Convert RGB to HSI
28 ビュー (過去 30 日間)
古いコメントを表示
I am looking for the values in the first row of S of an HSI color model. Unfortunately, I do not get the desired values. I assume it is my conversion from rgb to hsi. Instead I use rgb2hsv. Does this make any difference?
R = [ 120 20 30;
170 20 70;
120 140 70 ]
G = [ 40 150 20;
20 110 20;
25 20 20 ]
B = [20 60 150;
190 20 250;
20 30 40]
I = zeros(3,3,3);
I(:, :, 1) = R;
I(:, :, 2) = G;
I(:, :, 3) = B;
Ir = rgb2hsv(I);
S = Ir(1,:,2)
% Desired output:
% [0.67 0.74 0.70]
%My output:
% [0.83 0.87 0.87 ]
0 件のコメント
採用された回答
DGM
2021 年 11 月 27 日
編集済み: DGM
2021 年 11 月 27 日
Yes, it makes a difference. Compare the results for HSI, HSL and HSV:
R = [ 120 20 30;
170 20 70;
120 140 70 ];
G = [ 40 150 20;
20 110 20;
25 20 20 ];
B = [20 60 150;
190 20 250;
20 30 40];
rgb = uint8(cat(3,R,G,B));
hsi = rgb2hsi(rgb);
hsl = rgb2hsl(rgb);
hsv = rgb2hsv(rgb);
% the vector of interest
hsi(1,:,2)
ans =
0.6667 0.7391 0.7000
hsl(1,:,2)
ans =
0.7143 0.7647 0.7647
hsv(1,:,2)
ans =
0.8333 0.8667 0.8667
MATLAB/IPT does not have tools for HSI or HSL conversions. The HSI/HSL conversion tools I used are found here. There are also others on the File Exchange, though be aware that Pascal Getreuer's popular Colorspace Transformations has a bug in the HSI path and will give the incorrect results.
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Import, Export, and Conversion についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!