Conversion of RGB images into Lab color space

30 ビュー (過去 30 日間)
Naseeb Gill
Naseeb Gill 2016 年 5 月 20 日
コメント済み: Andrew Lee 2021 年 11 月 30 日
Hello, I tried to convert the RGB image into Lab color space using following two codes in MATLAB2014b(first code use RGB while second code use sRGB). For both code, output Lab images are different. I cannot get any use able data using these images. Also, my images are totally different from few images, I found on internet of Lab color space (I searched Lab image on internet to know how Lab images look like).
Codes which I used are below:
first code
A = imread('C:\Users\Naseeb\Desktop\images\1.jpg');
lab = rgb2lab(A);
imshow(lab);
Second Code:
A = imread('C:\Users\Naseeb\Desktop\images\1.jpg');
colorTransform = makecform('srgb2lab');
lab = applycform(A, colorTransform);
imshow(lab);
Also, I observe that image obtained from second code is same as image I get by converting RGB into YCrCb image. How can I get correct Lab image.
I'm attaching my images with this. Original image (RGB image which used to convert into Lab); 1st code (Lab image from 1st code); 2nd code (Lab image from 2nd code); internet image (which I found on internet to know how Lab image look like)
  5 件のコメント
Naseeb Gill
Naseeb Gill 2016 年 5 月 20 日
Dear Adam,
For storing and processing also it is creating a problem. For example when I changed RGB into HSV, at that instance using point cursor in matlab window all values H,S and V are below one but when I saved image as jpg it's HSV value get changed. But I want the real color space values which is between 0-1 after saving image. I'm attaching both images for your reference. I want these point to plot on graph.
Andrew Lee
Andrew Lee 2021 年 11 月 30 日
may I know at the end of this, which code did you use for the conversion. And how did you store the La*b* values which ranged from 0to100 for L, and -128to127 for a* & b* so that you can furthere process with it?

サインインしてコメントする。

回答 (1 件)

Image Analyst
Image Analyst 2016 年 5 月 20 日
NASEEB: See Steve's blog for lots and lots of info: http://www.mathworks.com/search/site_search.html?q=color+space&c[]=blogs
I use rgb2lab() to convert to CIE LAB color space whenever I need relative, quick and dirty, kind of color space conversion. Never use JPG images for image analysis. It's no wonder the values are different. JPG will destroy the image to various degrees. Use PNG instead.
All of those are "book" formulas. They will not give you the "true" LAB like you'd get from a spectrophotometer. Most of the time I use calibrated digital color imaging because I need the "true" LAB values out, not some arbitrary ones. But that's a much higher level of sophistication that you probably want to do.
For a color toolbox by one of the worlds leading color researchers, you can get Professor Westland's toolbox here: http://www.mathworks.com/matlabcentral/fileexchange/40640-computational-colour-science-using-matlab-2e He literally wrote the book on color analysis with MATLAB. http://www.mathworks.com/matlabcentral/fileexchange/28790-colorspace-transformations

カテゴリ

Help Center および File ExchangeConvert Image Type についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by