Image Conversion and Lab Colourspace range.

조회 수: 2 (최근 30일)
Simon Kirkman
Simon Kirkman 2020년 8월 21일
댓글: Simon Kirkman 2020년 8월 28일
I have two questions about converting images to different colourspaces and performing operations on them. If I have an RGB image and I want to convert it to Lab I can use the rgb2lab function in MATLAB. If I then want to perform operations on the converted image (I am doing colour correction using least squares regression) but when I do this I am getting max Values of
  • L = 149
  • a = 214
  • b = 255
These values fall outside of the range of the Lab colourspace (l = (0:100) a&b = (-128:127).
First of all how could I get an empty Lab image without using rgb2lab on the original image which i could then perform operations on. The second question is would if be right to clip the values so they do not go outside the maximum range like when performing operations on rgb images they are clipped at 255 and 0?
My code is as follows.
% creating an Image in Lab to work on
LabCorrectedImage = rgb2lab(colour);
[rows,cols,channels] = size(LabCorrectedImage);
% Modifying L values with least squares regression using constants obtained against a colour chart
for col = 1:cols
for row = 1:rows
redPixel = correctedImage(row, col,1);
greenPixel = correctedImage(row,col,2);
bluePixel = correctedImage(row,col,3);
LabCorrectedImage(rows,col,1) = Alphas(1,1)+ (Alphas(2,1)*redPixel) + (Alphas(3,1)* greenPixel)+(Alphas(4,1)*bluePixel)+(Alphas(5,1)*redPixel^2)+(Alphas(6,1)* greenPixel^2)+ (Alphas(7,1)*bluePixel^2) + (Alphas(8,1)*redPixel*greenPixel) +(Alphas(9,1)*redPixel*bluePixel)+(Alphas(10,1)*greenPixel*bluePixel);
end
end
% Modifying a values with least squares regression using constants obtained against a colour chart
for col = 1:cols
for row = 1:rows
redPixel = correctedImage(row, col,1);
greenPixel = correctedImage(row,col,2);
bluePixel = correctedImage(row,col,3);
LabCorrectedImage(rows,col,2) = Bethas(1,1)+ (Bethas(2,1)*redPixel) + (Bethas(3,1)* greenPixel)+(Bethas(4,1)*bluePixel)+(Bethas(5,1)*redPixel^2)+(Bethas(6,1)* greenPixel^2)+ (Bethas(7,1)*bluePixel^2)+ (Bethas(8,1)*redPixel*greenPixel) +(Bethas(9,1)*redPixel*bluePixel)+(Bethas(10,1)*greenPixel*bluePixel);
end
end
% Modifying b values with least squares regression using constants obtained against a colour chart
for col = 1:cols
for row = 1:rows
redPixel = correctedImage(row, col,1);
greenPixel = correctedImage(row,col,2);
bluePixel = correctedImage(row,col,3);
LabCorrectedImage(rows,col,3) = Gammas(1,1)+ (Gammas(2,1)*redPixel) + (Gammas(3,1)* greenPixel)+(Gammas(4,1)*bluePixel)+(Gammas(5,1)*redPixel^2)+(Gammas(6,1)* greenPixel^2)+ (Gammas(7,1)*bluePixel^2)+ (Gammas(8,1)*redPixel*greenPixel) +(Gammas(9,1)*redPixel*bluePixel)+(Gammas(10,1)*greenPixel*bluePixel);
end
end

채택된 답변

Prabhan Purwar
Prabhan Purwar 2020년 8월 28일
Hi,
Lab Images are represented in a matrix format of m*n*3, kindly create an empty matrix of the same size to get an empty Image structure. I would suggest going with a color correction method that is suitable for Lab Image representation. Clipping of values may lead to Normalization or data loss.
Hope it helps!!
Thanks.
  댓글 수: 1
Simon Kirkman
Simon Kirkman 2020년 8월 28일
Thanks. I have used least squares regression to do the colout correction and I have gone from RGB to XYZ. in my formula I have limited the values from going above 1 and below zero. I am getting relatively high values for delta E but they are consistent across all the calibration images I have taken so I am sticking to this method for now. For the empty image I have used rgb2xyz on the original image an then done my calibration on this image. Thanks for your message, if you think that anything I'm doing is wrong please let me know.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Red에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by