What is the discrete step size after rgb2hsv conversion

2 views (last 30 days)
Hi everyone,
For my internship I'm doing some image processing, just starting out and it is a surprisingly large and interesting field :-) Currently I'm thresholding HSV images, but my input images are in the RGB 24 bit color space.
I'm converting my 8 bit RGB colour channels to HSV channels with the matlab 'rgb2hsv' function. Quite an easy step, but I also need to know what the discrete step size of the different channels (i.e. H, S and V) are. Is there some way to calculate this? Is there a general formula that you can apply to an X-bit RGB image to obtain the discrete steps in the HSV colour space?
Thanks in advance for your comments!

Accepted Answer

Image Analyst
Image Analyst on 13 Dec 2013
What do you mean by the step size? The spatial quantization of the hsv images is the same as your input images. The intensity quantization depends on the range of what you put in. Try this code and examine the output
rgbImage = imread('peppers.png');
hsvInt = rgb2hsv(rgbImage);
hsvDouble = rgb2hsv(double(rgbImage));
rgbScaled = im2double(rgbImage);
hsvScaled = rgb2hsv(rgbScaled);
whos hsvInt
hsvInt(200,200,3)
whos hsvDouble
hsvDouble(200,200,3)
whos hsvScaled
hsvScaled(200,200,3)
  4 Comments
Dabbler
Dabbler on 16 Dec 2013
What I want to do after conversion is to threshold the image. To do this I created six thresholds: hueLowerBound, hueUpperBound, satLowerBound, satUpperBound, valLowerBound, valUpperBound. The lower bound for the hue is defined as the smallest amount of degrees from 0 to 340 and the hueUpperBound is defined as the smallest amount of degrees from 0 to 20 degrees.
I did some hand selections of the regions of interest by hand. In Matlab I want to optimize the thresholds by comparing them with this golden standard (the hand selection). The problem lies within the fact that optimizing these six parameters requires a huge amount of processing power, when done in a brute force grid search. One low resolution grid search with 11^6 possibilities took me about three hours ^_^ It took three of these runs during my previous weekend to get down to a mismatch of lower than 5%. The mismatch being defined as the overestimated pixels + the underestimated pixels.
After this initial grid search I was wondering how to bring down computing time and what the amount of significant digits should be. Implementing a search with the matlab fminsearch already brought my calculation time down to 60 seconds, with very similar results. (although this is offcourse a non-exhaustive search method).
Because I wanted to assess how well the fminsearch performed, I wanted to plot the parameter space. This way I could see in more detail, how sensitive / insensitive my parameters are. This is the point, where I realised that I didn't knew anything about the bits per pixel.
The fact that the rgb2hsv converts my discrete numbers to "infinite" numbers doesn't make it any easier. Offcourse I'm not going to evaluate the parameters up to a resolution of 53 bits. In this case I will get there through some trial and error.
Any tips are more than welcome. For example, do you think I can get better detection of my area by using a blob detection method?
This is what most of my histological slices look like: Image on Nature's Website. Except for the fact that my scaffold is dark black and my tissue is deep red.
Image Analyst
Image Analyst on 16 Dec 2013
I don't know what you're doing when you do the optimization but if you're adjusting values, you don't have to change them in jumps of 0.0000000001, you can do larger jumps. Just see what a one gray level difference corresponds to. Find the hue for (128,128,128) and for (128,128,129) and see how much the hue is different, then just change your steps by that much.
Anyway, it really depends on what shape of the gamut do you want to carve out of the image. HSV will get you a cylindrical pie shaped sector. Delta E will get you a sphere. RGB will get you a rectangular block (in RGB space). It also depends on if you want to apply the same color classification to each image or if you want it to adapt thresholds depending on the image content.

Sign in to comment.

More Answers (0)

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!