Read an RGB image into the workspace and display the image.
I = imread('peppers.png');
imshow(I)
Split the image into its component red, green, and blue channels.
[r,g,b] = imsplit(I);
Display the three color channels as a montage. Red peppers have a signal predominantly in the red channel. Yellow and green peppers have a signal in both the red and green channels. White objects, such as the garlic in the foreground, have a strong signal in all three channels.
montage({r,g,b},'Size',[1 3])
Split Image in HSV Colorspace into Its Component Channels
c1,c2,c3,...,ck — Output images numeric matrix for each channel
Output images, returned as k individual numeric matrices, where
k is the number of channels in the input image. The output images
are the same class as the input image.
Extended Capabilities
C/C++ Code Generation Generate C and C++ code using MATLAB® Coder™.
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.