Matlab将图像的一半留白

问题描述 投票:2回答:1

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

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

我正在得到这个:

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

matlab resize imshow imread
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
© www.soinside.com 2019 - 2024. All rights reserved.