フィルターのクリア

Why i'm getting different results from RGB to XYZ color conversion?

6 ビュー (過去 30 日間)
Bruno Tondin
Bruno Tondin 2018 年 7 月 4 日
編集済み: KARSH THARYANI 2018 年 7 月 6 日
Hello,
I'm performing a color conversion from RGB to XYZ using 3 methods. The first one is the MATLAB suggested function
IM_XYZ = rgb2xyz(IM_ORIG);
The second one is another bult in matlab function
cform = makecform('srgb2xyz');
IM_XYZ2 = applycform(IM_ORIG,cform);
The third one I did it myself using the the matrix used in Lindbloom website (inside one of the functions that the rgb2xyz() function calls i could find the same matrix and even the Lindbloom website reference).
The problem is that i'm getting different results from the 3 ways.
Can someone help me?
Thanks
All my code:
clc;
clear;
close all
%%Generate test image
R = [255 0 0; 255 0 85; 22 34 115];
G = [0 255 0; 255 0 85; 82 12 85];
B = [0 0 255; 255 0 85; 101 66 22];
IM_ORIG(:,:,1) = R;
IM_ORIG(:,:,2) = G;
IM_ORIG(:,:,3) = B;
IM_ORIG = (IM_ORIG)./255;
%%Converte imagem RGB para XYZ
IM_XYZ = rgb2xyz(IM_ORIG); % first method
cform = makecform('srgb2xyz');
IM_XYZ2 = applycform(IM_ORIG,cform); % second method
% conversion matrix (http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html)
M_conv = [0.4124564 0.3575761 0.1804375; ...
0.2126729 0.7151522 0.0721750; ...
0.0193339 0.1191920 0.9503041];
RGB(:) = IM_ORIG(1,1,:);
aa = M_conv*(RGB');
for i = 1:size(IM_ORIG,1)
for j = 1:size(IM_ORIG,2)
RGB(:) = IM_ORIG(i,j,:);
IM_XYZ3(i,j,:) = (M_conv*(RGB'))';
end
end
  1 件のコメント
KARSH THARYANI
KARSH THARYANI 2018 年 7 月 6 日
編集済み: KARSH THARYANI 2018 年 7 月 6 日
Are you sure that the input to both the functions is absolute, in the sense that the RGB spectrum format for an image is relative(sRGB is different from RGB). Hence, if one function assumes input as RGB and the other as sRGB, is it not possible that their conversion outputs might be different?
Also, in your method 3 it seems that you are not making R_srgb to R_linear, as stated in the Wikipedia article here

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeData Types についてさらに検索

製品


リリース

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by