??? Subscripted assignment dimension mismatch.

11 views (last 30 days)
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 Comments
B.k Sumedha
B.k Sumedha on 13 Jun 2015
Whats ur function chandrangray??
karthick ganesan
karthick ganesan on 14 Jun 2015
Edited: Walter Roberson on 14 Jun 2015
thanks for reply.
chandrangray is i1, i changed the program chandrangray===i1
i1==> gray image

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 14 Jun 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 Comments
karthick ganesan
karthick ganesan on 15 Jun 2015
Edited: Walter Roberson on 15 Jun 2015
??? 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 on 15 Jun 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]

Sign in to comment.

More Answers (0)

Categories

Find more on Data Type Identification in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!