MATLAB: What does this do r = img1(:,:,1); % red channel g = img1(:,:,2); % green b = img1(:,:,3);

digital image processingimageimage acquisitionimage analysisimage processingimage reconstructionimage segmentationimagesimagesc

r = img1(:,:,1);
g = img1(:,:,2);
b = img1(:,:,3);

Best Answer

That is taking an RGB image, img1, and extracting the red, green, and blue parts and creating 3 2-D matrices: r,g, and b.
An RGB image, sometimes referred to as a truecolor image, is stored in MATLAB as an M-by-N-by-3 data array that defines red, green, and blue color components for each individual pixel. RGB images do not use a palette. The color of each pixel is determined by the combination of the red, green, and blue intensities stored in each color plane at the pixel's location.
Related Question