Skip to Main Content Skip to Search
Home |   Select Country  Choose Country  |  Contact Us  |  Cart Store 
Create Account | Log In
Products & Services Industries Academia Support User Community Company

 

Image Acquisition Toolbox™ 3.1

Product Description

Image Acquisition Example

This example illustrates how you can perform complex image acquisition operations using only a few lines of MATLAB code. We first acquire a single video frame from a scientific video camera. Next, using standard MATLAB functions, we perform an edge enhancement on the acquired video frame and visualize the result as a three-dimensional surface plot.

A typical image acquisition session consists of the following four steps:

  1. Creation—creating a video input object
  2. Configuration—controlling acquisition behavior by setting object properties and previewing the results
  3. Acquisition—starting the video input object and acquiring and processing data
  4. Clean-up—deleting the video input object

The following sample script maps to these steps.

Step 1: Creation

First, we create a video input object named vid using the videoinput function. We associate the video input object with a particular hardware device by passing the device's identification number to the function. For our example, the scientific video camera’s device identification number is 1. For information on how to scan for devices and determine their identification number, see the tutorial, Accessing Devices and Video Sources.

vid = videoinput(‘winvideo’, 1);

Step 2: Configuration

Next, we open a preview window and adjust the camera’s brightness setting. To obtain a listing of all the configurable properties of a video object, see the tutorial, Working with Properties.

preview(vid);
set(vid.source,’Brightness’,100);

The scene is previewed to verify that the acquisition settings are correct.

Step 3: Acquisition

We use the getsnapshot command to acquire a single video frame from the camera. For information on how to perform a multiframe acquisition, see the tutorial, Logging Data to Memory.

data = getsnapshot(vid);

Now, we extract the red color band from the acquired frame and apply a Sobel edge enhancement filter. The toolbox acquires video frames in RGB format by default, and represents RGB data as a three-dimensional array consisting of height x width x color band. For more information on advanced image processing functions, refer to Image Processing Toolbox Web pages.

red = data(:, : ,1);
filtered = filter2(fspecial('sobel'), red);

Here, we visualize the filtered data as a three-dimensional surface and apply various formatting. For more information on advanced visualization methods, see the documentation on the MATLAB Web pages.

surf(filtered);
shading(‘interp’);colormap(‘hot’);colorbar;

The acquired image is processed using a Sobel edge enhancement filter and visualized as a 3-D surface plot.

Step 4: Clean up

We delete and clear the video input object from the MATLAB workspace to free up memory.

delete(vid);
clear vid;

This concludes the sample. For more samples, please visit:

Contact sales
Free technical kit
Trial software
E-mail this page

Get Pricing and
Licensing Options

Recorded Webinar

Image Processing Using MATLAB

Free Seminar

Video Surveillance System Design with Simulink® and Xilinx® FPGAs new