8 bit depth RGB image(gif)

2 次查看(过去 30 天)
is it possible to separate red ,green and blue channel of a 8 bit depth gif image with the following code?
redimg=im;
blueimg=im;
redimg(:,:,2:3)=0;
blueimg(:,:,1:2)=0;
greenimg=im;
greenimg(:,:,3)=0;
greenimg(:,:,1)=0;
if not then how can that be achieved?

采纳的回答

Image Analyst
Image Analyst 2012-3-11
Copy and paste this example code:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables.
workspace; % Make sure the workspace panel is showing.
fontSize = 20;
% Change the filename to your filename!
[gifImage cmap] = imread('C:\Users\yourname\Pictures\whatever.gif');
% Display indexed GIF image.
subplot(2,3, 1);
imshow(gifImage);
% Convert to true color RGB image.
rgbImage = ind2rgb(gifImage, cmap);
title('GIF Image', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
subplot(2,3, 2);
imshow(rgbImage);
title('After conversion to RGB', 'FontSize', fontSize);
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
% Display the three component color channels.
subplot(2,3, 4);
imshow(redChannel);
title('Red Channel', 'FontSize', fontSize);
subplot(2,3, 5);
imshow(greenChannel);
title('Green Channel', 'FontSize', fontSize);
subplot(2,3, 6);
imshow(blueChannel);
title('Blue Channel', 'FontSize', fontSize);

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by