MATLAB: Is there a way to turn certain parts of a binary image from black to white and white to black

binaryblackconvertdetectimageparticlesportionswitchwhite

I want to convert certain parts of a binary image from white to black so to avoid picking up detection of some particles. I know how to do this for the whole image. I just use
image=~image;
But how would I do this if I wanted to switch a certain portion of the image? Thank you!

Best Answer

Images are matrices in MATLAB, so you can use matrix addressing:
image_new = ~image_old(row_start:row_end, col_start:col_end);
If you want something other than to reverse a square section, you would have to do segmentation first. Image Analyst has demos on image segmentation in the File Exchange that I recommend to you.
Related Question