MATLAB: How to separate an image to rgb

colorImage Processing Toolboxrgb separation

how to divide an image into its r,g,and b colour planes,

Best Answer

No reshaping is needed. Simply extract the color channels you need:
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
Then, to reverse the process and create an RGB image from three separate color channels:
% Recombine separate color channels into a single, true color RGB image.
rgbImage = cat(3, redChannel, greenChannel, blueChannel);