MATLAB: A null assignment can have only one non-colon index. When I eliminated elements of matrix

matrix

Finally I accept this command
croppedImage = fullImage(row1:row2, col1:col2, :);
[iH, iW]=size(I(:,:,1));
[iHo, iWo]=size(O(:,:,1)); %original image size
if iH > iW
I(:,:,1:3)=[ I(:,:,1:3) zeros((iH-iW),iH,3)];
iW=iH;
Z=1;
elseif iH<iW
I(:,:,1:3)=[ I(:,:,1:3);zeros((iW-iH),iW,3)];
iH=iW;
Z=-1;
else
Z=0;
end
1 Judge the shape of the image. If it is not square, make it square by adding black pixels.
2 After arnold and unarnold transforming, I want to remove the black pixels
if iHo>iWo
outImg(iHo,(iHo-iWo),1:3)=[];
else if iHo<iWo
outImg((iWo-iHo),iHo,1:3)=[];
end
end
figure
imshow(outImg);
A null assignment can have only one non-colon index.
Error in unarnold (line 49)
outImg(iHo,(iHo-iWo),1:3)=[];

Best Answer

You cannot do that. You have a color image. Now imagine that you have identified some pixel in the image, say the one at the top left (1,1). Now you want to remove that pixel. Well, you can't. You can't even do it with a 2-D image, much less a 3-D color image. Let's say you had a 2-D 2 by 2 image like this:
100 140
210 155
Now you want to remove the 100 and be left with an image like this:
140
210 155
Well, the image would no longer be rectangular as is required. You can't have an L-shaped image. You can set that pixel to zero or some other value, but you can't just get rid of it since images must remain rectangular.
Related Question