-
-
Save Graciaira/ed61b458660eac0deca7536d9cf98a70 to your computer and use it in GitHub Desktop.
Get 3 color channels, RGB, of image, and stack it together to get color image.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clear all; | |
%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-1]); | |
G=imcrop(img,[1,1*rr+1,c,rr-1]); | |
R=imcrop(img,[1,2*rr+1,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) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment