User`s guide
Working with Image Data in the MATLAB Workspace
vid = videoinput('mat rox',1);
2 Bring a single frame into the work space —Callthegetsna psho t
function to bring a frame into the workspace.
frame = getsnapshot(v id);
3 View the class of the returned data —Usetheclass function to
determine the data type used for the returned image data.
class(frame)
ans =
uint8
4 Clean up — Always rem ove image acquisition objects from mem ory, and
the variables that re ference them, when you n o longer need them.
delete(vid)
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 o f red, green,
and blue. Another color space, wide ly us ed for digital video, is the YCbCr color
space. In this color space, luminance (brightness or intensity) information
is stored as a single component (Y ). Ch rominance (color) information is
stored as tw o color-difference compone nts (Cb and Cr). Cb represents the
difference be tw ee n 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 t he color represen t ati on of the image data, set t he value of the
ReturnedColorSpace property. To display image frames using the image
or imag esc functions, the data must use the R GB color space. Another
6-17