Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
875 views
in Technique[技术] by (71.8m points)

image processing - Should I use HSV/HSB or RGB and why?

I have to detect leukocytes cells in an image that contains another blood cells, but the differences can be distinguished through the color of cells, leukocytes have more dense purple color, can be seen in the image below.

What color methode I've to use RGB/HSV ? and why ?!

sample image:

Blood cells image

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Usually when making decisions like this I just quickly plot the different channels and color spaces and see what I find. It is always better to start with a high quality image than to start with a low one and try to fix it with lots of processing

In this specific case I would use HSV. But unlike most color segmentation I would actually use the Saturation Channel to segment the images. The cells are nearly the same Hue so using the hue channel would be very difficult.

hue, (at full saturation and full brightness) very hard to differentiate cells

enter image description here

saturation huge contrast

enter image description here

Green channel, actually shows a lot of contrast as well (it surprised me)

enter image description here

the red and blue channels are hard to actually distinguish the cells.

Now that we have two candidate representations the saturation or the Green channel, we ask which is easier to work with? Since any HSV work involves us converting the RGB image, we can dismiss it, so the clear choice is to simply use the green channel of the RGB image for segmentation.

edit

since you didn't include a language tag I would like to attach some Matlab code I just wrote. It displays an image in all 4 color spaces so you can quickly make an informed decision on which to use. It mimics matlabs Color Thresholder colorspace selection window

function ViewColorSpaces(rgb_image)
    % ViewColorSpaces(rgb_image)
    % displays an RGB image in 4 different color spaces. RGB, HSV, YCbCr,CIELab
    % each of the 3 channels are shown for each colorspace
    % the display mimcs the  New matlab color thresholder window
    % http://www.mathworks.com/help/images/image-segmentation-using-the-color-thesholder-app.html

    hsvim = rgb2hsv(rgb_image);
    yuvim = rgb2ycbcr(rgb_image);

    %cielab colorspace
    cform = makecform('srgb2lab');
    cieim = applycform(rgb_image,cform);

    figure();
    %rgb
    subplot(3,4,1);imshow(rgb_image(:,:,1));title(sprintf('RGB Space

red'))
    subplot(3,4,5);imshow(rgb_image(:,:,2));title('green')
    subplot(3,4,9);imshow(rgb_image(:,:,3));title('blue')

    %hsv
    subplot(3,4,2);imshow(hsvim(:,:,1));title(sprintf('HSV Space

hue'))
    subplot(3,4,6);imshow(hsvim(:,:,2));title('saturation')
    subplot(3,4,10);imshow(hsvim(:,:,3));title('brightness')

    %ycbcr / yuv
    subplot(3,4,3);imshow(yuvim(:,:,1));title(sprintf('YCbCr Space

Luminance'))
    subplot(3,4,7);imshow(yuvim(:,:,2));title('blue difference')
    subplot(3,4,11);imshow(yuvim(:,:,3));title('red difference')

    %CIElab
    subplot(3,4,4);imshow(cieim(:,:,1));title(sprintf('CIELab Space

Lightness'))
    subplot(3,4,8);imshow(cieim(:,:,2));title('green red')
    subplot(3,4,12);imshow(cieim(:,:,3));title('yellow blue')

end

you could call it like this

rgbim = imread('http://i.stack.imgur.com/gd62B.jpg');
ViewColorSpaces(rgbim)

and the display is this

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...