9
2009/8/5 1 Copyright © 2007 by TeraSoft, Inc. Image Acquisition and Analysis in MATLAB Presenter: Claire Chuang TeraSoft Inc. Copyright © 2007 by TeraSoft, Inc. Using MATLAB for Image Processing Data access Image analysis Idea sharing and reporting Application deployment Visualization Algorithm development Image acquisition Image pre-processing

Image Acquisition and AnalysisinMATLAB - TeraSoft...Image Processing Toolbox Perform image processing, analysis, visualization, and algorithm development • Graphical tools • Image

  • Upload
    others

  • View
    42

  • Download
    0

Embed Size (px)

Citation preview

2009/8/5

1

Copyright © 2007 by TeraSoft, Inc.

Image Acquisition and Analysis in MATLAB

Presenter: Claire Chuang

TeraSoft Inc.

Copyright © 2007 by TeraSoft, Inc.

Using MATLAB for Image Processing

Data access

Image analysis

Idea sharing and reporting

Application deployment

VisualizationAlgorithm

development

Image acquisition

Image pre-processing

2009/8/5

2

Copyright © 2007 by TeraSoft, Inc.

Outline

▪ Hardware Connections

▪ Examining Hardware Resources

▪ Create a Video Input Object

▪ Configuring Properties

▪ Preview the Video Stream

▪ Acquiring Image Data

▪ Deleting and Clearing Toolbox Objects

Copyright © 2007 by TeraSoft, Inc.

Image Acquisition ApplicationThis section shows you an example of:

1. Accessing the webcam’s video input.

2. Acquiring an image and store as a

MATLAB variable.

3. Bring the acquired image into MATLAB,

process, and visualize.

Original Image

2009/8/5

3

Copyright © 2007 by TeraSoft, Inc.

Hardware Connections▪ Connect the image acquisition device to your PC (In our

case, a USB port connected webcam).

▪ Check the hardware with the application software

provided by the manufacturer.

USB Port

Webcam

http://www.mathworks.com/products/imaq/supportedio.html

Copyright © 2007 by TeraSoft, Inc.

Examining Hardware Resources

▪ You should examine the image acquisition hardware resources visible to the toolbox with the imaqhwinfo function.

• General toolbox information

• Adaptor-specific information

>> a = imaqhwinfo;

>> a.InstalledAdaptors

ans =

'coreco' 'winvideo'

>> b = imaqhwinfo('winvideo');

2009/8/5

4

Copyright © 2007 by TeraSoft, Inc.

Creating a Video Input Object – Basics

▪ Create a video input object with the videoinput

constructor.

where:

• vid is called a video input object.

• winvideo is the adaptor name for image acquisition

hardware.

• 1 is the device ID (given by imaqhwinfo)

▪ vid is a custom MATLAB class.

>> vid = videoinput('winvideo',1);

>> whos vid

Copyright © 2007 by TeraSoft, Inc.

Configuring Properties – Basics

▪ Use the set function to display all configurable

device object properties.

▪ Use the get function to return the current device

object property values.

▪ Use the image acquisition property editor to view and edit the device object's properties.

>> set(vid)

>> get(vid)

>> inspect(vid)

2009/8/5

5

Copyright © 2007 by TeraSoft, Inc.

Configuring Properties – Summary ▪ The Image Acquisition Toolbox provides the

following functions to return property information.

set

Function Property information provided

imaqhwinfo

get

Hardware-related property values- Maximum height and width- Vendor driver version

All properties and their current values

propinfo

Runtime property characteristicsProperty value data typeDefault property valuesConstraints (min and max values)

All configurable propertiesPossible value strings, with the default contained by braces

inspect Image acquisition object property editor

Copyright © 2007 by TeraSoft, Inc.

Preview Video StreamThe data extraction process is shown below.

>> data = peekdata(vid,5);

>> montage(data);

Log data to engine

Preview 5 most recent frames

4-D data array

Logged data

Engine

Note peekdata is an non-blocking function

that immediately returns data and execution

control to MATLAB.

>> preview(vid)

2009/8/5

6

Copyright © 2007 by TeraSoft, Inc.

Acquiring Image Data - Extracting (Continued)

The data extraction process is shown below.

>> [data,time] = getdata(ai);

t1

t2

t3.

.

.tm

m-by-1 time array

Note getdata blocks the command

line until the requested number of

samples is returned or a timeout

occurs.

Extract data from engine

Log data to engineEngine

Remaining

dataExtracted

data

4-D data array

Copyright © 2007 by TeraSoft, Inc.

Acquiring Image Data – Extracting (Continued)

▪ Extract the specified number of frames.

▪ Extract all the data associated with one trigger.

▪ Extract all the data available in the engine.

>> data = getdata(vid,5);

>> data = getdata(vid);>> data = getdata(vid,get(vid,'FramesPerTrigger'));

>> data = getdata(ai,get(vid,'FramesAvailable'));

Use the getdata function to extract acquired data

from the engine.

2009/8/5

7

Copyright © 2007 by TeraSoft, Inc.

Deleting and Clearing Toolbox Objects

▪ Remove variables from the MATLAB workspace.

▪ To quickly delete all device objects and reset the hardware to its initial state

>> delete(vid)>> clear vid

>> imaqreset

Copyright © 2007 by TeraSoft, Inc.

The Video Input Session>> vid = videoinput('winvideo',1);

>> set(vid,'ReturnedColorSpace','rgb');

>> triggerconfig(vid,'immediate');

>> set(vid,'FramesPerTrigger',10);

>> preview(vid);

>> start(vid);

>> data = getdata(vid);

>> imshow(data(:,:,:,end));

>> stop(vid);

>> delete(vid)

>> clear vid

Create object

Acquire data

Configure properties

(optional)

Delete / Clean-up

Preview video input

(optional)

2009/8/5

8

Copyright © 2007 by TeraSoft, Inc.

Image Processing Toolbox

Perform image processing, analysis, visualization, and algorithm development

• Graphical tools

• Image pre- and postprocessing

• Image analysis

• Spatial transformations

• Image registration

• Color image processing

Copyright © 2007 by TeraSoft, Inc.

Image Pre- and Postprocessing

▪ Contrast enhancement

▪ Noise removal

▪ Deblurring

▪ Region-based processing

▪ Linear and nonlinear filtering

Original image courtesy of MIT. Thisversion created by simulating motion blur.

Deblurred image using Wienerfilter deconvolution.

Original Landsat image courtesy of Space Imaging, LLC.

2009/8/5

9

Copyright © 2007 by TeraSoft, Inc.

Image Analysis

▪ Edge detection

▪ Segmentation

▪ Morphological operators

▪ Image statistics

▪ Boundary tracing

▪ Region properties

▪ Texture analysis

▪ Hough transform

Copyright © 2007 by TeraSoft, Inc.

Q & AThanks!!