MATLAB: Turn background to one color

image processingimage segmentation

I have an RGB image and I want to do something similar to a binary image. But instead of black and white colors, I want some objects to be white, while the background of the image should be blue. How can I accomplish this?
I've tried using for loops, but not sure how to do iterate through RGB images properly.

Best Answer

  • Threshold the image and do your thresholding to get your binary image. Then follow Steve's directions if you want the detected regions in the overlay.
    If you want the blue to be "burned in" to an RGB image, then you need to first get the individual color channels, and then do
    redChannel(binaryImage) = 0;
    greenChannel(binaryImage) = 0;
    blueChannel(binaryImage) = 255;
    rgbImage = cat(3, redChannel, greenChannel, blueChannel);