DISPLAY RED, GREEN & BLUE COMPONENTS OF RGB IMAGE

28 ビュー (過去 30 日間)
LOKESH
LOKESH 2012 年 4 月 15 日
コメント済み: DGM 2022 年 4 月 24 日
Hello, I want to display 3 images of red, blue & green component. I don't want to display the GRAYSCALE images. I tried following code:
X-imread('Hello.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;
but it gives me 3 images with background as Red, green & blue.. How can I display only Red component of RGB image [No Grayscales]
Thanks
  2 件のコメント
Andres Soto
Andres Soto 2022 年 3 月 19 日
Try () instead of [] there [0:1/255:1]
Walter Roberson
Walter Roberson 2022 年 3 月 19 日
A = [0:1/255:1];
B = (0:1/255:1);
isequal(A, B)
ans = logical
1
The line
A = [0:1/255:1];
to MATLAB means the same thing as
temporary = 0:1/255:1;
A = horzcat(temporary);
clear temporary
but horzcat() of a single variable returns the same thing as the input (but after having taken a little bit of time), so the functionality is the same as
A = 0:1/255:1;
but taking slightly more time.
There are differences between using () and [] brackets. For example,
[1 -2]
ans = 1×2
1 -2
(1 -2)
ans = -1
That is, inside [], in some combinations of spacing, the space can indicate end of an expression and beginning of the next element.

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

回答 (5 件)

Walter Roberson
Walter Roberson 2012 年 4 月 15 日
X-imread('Hello.jpg');
R = X
R(:,:,2:3) = 0;
image(R);
pause(5);
G = X;
G(:,:,[1 3]) = 0;
image(G);
pause(5);
B = X;
B(:,:,1:2) = 0;
image(B);
pause(5);
  3 件のコメント
Walter Roberson
Walter Roberson 2018 年 3 月 21 日
kranti kumar kuppili : what would the inputs be?
DGM
DGM 2022 年 4 月 24 日
To answer the "reverse process" question:
% assume that this is the "forward process"
X = imread('peppers.png');
R = X;
R(:,:,2:3) = 0;
G = X;
G(:,:,[1 3]) = 0;
B = X;
B(:,:,1:2) = 0;
montage({R G B},'size',[1 3]);
% now you have three RGB images called R,G, and B
% you could reassemble them directly:
RGB1 = cat(3,R(:,:,1),G(:,:,2),B(:,:,3));

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


Priyanka Johri
Priyanka Johri 2016 年 11 月 2 日
x = imread('Hello.jpg');
figure, imshow(x(:,:,1)); % Red component
figure, imshow(x(:,:,2)); % Green component
figure, imshow(x(:,:,3)); % Blue component
% Is this what you required?
  9 件のコメント
Image Analyst
Image Analyst 2021 年 6 月 27 日
@abdelatti errokhsy, What does "styb by stybe" mean? I have no idea what a styb or stybe is.
Walter Roberson
Walter Roberson 2021 年 6 月 27 日
I have a suspicion that they are asking for a line by line explanation of the code.

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


Image Analyst
Image Analyst 2012 年 4 月 15 日
Not sure what you want. I guess my first answer would be to just not display the green and blue components and that would then "display only Red component." But I don't know what you mean when you say "No Grayscales." The red channel, or any color channel is simply a numerical array, and that is normally displayed as gray scale, though you can apply a pseudocolor look up table (colormap) like you did to make it appear in any tint or even combination of many different colors. But you don't want the red channel to appear red, like you're doing now, and you don't want it to appear in gray scale, so what do you want?
  13 件のコメント
Moe Makki
Moe Makki 2021 年 5 月 22 日
@Image Analyst how do i scan pixels of an image and then remove green and blue components if redValue is above 200

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


Shatha Ali.
Shatha Ali. 2020 年 10 月 17 日
i=imread('6.jpg');
red= i(:,:,1);
green=i(:,:,2);
blue=i(:,:,3);
black=i(:,:,0:0:0);
white=i(:,:,1:1:1);
black=zeros(size(i,1),size(i,2),'unit8');
just_red=cat(3,red,black,black);
just_green=cat(3,black,green,black);
just_blue=cat(3,black,black,blue);
just_black=cat(3,black,black,black);
just_white=cat(3,white,white,white);
picture(3,2,1),imshow(i);
picture(3,2,2),imshow(just_red);
picture(3,2,3),imshow(just_green);
picture(3,2,4),imshow(just_blue);
picture(3,2,5),imshow(just_black);
picture(3,2,6),imshow(just_white);

Dayangku Nur Faizah Pengiran Mohamad
Dayangku Nur Faizah Pengiran Mohamad 2021 年 12 月 5 日
編集済み: Walter Roberson 2021 年 12 月 5 日
B = X(:,:,3);
figure;
image(B), colormap([zeros(256,1), zeros(256,1), [0:1/255:1]']), imwrite(B,colormap,'blueHello.jpg');
Hope this will helps you.

カテゴリ

Help Center および File ExchangeColor and Styling についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by