Count Objects in an Image - MATLAB & Simulink.pdf - Google Drive

2 downloads 111 Views 547KB Size Report
Count Objects in an Image - MATLAB & Simulink.pdf. Count Objects in an Image - MATLAB & Simulink.pdf. Open. Extr
Count Objects in an Image In this example, you import an intensity image of a wheel from the MATLAB® workspace and convert it to binary. Then, using the Opening and Label blocks, you count the number of spokes in the wheel. You can use similar techniques to count objects in other intensity images. However, you might need to use additional morphological operators and different structuring elements. Note:   Running this example requires a DSP System Toolbox™ license.

You can open the example model by typing ex_vision_count_objects on the MATLAB command line. 1.  Create a new Simulink® model, and add to it the blocks shown in the following table. Block

Library

Quantity

Image From File

Computer Vision System Toolbox™ > Sources

1

Opening

Computer Vision System Toolbox> Morphological Operations

1

Label

Computer Vision System Toolbox > Morphological Operations

1

Video Viewer

Computer Vision System Toolbox > Sinks

2

Constant

Simulink > Sources

1

Relational Operator

Simulink > Logic and Bit Operations

1

Display

Simulink > Sinks

1

2.  Use the Image From File block to import your image. Set the File name parameter to testpat1.png. This is a 256­by­ 256 matrix image of 8­bit unsigned integers. 3.  Use the Constant block to define a threshold value for the Relational Operator block. Set the Constant value parameter to 200. 4.  Use the Video Viewer block to view the original image. Accept the default parameters. 5.  Use the Relational Operator block to perform a thresholding operation that converts your intensity image to a binary image. Set the Relational Operator parameter to