Reputation: 513
image=double(imread('ooutput.jpg'));
[M, N]=size(image);
masked=zeros(M,N);
masked(1:100,1:90)=255;
masked(175:300,1:90)=255;
imshow(masked);
new=uint8( masked&image);
imshow(new);
I used logical and to obtain a portion of image.Here a mask is created and logically and it with image.I am not able to get the portion.instead a get complete black pixel.Can anyone point out what is the mistake in the above code?
Upvotes: 0
Views: 368
Reputation: 36710
'masked&image' is either 1 or 0. Using uint8, both is close to black. Besides this, your code fails for all image types except grayscale uint 8.
To fix the mask issue, use:
image=imread('ooutput.jpg');
masked=false(M,N);
masked(1:100,1:90)=true;
masked(175:300,1:90)=true;
image(~masked)=0
imshow(image);
Upvotes: 2