User`s guide
Working with Image Data in MATLAB Workspace
7-15
7
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
Determining the Data Type of Image Frames
By default, the toolbox returns image frames in the data type used by the image
acquisition device. If there is no MATLAB data type that matches the object's native
data type, getdata chooses a MATLAB data type that preserves numerical accuracy.
For example, in RGB 555 format, each color component is expressed in 5-bits. getdata
returns each color as a uint8 value.
You can specify the data type you want getdata to use for the returned data. For
example, you can specify that getdata return image frames as an array of class double.
To see a list of all the data types supported, see the getdata reference page.
The following example illustrates the data type of returned image data.
1
Create an image acquisition object — This example creates a video input object
for a Matrox image acquisition device. To run this example on your system, use the
imaqhwinfo function to get the object constructor for your image acquisition device
and substitute that syntax for the following code.
vid = videoinput('matrox',1);
2
Bring a single frame into the workspace — Call the getsnapshot function to
bring a frame into the workspace.
frame = getsnapshot(vid);
3
View the class of the returned data — Use the class function to determine the
data type used for the returned image data.
class(frame)
ans =
uint8
4
Clean up — Always remove image acquisition objects from memory, and the
variables that reference them, when you no longer need them.
delete(vid)