RGB images are 3-D(i.e 3 , 2-D array for R,G,B ), can we extract these array seperatly?

6 ビュー (過去 30 日間)
priyanka
priyanka 2014 年 3 月 29 日
コメント済み: Jeykishan 2022 年 10 月 16 日
I want to convert the 3-D image array into 1-D array, so if i got R,G & B array seperatly then these can be converted into 2-D array easily.. so how to get these 3 (R,G,B) array??

採用された回答

Wayne King
Wayne King 2014 年 3 月 29 日
編集済み: Wayne King 2014 年 3 月 29 日
You just select each "page" of the matrix.
im = imread('ngc6543a.jpg');
Rim = im(:,:,1);
Gim = im(:,:,2);
Bim = im(:,:,3);
  4 件のコメント
priyanka
priyanka 2014 年 3 月 29 日
Thank you,, its working .:)
MAHMOOD QADIR
MAHMOOD QADIR 2021 年 3 月 27 日
Thank you very much

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

その他の回答 (2 件)

Image Analyst
Image Analyst 2014 年 3 月 29 日
Extract each color channel
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
as shown in my attached demo that takes RGB histograms of every image in your folder.
Screenshot:
  7 件のコメント
Image Analyst
Image Analyst 2016 年 10 月 13 日
That doesn't look right. If the image is 980 by 1280 by 4 color channels, and you've read in all the data, then your reshape would not work since your new desired size does not contain all the pixels. I suggest you start your own discussion thread (rather than keep bugging priyanka), and read this and attach your actual image.
Jeykishan
Jeykishan 2022 年 10 月 16 日
Thank you for the code. Very informative and usefl for me.

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


priyanka
priyanka 2014 年 3 月 29 日
When i am using imtool() function and checking the pixel information,pixel value is not matched with the pixel value which is obtained by redChannel = rgbImage(:, :, 1); greenChannel = rgbImage(:, :, 2); blueChannel = rgbImage(:, :, 3);
  1 件のコメント
Image Analyst
Image Analyst 2021 年 3 月 27 日
Attach your image. There's a good possibility you're cheking the value using the x,y from the cursor in imtool as redChannel(x,y), which would be incorrect. Remember y is row, not x, so it needs to be redChannel(y, x), NOT redChannel(x, y);

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

カテゴリ

Help Center および File ExchangeImage Processing and Computer Vision についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by