I was trying to segment blue cells from the image,
I found that using color distance method is highly effective, however, I can only manually set the reference color in RGB. Since I want to do batch processing, I need to automatically select reference color, is there any good solutions?
I would like to present two very basic image processing approaches for this problem. Maybe one of them is useful for you.
Load input image:
cells = imread('cells.png');
Approach #1
Select the blue channel of the input image:
cellsBlue = cells(:, :, 3);
imshow(cellsBlue)
Do some thresholding. A very simple version could be:
cellsSegm = cellsBlue < 100;
imshow(cellsSegm)
Afterwards you will need to apply some morphological filters to improve the masks.
Approach #2
Convert input image to HSV color space:
cellsHSV = rgb2hsv(cells);
imshow(cellsHSV)
Select the "saturation" channel of the HSV image:
cellsSat = cellsHSV(:, :, 2);
imshow(cellsSat)
Do some thresholding. A very simple version could be (attention, HSV values are double values between 0 and 1):
cellsSegm = cellsSat > 0.5;
imshow(cellsSegm)
Afterwards you will need to apply some morphological filters to improve the masks.