フィルターのクリア

I want RGB to HSV conversion. What changes are required in the following code?

1 回表示 (過去 30 日間)
SHUBHDEEP KAUR
SHUBHDEEP KAUR 2018 年 9 月 26 日
コメント済み: Walter Roberson 2018 年 9 月 26 日
X = im2double(imread('path'));
R = X(:,:,1);
G= X(:,:,2);
B = X(:,:,3);
z = zeros(size(R));
Rimg = cat(3, R, z, z);
Gimg = cat(3, z, G, z);
Bimg = cat(3, z, z, B);
L256 = linspace(0,1,256).';
z256 = zeros(256,1)
mapR= [L256, z256, z256];
mapG= [z256, L256, z256];
mapB = [z256, z256, L256];
figure; image(Rimg); colormap(mapR); colorbar();
figure; image(Gimg); colormap(mapG); colorbar();
figure; image(Bimg); colormap(mapB); colorbar();
  4 件のコメント
Guillaume
Guillaume 2018 年 9 月 26 日
Indeed it is very unclear what the code given has got to do with conversion to HSV which is trivially achieved with rgb2hsv.
The whole code is simply a very complicated way of achieving the same as:
X = im2double(imread('path'));
figure; imshow(X .* cat(3, 1, 0, 0));
figure; imshow(X .* cat(3, 0, 1, 0));
figure; imshow(X .* cat(3, 0, 0, 1));
Walter Roberson
Walter Roberson 2018 年 9 月 26 日
X .* cat(3, 1, 0, 0) requires R2016b or later.

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

回答 (1 件)

Image Analyst
Image Analyst 2018 年 9 月 26 日
Your code doesn't do anything useful at all. Abandon it all, except the imread() and try this:
hsvImage = rgb2hsv(X);

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by