Color Imaging - RGB Channels
조회 수: 7 (최근 30일)
이전 댓글 표시
Divide the given image in 3 parts(RGB) and stack them together to get a color image
please help me what to edit in code...
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/310247/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/310250/image.jpeg)
%Read the image
img = imread('image.jpg');
%Get the size (rows and columns) of the image
[r,c] = size(img);
rr=r/3;
%Wrire code to split the image into three equal parts and store them in B, G, R channels
B=imcrop(img,[1,1,c,rr]);
G=imcrop(img,[1,1*rr,c,rr]);
R=imcrop(img,[1,2*rr,c,rr]);
%concatenate R,G,B channels and assign the RGB image to ColorImg variable
ColorImg(:,:,1) = R;
ColorImg(:,:,2) = G;
ColorImg(:,:,3) = B;
imshow(ColorImg)
댓글 수: 3
Image Analyst
2020년 8월 9일
편집: Image Analyst
2021년 4월 1일
Same homework problem as this other post
and this one where I put the solution:
답변 (2개)
shyam chauhan
2020년 7월 18일
This code is absolutely fine for the task already, if you have the "image processing toolbox" installed in your account. Imcrop is the advanced feature that of matlab that needs to be bought to use it.
If you have not installed that toolbox, change your program to split the image into three equal parts replacing the command for B, G, R.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!