User`s guide
7 Working with Acquired Image Data
7-20
ans =
480 640
Notice how the size changed from the rgb image to the grayscale image by
comparing the size output in steps 4 and 5.
6
You can optionally use the demosaic function in the Image Processing Toolbox to
convert Bayer patterns into color images.
% Create an image colorImage by using the demosaic function on the
% image img and convert it to color.
colorImage = demosaic(img, 'gbrg');
% Now check the size of the new color image.
size(colorImage)
ans =
480 640 3
7
Always remove image acquisition objects from memory, and the variables that
reference them, when you no longer need them.
delete(vid)
clear vid
Automatic Conversion
The camera in this example returns data that is a Bayer mosaic, but the toolbox doesn't
know it since the DCAM standard doesn't have any way for the camera to communicate
that to software applications. You need to know that by reading the camera specifications
or manual. The toolbox can automatically convert the Bayer encoded data to RGB data,
but it must be programmed to do so.
1
Create a video object vid using the DCAM adaptor and the designated video format
for raw data.
vid = videoinput('dcam', 1, 'F7_RAW8_640x480');
2
View the default color space used for the data.
vid.ReturnedColorSpace
ans =