How to get coloured layer from an rgb image in matlab.

7 ビュー (過去 30 日間)
sadiqa ilyas
sadiqa ilyas 2019 年 8 月 2 日
コメント済み: Walter Roberson 2019 年 8 月 2 日
Hi. I want to extract all three layers from rgb colour image.For red layer i want it is red colour and similarly for green layer i need the image in green shade. simple code is attached but it increase the size of the image which i dont want. If an input image is of small size I need the output of the same size.
I1=imread('Hello.png')
I1 = I1(:,:,2);
R=image(I1), colormap([zeros(256,1),[0:1/255:1]', zeros(256,1)]);
figure;
imshow(R,[])

採用された回答

Walter Roberson
Walter Roberson 2019 年 8 月 2 日
I1 = imread('Hello.png');
R = 0 * I1; R(:,:,1) = I1(:,:,1);
G = 0 * I1; G(:,:,2) = I1(:,:,2);
B = 0 * I1; B(:,:,3) = I1(:,:,3);
subplot(1,3,1)
image(R)
subplot(1,3,2)
image(G)
subplot(1,3,3)
image(B)
  7 件のコメント
sadiqa ilyas
sadiqa ilyas 2019 年 8 月 2 日
EncImg is only an enciphered image of green layer, so it is 1 dim
Walter Roberson
Walter Roberson 2019 年 8 月 2 日
Then reshape it to 2d and store it as (:, :, 2) of a 3d matrix of zeros like I showed.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeConvert Image Type についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by