Harshal Zope
Harshal Zope

Reputation: 1576

how to convert a particular white region(larger one) to black in B/W image in matlab?

I want to convert the particular white region of the image to black. black n white image

in the above image apart from eye portion what ever is white i want to turnit to black. How can I achieve that in Matlab 2016a.

Upvotes: 0

Views: 64

Answers (1)

Ozcan
Ozcan

Reputation: 726

I am sure there are lots of ways doing this. Connected component analysis, morphological operations etc. However, in your case you are trying to find the regions that contain left and right sides of the image. So just select those regions with bwselect and replace the pixels with zeros.

im=imread('eye.png');
[n,m]=size(im);
im2=im;
im2(bwselect(im,1,1))=0;
im2(bwselect(im2,m,n))=0;
figure,imagesc(im2),axis image;colormap gray

enter image description here

Upvotes: 1

Related Questions