img = imread('peppers.png');

im_red = img;
im_green = img;
im_blue = img;

% Red channel only
im_red(:,:,2) = 0;
im_red(:,:,3) = 0;
figure, imshow(im_red);

% Green channel only
im_green(:,:,1) = 0;
im_green(:,:,3) = 0;
figure, imshow(im_green);

% Blue channel only
im_blue(:,:,1) = 0;
im_blue(:,:,2) = 0;
figure, imshow(im_blue);