Preallocation of Array that is storing histograms in Matlab -
x = []; y = []; = 1:m qimg = imread(fullfile(dir2, queryframes(i).name),fmt); image1 = rgb2gray(qimg); x = [x, imhist(image1)]; end j= 1:n rimg = imread(fullfile(dir1, refframes(j).name),fmt); image2 = rgb2gray(rimg); y = [y, imhist(image2)]; end
can show me how can preallocate x , y, 2 arrays storing histograms. matlab suggests preallocation both arrays speed. help.
by default grayscale images (which have), imhist
creates histogram using 256 bins (docs here) , outputs column vector. therefore, unless change number of bins in iterations want x have 256 rows. number of columns dictated number of images processing, here m
images x
variable , n
images y
variable.
therefore want initialize both variables follows:
x = double(256,m); y = double(256,n);
also, not recommended use i
or j
loop iterators since can confused imaginary unit.
Comments
Post a Comment