User`s guide

7 Working with Acquired Image Data
7-16
clear vid
Specifying the Color Space
For most image acquisition devices, the video format of the video stream determines the
color space of the acquired image data, that is, the way color information is represented
numerically.
For example, many devices represent colors as RGB values. In this color space, colors
are represented as a combination of various intensities of red, green, and blue. Another
color space, widely used for digital video, is the YCbCr color space. In this color space,
luminance (brightness or intensity) information is stored as a single component (Y).
Chrominance (color) information is stored as two color-difference components (Cb and
Cr). Cb represents the difference between the blue component and a reference value. Cr
represents the difference between the red component and a reference value.
The toolbox can return image data in grayscale, RGB, and YCbCr. To specify the color
representation of the image data, set the value of the ReturnedColorSpace property.
To display image frames using the image, imagesc, or imshow functions, the data must
use the RGB color space. Another MathWorks product, the Image Processing Toolbox
software, includes functions that convert YCbCr data to RGB data, and vice versa.
Note Some devices that claim to support the YUV color space actually support the YCbCr
color space. YUV is similar to YCbCr but not identical. The difference between YUV and
YCbCr is the scaling factor applied to the result. YUV refers to a particular scaling factor
used in composite NTSC and PAL formats. In most cases, you can specify the YCbCr
color space for devices that support YUV.
You can determine your device’s default color space using this code:
vid.ReturnedColorSpace, where vid is the name of the video object. An example of
this is shown in step 2 in the example below. There may be situations when you wish to
change the color space. The example below shows a case where the default color space is
rgb, and you change it to grayscale (step 3).
The following example illustrates how to specify the color space of the returned image
data.
1
Create an image acquisition object — This example creates a video input object
for a generic Windows image acquisition device. To run this example on your system,