??? 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 个评论
karthick ganesan
karthick ganesan 2015-6-14
编辑:Walter Roberson 2015-6-14
thanks for reply.
chandrangray is i1, i changed the program chandrangray===i1
i1==> gray image

请先登录,再进行评论。

采纳的回答

Walter Roberson
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 个评论
karthick ganesan
karthick ganesan 2015-6-15
编辑:Walter Roberson 2015-6-15
??? Subscripted assignment dimension mismatch.
Error in ==> parallel_function at 479
consume(base, limit, F(base, limit, supply(base, limit)));
Error in ==> Untitled at 34
parfor sqr=1:8,
same error occur in cameraman image but no error in onion image
i attached program below
i1=imread('cameraman.tif');
%i=imread('E:\svm-k\images\6.jpg');
%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;
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, : );
rectangle=[cropfromy cropfromy croptox croptoy];
squares=zeros(floor(side-1),floor(side-1),8);
squres=imcrop(images(:,:,1),rectangle);
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
Walter Roberson
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 CenterFile Exchange 中查找有关 Data Type Identification 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by