??? Subscripted assignment dimension mismatch.
12 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Walter Roberson
2015-6-14
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 个评论
Walter Roberson
2015-6-15
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]
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Identification 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!