Intelligent Vision Systems [ENT 496] Laboratory

advertisement
Intelligent Vision Systems [ENT 496]
Laboratory Module 4
INTELLIGENT VISION SYSTEMS
ENT 496
LABORATORY MODULE
EXPERIMENT 4
Submitted by:
Name: _____________________________
Matrix No.: _________________________
Group No. __________________________
Project Title: ______________________________________________________
______________________________________________________
Date: _____________
School of Mechatronic Engineering
Northern Malaysia University College of Engineering
-1-
Intelligent Vision Systems [ENT 496]
Laboratory Module 4
EXPERIMENT 4
FEATURE EXTRACTIONN
1. OBJECTIVE:
To develop algorithms for extraction of features from edge images using various feature
extraction methods.
2. COMPONENTS, EQUIPMENTS & SOFTWARE:
Objects
Vision Sensors
MATLAB software
3. INTRODUCTION:
Connected-Component Labeling:
The bwlabel and the bwlabeln functions perform connected-component labeling, which is
a method for identifying each object in a binary image. The bwlabel function supports 2D inputs only; the bwlabeln function supports inputs of any dimension. These functions
return a matrix, called a label matrix. A label matrix is an image, the same size as the
input image, in which the objects in the input image are distinguished by different integer
values in the output matrix. For example, bwlabel can identify the objects in this binary
image. In the output matrix, the 1's represent one object, the 2's a second object, and
the 3's a third. (If you had used 8-connected neighborhoods (the default), there would be
only two objects, because the first and second objects would be a single object,
connected along the diagonal.) Viewing a Label MatrixThe label matrix returned by
bwlabel or bwlabeln is of class double; it is not a binary image. One way to view it is to
display it as a pseudocolor indexed image, using label2rgb. In the pseudocolor image,
each number that identifies an object in the label matrix is used as an index value into
the associated colormap matrix. When you view a label matrix as an RGB image, the
objects in the image are easier to distinguish.
BW2 = bwselect(BW,c,r,n) returns a binary image containing the objects that overlap the
pixel (r,c). r and c can be scalars or equal-length vectors. If r and c are vectors, BW2
contains the sets of objects overlapping with any of the pixels (r(k),c(k)). n can have a
value of either 4 or 8 (the default), where 4 specifies 4-connected objects and 8 specifies
8-connected objects. Objects are connected sets of on pixels (i.e., pixels having a value
of 1). BW2 = bwselect(BW,n) displays the image BW on the screen and lets you select
the (r,c) coordinates using the mouse. If you omit BW, bwselect operates on the image
in the current axes. Use normal button clicks to add points. Pressing Backspace or
Delete removes the previously selected point. A shift-click, right-click, or double-click
selects the final point; pressing Return finishes the selection without adding a point.
[BW2,idx] = bwselect(...) returns the linear indices of the pixels belonging to the selected
-2-
Intelligent Vision Systems [ENT 496]
Laboratory Module 4
objects. BW2 = bwselect(x,y,BW,xi,yi,n) uses the vectors x and y to establish a
nondefault spatial coordinate system for BW1. xi and yi are scalars or equal-length
vectors that specify locations in this coordinate system. [x,y,BW2,idx,xi,yi] = bwselect(...)
returns the XData and YData in x and y, the output image in BW2, linear indices of all
the pixels belonging to the selected objects in idx, and the specified spatial coordinates
in xi and yi. If bwselect is called with no output arguments, the resulting image is
displayed in a new figure. Class SupportThe input image BW can be logical or numeric
and must be 2-D and nonsparse. The output image BW2 is of class logical.
Euler Number:
Finding the Euler Number of a Binary ImageThe bweuler function returns the Euler
number for a binary image. The Euler number is a measure of the topology of an image.
It is defined as the total number of objects in the image minus the number of holes in
those objects. You can use either 4- or 8-connected neighborhoods.
Area:
Finding the Area of the Foreground of a Binary Image The bwarea function returns the
area of a binary image. The area is a measure of the size of the foreground of the
image. Roughly speaking, the area is the number of on pixels in the image. bwarea does
not simply count the number of pixels set to on, however. Rather, bwarea weights
different pixel patterns unequally when computing the area. This weighting compensates
for the distortion that is inherent in representing a continuous image with discrete pixels.
For example, a diagonal line of 50 pixels is longer than a horizontal line of 50 pixels. As
a result of the weighting bwarea uses, the horizontal line has area of 50, but the diagonal
line has area of 62.5.
Singular value decomposition:
The svd command computes the matrix singular value decomposition. s = svd(X) returns
a vector of singular values. [U,S,V] = svd(X) produces a diagonal matrix S of the same
dimension as X, with nonnegative diagonal elements in decreasing order, and unitary
matrices U and V so that X = U*S*V'. [U,S,V] = svd(X,0) produces the "economy size"
decomposition. If X is m-by-n with m > n, then svd computes only the first n columns of
U and S is n-by-n
Eigenvalues:
eig(A) returns a vector of the eigenvalues of matrix A. d = eig(A,B) returns a vector
containing the generalized eigenvalues, if A and B are square matrices. Note
If S is
sparse and symmetric, you can use d = eig(S) to returns the eigenvalues of S. To
request eigenvectors, and in all other cases, use eigs to find the eigenvalues or
eigenvectors of sparse matrices. [V,D] = eig(A) produces matrices of eigenvalues (D)
and eigenvectors (V) of matrix A, so that A*V = V*D. Matrix D is the canonical form of A-a diagonal matrix with A's eigenvalues on the main diagonal. Matrix V is the modal
matrix--its columns are the eigenvectors of A. If W is a matrix such that W'*A = D*W', the
columns of W are the left eigenvectors of A . Use [W,D] = eig(A.'); W = conj(W) to
compute the left eigenvectors. [V,D] = eig(A,'nobalance') finds eigenvalues and
eigenvectors without a preliminary balancing step. Ordinarily, balancing improves the
-3-
Intelligent Vision Systems [ENT 496]
Laboratory Module 4
conditioning of the input matrix, enabling more accurate computation of the eigenvectors
and eigenvalues. However, if a matrix contains small elements that are really due to
round off error, balancing may scale them up to make them as significant as the other
elements of the original matrix, leading to incorrect eigenvectors. Use the no balance
option in this event. See the balance function for more details. [V,D] = eig(A,B) produces
a diagonal matrix D of generalized eigenvalues and a full matrix V whose columns are
the corresponding eigenvectors so that A*V = B*V*D. [V,D] = eig(A,B,flag) specifies the
algorithm used to compute eigenvalues and eigenvectors. flag can be: 'chol'Computes
the generalized eigenvalues of A and B using the Cholesky factorization of B.
Discrete Fourier transform:
Y = fft(X) returns the discrete Fourier transform (DFT) of vector X, computed with a fast
Fourier transform (FFT) algorithm. If X is a matrix, fft returns the Fourier transform of
each column of the matrix. If X is a multidimensional array, fft operates on the first
nonsingleton dimension. Y = fft(X,n) returns the n-point DFT. If the length of X is less
than n, X is padded with trailing zeros to length n. If the length of X is greater than n, the
sequence X is truncated. When X is a matrix, the length of the columns is adjusted in the
same manner. Y = fft(X,[],dim) and Y = fft(X,n,dim) applies the FFT operation across the
dimension dim.
4. PROCEDURE
a) Read an image obtained during experiment no. 2
b) Display image
c) Resize image to a suitable size and display resized image.
d) Convert the acquired images to binary images
e) Convert the binary image obtained to an edge image first by using a canny
operator.
f)
Extract features of the object edge image using any four feature extraction
methods detailed above. Record your observations and choose the best feature
extraction method.
g) Write an algorithm to extract features from a given object image.
h) Write a mat lab program extract features from a given object image
Note: At all stages the images acquired should recorded with proper
descriptions and observations of the images
-4-
Intelligent Vision Systems [ENT 496]
Laboratory Module 4
Name: ____________________________ Matrix No.:_____________ Date: _________
5. EXPERIMENTAL RESULTS
(a) Object Images
Display the images read in the space provided [images maybe be resized to fit
boxes provided]
Object Name:
_______________________________
_______________________________
_______________________________
(b) Resized Images
Object Name:
_______________________________
_______________________________
_______________________________
(c ) Binary Images
Object Name:
Threshold: T =
_______________________________
_______________________________
_______________________________
Instructor Approval: …………………………………. Date: ……………………
-5-
Intelligent Vision Systems [ENT 496]
Laboratory Module 4
Name:____________________________ Matrix No.:_____________ Date:_________
(d ) Edge Images
Object Name:
Canny Edge:
_______________________________
_______________________________
_______________________________
(e) Feature Extraction
Display extracted feature data
Method :____________
Method :____________
Instructor Approval: …………………………………. Date: ……………………
-6-
Intelligent Vision Systems [ENT 496]
Laboratory Module 4
Name: ____________________________ Matrix No.:_____________ Date:_________
Method :____________
Method :____________
Instructor Approval: …………………………………………. Date: ………………
-7-
Intelligent Vision Systems [ENT 496]
Laboratory Module 4
Name:____________________________ Matrix No.:_____________ Date:_________
f) Algorithm to extract features from an object image
Instructor Approval: …………………………………………. Date: ………………
-8-
Intelligent Vision Systems [ENT 496]
Laboratory Module 4
Name:____________________________ Matrix No.:_____________ Date:_________
g) Mat lab program to extract features from an object image.
Instructor Approval: …………………………………………. Date: ………………
-9-
Intelligent Vision Systems [ENT 496]
Laboratory Module 4
Name: ____________________________ Matrix No.:_____________ Date: _________
6. DISCUSSION
7. CONCLUSION
Instructor Approval: …………………………………………. Date: ………………
- 10 -
Intelligent Vision Systems [ENT 496]
Laboratory Module 4
Name: ____________________________ Matrix No.:_____________ Date: _________
ANALYSIS
1. Discuss four feature extraction methods
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
2. List out all the mat lab functions used in this experiment
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
Instructor Approval: …………………………………………. Date: ………………
- 11 -
Download