RGB images are 3-D(i.e 3 , 2-D array for R,G,B ), can we extract these array seperatly?
조회 수: 3 (최근 30일)
이전 댓글 표시
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??
댓글 수: 0
채택된 답변
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
추가 답변 (2개)
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/174682/image.jpeg)
댓글 수: 7
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.
priyanka
2014년 3월 29일
댓글 수: 1
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 Exchange에서 Image Processing and Computer Vision에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!