Image Conversion and Lab Colourspace range.
조회 수: 3 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
채택된 답변
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.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!