matlabimage-processingimage-segmentationdeconvolution

Problems in automatically set reference color


I was trying to segment blue cells from the image, enter image description here

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?


Solution

  • 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)
    

    Blue channel of input image

    Do some thresholding. A very simple version could be:

    cellsSegm = cellsBlue < 100;
    imshow(cellsSegm)
    

    Thresholding in blue channel

    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)
    

    HSV color space

    Select the "saturation" channel of the HSV image:

    cellsSat = cellsHSV(:, :, 2);
    imshow(cellsSat)
    

    Saturation channel of HSV image

    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)
    

    Thresholding in saturation channel

    Afterwards you will need to apply some morphological filters to improve the masks.