??? Subscripted assignment dimension mismatch.
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
karthick ganesan
le 13 Juin 2015
Commenté : Walter Roberson
le 15 Juin 2015
I am struck in this error can any one help me i am run this program,i am getting like that
??? Subscripted assignment dimension mismatch.
Error in ==> parallel_function at 479 consume(base, limit, F(base, limit, supply(base, limit)));
Error in ==> rdm at 27 parfor sqr=1:8, squares(:,:,sqr)=imcrop(images(:,:,sqr),rectangle);end
how to clear this error any one know that help me i attached program below
i=imread('onion.png');
i1=(rgb2gray(i));
[row colm]=size(i1);
%imshow(i1);
images=zeros(row,colm,8);
images(:,:,1)=i1;
images(:,:,2)=imrotate(i1,-90*(1/4),'bilinear','crop');
images(:,:,3)=imrotate(i1,-90*(2/4),'bilinear','crop');
images(:,:,4)=imrotate(i1,-90*(3/4),'bilinear','crop');
images(:,:,5)=imrotate(i1,-90,'bilinear','crop');
images(:,:,6)=imrotate(i1,-90*(5/4),'bilinear','crop');
images(:,:,7)=imrotate(i1,-90*(6/4),'bilinear','crop');
images(:,:,8)=imrotate(i1,-90*(7/4),'bilinear','crop');
diameter=row;
midpoint=floor(diameter/2);
side=sqrt(2)*midpoint;
rectangle=[midpoint-floor(side/2+2) midpoint-floor(side/2-2) side-2 side-2];
parfor sqr=1:8, squares(:,:,sqr)=imcrop(images(:,:,sqr),rectangle);end
scaledsquares=zeros(size(squares));
numlev=8;
for sqr=1:8
im=squares(:,:,sqr);
graylevels = [min(im(:)) max(im(:))];
[glcm, scaledsquares(:,:,sqr)]=graycomatrix(im,'numlevels',numlev,'G',graylevels);
end
2 commentaires
Réponse acceptée
Walter Roberson
le 14 Juin 2015
I am not sure why you are getting that message.
On the other hand, imcrop() is really just array indexing, so recode as
cropfromx = midpoint-floor(side/2+2);
cropfromy = midpoint-floor(side/2-2);
croptox = cropfromx + side - 2
croptoy = cropfromy + side - 2;
squares = images(cropfromy : croptoy, cropfromx : croptox, : );
All just array indexing...
Note: the size returned might differ slightly from what imcrop() would return, as imcrop() deals with pixel centers rather than pixel edges. You might want to tweak the start or end by 1.
2 commentaires
karthick ganesan
le 15 Juin 2015
Modifié(e) : Walter Roberson
le 15 Juin 2015
Walter Roberson
le 15 Juin 2015
I am not sure why you commented out the simple indexing I showed and went for the parfor version instead?
Note that the rectangle() you build is wrong for imcrop(): imcrop() takes a rectangle which is [x y width height] not [firsty lasty firstx lastx]
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Data Type Identification dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!