Clear Filters
Clear Filters

a and b channels in CIELAB color space

3 views (last 30 days)
I am trying to convert an image from RGB (uint8,uint16) to LAB color space , I want to rescale it to [0 1] based on the max and min value of the color space not the image itself.. I would like to know the range that is used when I use rgb2lab..
in the documentation, it is mentioned that it can be [-100, 100] or [-128, 127) for a* and b* channels,
the question is how to know which one is used so I can use it and why these two different ranges??
ref: https://www.mathworks.com/help/images/ref/rgb2lab.html
Any references or explanation will be appreciated,

Accepted Answer

Image Analyst
Image Analyst on 28 Apr 2021
There is no max and min for the colorspace. a and b do not have defined range, like L (which represents percent reflectivity). I don't believe there is any need for you to rescale your a and b images. Why do you want to do that?
  4 Comments
MatlabUser
MatlabUser on 29 Apr 2021
Edited: MatlabUser on 29 Apr 2021
Thank you for replying @Image Analyst:
  1. I have ranges [0,50], [0,100], [ a, b ranges], [ -3,3]. for position, color, and other feature that has range [-3,3].
  2. I attached screenshots for RGB before convert to LAB
  3. I mentioned in point 1 the ranges, I noticed from the results the clustering is biased to the position feature, and the feature with range [-3,3] can not affect the results with its small range (unless I multiply by a large weight value).
  4. K-means (manual implementation not matlab function), and I read many articles saying since K-means is based on distance metric then the features should normalized to have same ranges.
Note: when I print the max and min value it is always within [-100 ,100] for 6 different images, but for two images b channel can reach to -101.2, so I am wondering if -100,100 is the range that I can use?
Image Analyst
Image Analyst on 29 Apr 2021
I don't believe you need to do that, though you can. That is necessary if for example one of your features is in the range of 1 million to 2 million, and another feature ranges from 0.01 to 0.1 - several orders of magnitude different such that you'd have a problem with truncation or roundoff errors. You don't have that situation. Yours are all in the range of -100 to +100 or so, which is not disparate enough to cause the problem. I don't see that normalization would be needed. That said, if you still insist on using it, you can call rescale on each column before doing kmeans on it, then undo the scaling on the centroid locations you found to get back to the original space.
But looking at your gamut, I don't see any real clusters that kmeans would do a good job at finding. You can see my demo and see that kmeans doesn't do such a great job with RGB images that don't have well defined clusters in the gamut (like yours).

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!