Should I use HSV / HSB or RGB and why?

I have to detect white blood cells in an image that contains other blood cells, but the differences can be distinguished by the color of the cells, the white blood cells have a denser purple color, can be seen in the image below.

What color code should I use RGB / HSV? and why?!

sample image:

Blood cells image

+4
source share
2 answers

Usually when making such decisions, I just draw different channels and color spaces and see what I find. It is always better to start with a high quality image than start with a low quality and try to fix it with a lot of processing

In this particular case, I would use HSV. But, unlike most color segments, I would use the saturation channel to segment images. The cells are almost the same with the shade, so using a thin channel will be very difficult.

hue (at full saturation and full brightness) it is very difficult to distinguish between cells

enter image description here

intense huge contrast

enter image description here

The green channel actually also shows a lot of contrast (it surprised me)

enter image description here

red and blue channels are difficult to distinguish cells.

Now that we have two representations of the candidate: saturation or the green channel, we ask, what is easier to work with? Since any HSV job involves converting an RGB image, we can discard it, so the obvious choice is to simply use the green channel of the RGB image for segmentation.

change

since you did not specify a language tag, I would like to add some Matlab code that I just wrote. It displays the image in all 4 color spaces so you can quickly make an informed decision about its use. It mimics the Matlabs Color Thresholder color picker.

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\n\nred')) 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\n\nhue')) 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\n\nLuminance')) 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\n\nLightness')) 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 that

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

and the display shows

enter image description here

+12
source

in DIP and CV this is always the right question

But he does not have a universal answer, because each task is unique, so use what works best for her. To choose the right one, you need to know the pros and cons of each of them, so here are a few summaries:

  • RGB

    this is easy to handle and you can easily access the r, g, b ranges. For many cases, it is better to check only one strip instead of a whole color or mix colors to emphasize the desired function or even moisturize the undesirable. It is difficult to compare colors in RGB due to the intensity encoded in the bands directly. To fix this, you can use normalization, but it is slow (required per pixel sqrt). You can do arithmetic on RGB colors directly.

    An example of a task more suitable for RGB:

  • HSV

    better suited for color recognition, because CV algorithms using HSV have a very similar visual perception of human perception, so if you want to better recognize areas of different colors, then HSV. Converting between RGB / HSV takes a little time, which may be due to higher resolutions or hi fps applications. For standard DIP / CV tasks this is usually not the case.

    An example of a task more suitable for HSV:

    Take a look at:

    to see a clear color separation in HSV. Color-based image segmentation is easy in HSV. You cannot do arithmetic on HSV colors directly, instead you need to convert to RGB and vice versa

+2
source

Source: https://habr.com/ru/post/1234947/


All Articles