User`s guide
Working with Image Data in MATLAB Workspace
7-17
use the imaqhwinfo function to get the object constructor for your image acquisition
device and substitute that syntax for the following code.
vid = videoinput('winvideo',1);
2
View the default color space used for the data — The value of the
ReturnedColorSpace property indicates the color space of the image data.
vid.ReturnedColorSpace
ans =
rgb
3
Modify the color space used for the data — To change the color space of the
returned image data, set the value of the ReturnedColorSpace property.
vid.ReturnedColorSpace = 'grayscale'
ans =
grayscale
4
Clean up — Always remove image acquisition objects from memory, and the
variables that reference them, when you no longer need them.
delete(vid)
clear vid
Converting Bayer Images
You can use the ReturnedColorSpace and BayerSensorAlignment properties to
control Bayer demosaicing.
If your camera uses Bayer filtering, the toolbox supports the Bayer pattern and can
return color if desired. By setting the ReturnedColorSpace property to 'bayer',
the Image Acquisition Toolbox software will demosaic Bayer patterns returned by the
hardware. This color space setting will interpolate Bayer pattern encoded images into
standard RGB images.
In order to perform the demosaicing, the toolbox needs to know the pixel alignment of the
sensor. This is the order of the red, green, and blue sensors and is normally specified by
describing the four pixels in the upper-left corner of the sensor. It is the band sensitivity
alignment of the pixels as interpreted by the camera's internal hardware. You must get
this information from the camera's documentation and then specify the value for the
alignment.