??? Assignment has more non-singleton rhs dimensions than non-singleton subscripts

9 vues (au cours des 30 derniers jours)
% my array declaration
imgarr=zeros([5,3,nFrames]);
% Create topleft quantized image
[img1,map] = rgb2ind(tl,64);
% color planes for topleft image
tl_rPlane = reshape(map(img1+1,1),size(img1)); % Red color plane for image
tl_gPlane = reshape(map(img1+1,2),size(img1)); % green color plane
tl_bPlane = reshape(map(img1+1,3),size(img1)); % blue color plane
imgarr(1,1,k)=imhist(tl_rPlane); % storing histograms for the 3 color planes to the kth dimension of the array..
imgarr(1,2,k)=imhist(tl_gPlane);
imgarr(1,3,k)=imhist(tl_bPlane);
my error:
??? Assignment has more non-singleton rhs dimensions than
non-singleton subscripts
Error in ==> modified at 42
imgarr(1,1,k)=imhist(tl_rPlane);
i need to store the histogram values of the three color planes to the array please do help me...im totally a newcomer to matlab...
[EDITED, Jan, code formatted]

Réponse acceptée

Jan
Jan le 28 Déc 2012
imhist replies a vector, but imgarr(1,1,k) is a scalar, if k is scalar. Perhaps you want imgarr to be a cell array:
imgarr = cell(5,3,nFrames);
...
imgarr{1,1,k} = imhist(tl_rPlane);
You can store only vectors of the same length in an numerical array, but in a cell array all elements can have different type and size. As a drawback, it is much harder to perform calculations with cell arrays, of course.
  1 commentaire
soumya
soumya le 31 Déc 2012
Thank u boss....i was a bit confused with cell array and numeric array concepts.... :)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Images dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by