splitcv
Splits an image into RGB/RGBA channels.
Syntax
[r, g, b] = splitcv(cvhandle)
[r, g, b, a] = splitcv(cvhandle)
Inputs
- cvhandle
- Handle of a color image.
Outputs
- r
- Handle of the single channel image representing the red channel data.
- g
- Handle of the single channel image representing the green channel data.
- b
- Handle of the single channel image representing the blue channel data.
- a
- Handle of the single channel image representing the alpha channel data, if applicable.
Example
Split an image into RGB channels and create one image with each of these channels:
Figure 1. Input image
![](images/splitcv_fig3.png)
Figure 2. Blue channel
![](images/splitcv_fig4.png)
Figure 3. Red channel
![](images/splitcv_fig5.png)
Figure 4. Green channel
![](images/splitcv_fig6.png)
%Read image
img = imreadcv('RGBchannels.jpg',1);
figure(1);
imshowcv(img);
[blue, green, red] = splitcv(img);
figure(2);
imshowcv(blue);
figure(3);
imshowcv(red);
figure(4);
imshowcv(green);
![](images/splitcv_fig3.png)
![](images/splitcv_fig4.png)
![](images/splitcv_fig5.png)
![](images/splitcv_fig6.png)
Split an image into RGB channels and display only the red one:
Figure 5. Input image 1
![](images/splitcv_fig1.png)
Figure 6. Input image 1 modified
![](images/splitcv_fig2.png)
cvhandle = imreadcv('bird2.jpg');
[r, g, b] = splitcv(cvhandle);
imshowcv(r);
![](images/splitcv_fig1.png)
![](images/splitcv_fig2.png)