MATLAB: Changing black pixels to white.

image processing

How can I keep the small black pixels and change the large lump of black pixels to white?

Best Answer

inverted = ~YourBWImae; %now black is 1, white is 0
Now you can do bwareafilt() on inverted, telling to keep only the groups that are sufficiently small for your purpose. Then after that, invert the result of that so that black goes back to being represented by 0.