如何反转这种色彩空间转换?

时间:2019-03-06 02:13:19

标签: matlab colors

我正在尝试反转此功能:

XYZ2LMSmat = [0.3593 -0.1921 0.0071; 0.6976 1.1005 0.0748; -0.0359 0.0754 0.8433];
LMS2ICTCPmat = [2048 2048 0; 6610 -13613 7003; 17933 -17390 -543]'/4096;

invEOTF = @(Lin) (((3424/4096)+(2413/128)*(max(0,Lin)/10000).^(2610/16384)) ./ ...
(1+(2392/128)*(max(0,Lin)/10000).^(2610/16384))).^(2523/32);

ICTCP = bsxfun(@times, invEOTF(XYZ * XYZ2LMSmat) * LMS2ICTCPmat, [720, 360, 720]);

此脚本从XYZ转换为ICtCp颜色空间。输入(XYZ采用N x 3(rgb)矩阵的格式,该矩阵乘以3x3变换矩阵XYZ2LMSmatLMS2ICTCPmat

我正在尝试写相反的东西:从ICtCp到XYZ。

我具有invEOTF函数的反函数,即:

EOTF = @(PQ) (max(PQ.^(32/2523)-(3424/4096),0) ./ ... ((2413/128)-(2392/128)*PQ.^(32/2523))).^(16384/2610)*10000; 

Here is the reference for this code,其中有更详细的说明(文档末尾的Matlab代码)。

我不确定应该使用bsxfun的哪个标志以及如何安排矩阵求逆。

1 个答案:

答案 0 :(得分:0)

我发现拆分操作是有好处的,它使查看它们的操作并弄清楚如何扭转它们变得更加容易。这是您的计算:

step1 = XYZ * XYZ2LMSmat;
step2 = invEOTF(step1);
step3 = step2 * LMS2ICTCPmat;
ICTCP = bsxfun(@times, step3, [720, 360, 720]);

我们现在可以撤消以下步骤:

step3_back = bsxfun(@times, ICTCP, 1./[720, 360, 720]);
step2_back = step3_back / LMS2ICTCPmat;
step1_back = EOTF(step2_back);
XYZ_back = step1_back / XYZ2LMSmat;

如果step3step3_back,则可以将step2step2_backstep1step1_back以及XYZ_backXYZ进行比较不等于step2_back,以找出问题出在哪里。

我注意到step1_back为零时,step1step1不匹配。在step1_back为负的情况下会发生这种情况。 max保持为零。这是由于EOTF中的bsxfun被显式剪切所致。当X接近1且Y接近0时,就会发生这种情况(我使用XYZ的随机值在[0,1]范围内对此进行了测试)。


请注意,对于MATLAB R2016b及更高版本,通常不再需要ICTCP = step3 .* [720, 360, 720]。您只需编写.tl-postShare{text-align:right;} .tl-postShare ul{display:inline-block;} .tl-postShare ul li{margin:0;} .tl-tagnShare{position:relative;overflow:hidden;line-height:45px;margin-top:25px;} .tl-postShare .tl-social-icons.icon-circle .fa{margin-right:7px} .tl-postShare h6{display:inline-block;font-size:15px;margin:0 10px 0 0;line-height:35px;}

相关问题