I want code to convert color image to rgb color spaces exactly

2 次查看(过去 30 天)
I want code to convert color image to rgb color spaces exactly
  2 个评论
Walter Roberson
Walter Roberson 2015-9-2
编辑:Walter Roberson 2015-9-2
In a duplicate Question, the user posted
X=imread('images.jpg'); R = X(:,:,1); image(R), colormap([[0:1/255:1]', zeros(256,1), zeros(256,1)]), colorbar;
%Green Component G = X(:,:,2); figure; image(G), colormap([zeros(256,1),[0:1/255:1]', zeros(256,1)]), colorbar;
%Blue component B = X(:,:,3); figure; image(B), colormap([zeros(256,1), zeros(256,1), [0:1/255:1]']), colorbar;

请先登录,再进行评论。

采纳的回答

Walter Roberson
Walter Roberson 2015-9-2
X = im2double(imread('images.jpg'));
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();
  2 个评论
venmal devi
venmal devi 2015-9-2
its displaying R ,G and B color ..but behind every image it showing black gray image why ?
Walter Roberson
Walter Roberson 2015-9-2
I do not know what you mean by a "black gray image" ? Please capture a portion of the screen and post the image.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Colormaps 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by