2

在 matlab 上遇到问题,试图在不调整大小的情况下将图像的一半设为空白。ATM即时使用那个简单的代码

im=imread('spinpie.bmp');
n=fix(size(im,1)/2);
A=im(n+1:end,:,:);
imshow(A)

我得到了这个:

实际上我需要的是这样的:

4

1 回答 1

2

尝试这个:

im=imread('spinpie.bmp');
n=fix(size(im,1)/2);
A = repmat(255,size(im));           %// PreAllocating with white pixels
A(n+1:end,:,:) = im(n+1:end,:,:);   %// Assigning only the required pixels to original image
imshow(uint8(A));                   %// lastly converting double to uint8 before displaying
于 2015-05-17T15:09:46.403 回答