Output argument <XX> (and possibly others) not assigned a value in the execution with <YY> function
I have a function script as follows:
function [h]=getColorHist(im, color_table, opt) im = rgb2hsv(im); [ht,wid,~]=size(im); if opt == 'euc' % euclidean distance D = pdist2(color_table, reshape(im, [ht*wid, 3])); end end
f_hist(f_cnt, :) = getColorHist(hsv_im, color_table,'euc')
where HW3.m is:
im_path='/MATLAB Drive/Published/NWPU-RESISC45_1'; ids = {'airplane', 'airport', 'baseball_diamond', 'baseball_court', 'beach','bridge','chaparral', 'church', 'circular_farmland', 'cloud','commercial_area','dense_residental', 'desert', 'forest', 'freeway'}; kColor = 64; color_table = getHSVColorTable_2(im_path, ids, kColor); nClass = length(ids); nImg = 40; f_hist = zeros(nImg*nClass, kColor); labels = zeros(nImg*nClass, 1); f_cnt = 0; for k=1:nClass % list of files class_path = sprintf('%s/%s', im_path, ids{k}); f_list = dir(sprintf('%s/*.jpg', class_path)); offs = randperm(length(f_list)); % load random 256 pixels from each images if isempty(offs) == 0 for j=1:nImg f_cnt = f_cnt + 1; % read in a random image from the class im = imread(sprintf('%s/%s', class_path, f_list(offs(j)).name)); hsv_im = rgb2hsv(im); f_hist(f_cnt, :) = getColorHist(hsv_im, color_table,'euc'); labels(f_cnt) = k; % plot if (1) figure(3); subplot(nClass, nImg, f_cnt); plot(f_hist(f_cnt, :)); grid on; end end end end
function [color_table]=getHSVColorTable_2(im_path, ids, kColor) dbg=1; if dbg im_path='/MATLAB Drive/Published/NWPU-RESISC45_1'; ids = {'airplane', 'airport', 'baseball_diamond', 'baseball_court', 'beach','bridge','chaparral', 'church', 'circular_farmland', 'cloud','commercial_area','dense_residental', 'desert', 'forest', 'freeway'}; kColor = 64; end nClass = length(ids); nImg = 40; nPixelPerImage = 256; % sample images from the repository to train a global HSV color table % training pixels x = zeros(nImg*nPixelPerImage*nClass, 3); cnt = 0; for k=1:nClass % list of files class_path = sprintf('%s/%s', im_path, ids{k}); f_list = dir(sprintf('%s/*.jpg', class_path)); offs = randperm(length(f_list)); % load random 256 pixels from each images if isempty(offs) == 0 for j=1:nImg % read in a random image from the class im = imread(sprintf('%s/%s', class_path, f_list(offs(j)).name)); hsv_im = rgb2hsv(im); [ht,wid,~] = size(im); hsv_im = reshape(hsv_im, [ht*wid, 3]); pix_offs = randperm(ht*wid); x(cnt+1:cnt+nPixelPerImage, :) = hsv_im(pix_offs(1:nPixelPerImage), :); cnt = cnt + nPixelPerImage; end % plot if dbg figure(1); subplot(1, nClass, k); subplot(1, nClass, k); imshow(im); title(ids{k}); end end end
The error is simple. In the given function:
function [h]=getColorHist(im, color_table, opt) im = rgb2hsv(im); [ht,wid,~]=size(im); if opt == 'euc' % euclidean distance D = pdist2(color_table, reshape(im, [ht*wid, 3])); end end
function D=getColorHist(im, color_table, opt) im = rgb2hsv(im); [ht,wid,~]=size(im); if opt == 'euc' % euclidean distance D = pdist2(color_table, reshape(im, [ht*wid, 3])); end end
Matlabsolutions.com provides guaranteed satisfaction with a
commitment to complete the work within time. Combined with our meticulous work ethics and extensive domain
experience, We are the ideal partner for all your homework/assignment needs. We pledge to provide 24*7 support
to dissolve all your academic doubts. We are composed of 300+ esteemed Matlab and other experts who have been
empanelled after extensive research and quality check.
Matlabsolutions.com provides undivided attention to each Matlab
assignment order with a methodical approach to solution. Our network span is not restricted to US, UK and Australia rather extends to countries like Singapore, Canada and UAE. Our Matlab assignment help services
include Image Processing Assignments, Electrical Engineering Assignments, Matlab homework help, Matlab Research Paper help, Matlab Simulink help. Get your work
done at the best price in industry.