MATLAB: Segmenting or Thresholding Blue

colorimage processingImage Processing Toolboxthresholding

I need to segment the color blue on this image.
It seems easy, but the software doesn't recognize the blue from some other structures in the image – which are clearly not blue.
Can anyone help?

Best Answer

Most color images are stored in RGB format. In other words, they are 3D matrices where the first, second, and third matrix represents the intensity of red, green, and blue respectively.
In your case, the simplest solution may be to isolate the blue-channel and perform segmenting on that image:
imageRaw = imread("source");
imageBlue = imageRaw(:,:,3);
imageBlueThresh = graythresh(imageBlue);
imageBlueBw = im2bw(imageBlue,imageBlueThresh);
What would you like to do with the segmented regions though? Remove everything else from the image? Outline them? Quantify something within those regions?
Related Question