Azzera filtri
Azzera filtri

how to solve this error??? Subscripted assignment dimension mismatch. Error in traincolorceder (line 100) IHSVMEAN(imgn,:)=IHSV;

2 visualizzazioni (ultimi 30 giorni)
Plsss help me to solve this error???
Traindatabasepath='E:\PROJECT2\original\appleleaves\ceder';
Trainfiles=dir(Traindatabasepath);
Trainnum=0;
for ii=1:size(Trainfiles,1)
if not(strcmp(Trainfiles(ii).name,'.')|strcmp(Trainfiles(ii).name,'..')|strcmp(Trainfiles(ii).name,'Thumbs.db'))
Trainnum=Trainnum+1;
end
end
imgccount=1;
for imgn=1:Trainnum
img=imread(strcat(Traindatabasepath,'\',num2str(imgn),'.jpg'));
% imshow(i);
% j=imresize(i,[256 256]);
% figure,imshow(j);
[r c]=size(img);
%global feature extraction
HSV=rgb2hsv(img);
H=HSV(:,:,1);
S=HSV(:,:,2);
V=HSV(:,:,3);
HM=mean(H(:));
SM=mean(S(:));
VM=mean(V(:));
k=1;
[r1 c1]=size(H);
for m=1:8:r1-7
for n=1:8:c1-7
BH=H(m:m+7,n:n+7);
BS=S(m:m+7,n:n+7);
BV=V(m:m+7,n:n+7);
BHM=mean(BH(:));
BSM=mean(BS(:));
BVM=mean(BV(:));
BMN=[BHM BSM BVM]';
BMEAN(k,:)=BMN;
k=k+1;
end
end
IH=zeros(k-1,1);
IS=zeros(k-1,1);
IV=zeros(k-1,1);
for p=1:k-1
if (BMEAN(p,1)>=HM)
IH(p)=1;
end
if (BMEAN(p,1)>=SM)
IS(p)=1;
end
if (BMEAN(p,3)>=VM)
IV(p)=1;
end
end
% IHSV=[IH IS IV]';
%IHSVMEAN(imgn,:,:)=IHSV;
IHSV=[IH' IS' IV'];
IHSVMEAN(imgn,:)=IHSV;
end
save colorlocal IHSVMEAN

Risposta accettata

Walter Roberson
Walter Roberson il 1 Feb 2017
Your images are not all the same size.
Note:
[r c]=size(img);
is probably a mistake. You do not use r or c so you might as well remove the line.
At that point in the code, img is an RGB image, so it has 3 dimensions. When you ask for only two outputs, the second output is number of columns times number of color planes -- the product of the outputs from size() is always equal to the number of elements in the array.

Più risposte (0)

Categorie

Scopri di più su Read, Write, and Modify Image in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by