Search code examples
matlabresizeimshowimread

Matlab make half of the image blank


Got an issue on matlab, trying to make half of the image blank without resizing to it. ATM im using that simple code

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

And im geting this:

What is actually i need to have is something like this:

Ty


Solution

  • Try this:

    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