Skip to content

Instantly share code, notes, and snippets.

@ehzawad
Created July 18, 2020 21:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ehzawad/806dfba78465df2c5a92895cc03a5350 to your computer and use it in GitHub Desktop.
Save ehzawad/806dfba78465df2c5a92895cc03a5350 to your computer and use it in GitHub Desktop.
img = imread('amy_adams.jpg'); % Read image
red = img(:,:,1); % Red channel
green = img(:,:,2); % Green channel
blue = img(:,:,3); % Blue channel
a = zeros(size(img, 1), size(img, 2));
just_red = cat(3, red, a, a);
just_green = cat(3, a, green, a);
just_blue = cat(3, a, a, blue);
disp(just_green);
% back_to_original_img = cat(3, red, green, blue);
% figure, imshow(img), title('Original image')
% figure, imshow(just_red), title('Red channel')
% figure, imshow(just_green), title('Green channel')
% figure, imshow(just_blue), title('Blue channel')
% figure, imshow(back_to_original_img), title('Back to original image')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment