Extracting blue objects of interest
3 views (last 30 days)
I have an image of a circuit board with very blue chips. I want to display the blue chips as blue and display the rest of the board in greyscale.
My approach so far is:
image = imread('board.tif');
redBand = image(:,:,1); greenBand = image(:,:,2); blueBand = image(:,:,3);
After this I want to get everything in greyscale but display the blue chips on the same image. I think I have to put a red and green mask but I'm unsure how to do this. Any insights?
Christiaan on 24 Mar 2015
I made a code for you, where first the color 'blue' is detected at a certain threshold. (here 200) Then with a for loop, all points where the color is below the threshold are neglected. The image I used has been put in the attachment.
clc; clear all; close all;
% Read standard MATLAB demo image.
rgbImage = imread('board.jpg');
% Display the original image.
subplot(1, 3, 1);
title('Original RGB Image');
% Maximize figure.
set(gcf, 'Position', get(0, 'ScreenSize'));
% Split into color bands.
redBand = rgbImage(:,:, 1);
greenBand = rgbImage(:,:, 2);
blueBand = rgbImage(:,:, 3);
% Display them.
subplot(1, 3, 2);
% here objects which are parly blue make totaly blue
% here objects which are not blue to dark
% Display them.
subplot(1, 3, 3);
im = cat(3,redBand,greenBand,blueBand);
A second possibility would be using a tool from the File Exchange. A nice feature is 'imoverlay'. If you call this tool by writing in the prompt : >>imoverlay_tool and then use as a background 'blueband' (0-255), in the foreground'blueband' (200-250) and in the overlay (alpha 0.8) you obtain a figure that is blue where the objects are blue and the rest is gray.
Good luck! Christiaan
Image Analyst on 24 Mar 2015
You can use my demos that find specified colors. Try the delta E one, or the one that does it in HSV color space.
Change the thresholds in the HSV one to get blue instead of yellow. For the delta E demo, you don't need to do that because you give it an example of the color you want to find by tracing a small region.