Intelligent Vision Systems [ENT 496] Laboratory

advertisement
Intelligent Vision Systems [ENT 496]
Laboratory Module 3
INTELLIGENT VISION SYSTEMS
ENT 496
LABORATORY MODULE
EXPERIMENT 3
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 3
EXPERIMENT 3
BINARY IMAGING AND EDGE DETECTION
1. OBJECTIVE:
To develop algorithms for binary imaging and edge detection using Sobel and Canny
operators.
2. COMPONENTS, EQUIPMENTS & SOFTWARE:
Objects
Vision Sensors
MATLAB software
3. INTRODUCTION:
Binary Images:
In a binary image, each pixel assumes one of only two discrete values. Essentially,
these two values correspond to on and off. A binary image is stored as a logical array of
0's (off pixels) and 1's (on pixels). Pixels in a Binary Image Have Two Possible Values: 0
or 1. A binary image can be created by using thresholding. The function graythresh
automatically computes an appropriate threshold to use to convert the intensity image to
binary. The Matlab function produces binary images from indexed, intensity, or RGB
images. To do this, it converts the input image to grayscale format (if it is not already an
intensity image), and then converts this grayscale image to binary by thresholding. The
output binary image has values of 0 (black) for all pixels in the input image with
luminance less than LEVEL and 1 (white) for all other pixels. The function Graythresh
can be used to compute LEVEL automatically. The input image can be of class uint8,
uint16, or double and it must be nonsparse. The output image is of class logical.
Graythresh computes global image threshold using Otsu's method the function
computes a global threshold (level) that can be used to convert an intensity image to a
binary image , level is a normalized intensity value that lies in the range [0, 1]. The
graythresh function uses Otsu's method, which chooses the threshold to minimize the
intra class variance of the black and white pixels. Multidimensional arrays are converted
automatically to 2-D arrays using reshape. The gray thresh function ignores any nonzero
imaginary part of I. Class Support The input image I can be of class uint8, uint16, or
double and it must be no sparse. The return value level is a double scalar.
Morphological Operations:
1. Close Operator:
This operator performs morphological closing on the grayscale or binary image,
returning the closed image. The structuring element, must be a single structuring
-2-
Intelligent Vision Systems [ENT 496]
Laboratory Module 3
element object, as opposed to an array of objects., with structuring element the operator
performs closing with the structuring element strel(NHOOD), where NHOOD is an array
of 0's and 1's that specifies the structuring element neighborhood. The image can be any
numeric or logical class and any dimension, and must be nonsparse.
2. Open Operator:
This operator performs morphological opening on the grayscale or binary image with the
structuring element SE. The argument SE must be a single structuring element object,
as opposed to an array of objects, this performs opening with the structuring element
strel(NHOOD), where NHOOD is an array of 0's and 1's that specifies the structuring
element neighborhood. Image can be any numeric or logical class and any dimension,
and must be nonsparse. If IM is logical, then SE must be flat. IM2 has the same class as
IM.
3. Erode Operator:
This operator erodes the grayscale, binary, or packed binary image returning the eroded
image. The argument SE is a structuring element object or array of structuring element
objects returned by the strel function. If image is logical and the structuring element is
flat, the function performs binary dilation; otherwise it performs grayscale erosion. If SE
is an array of structuring element objects, imerode performs multiple erosions of the
input image, using each structuring element in SE in succession. IM2 = imerode
(IM,NHOOD) erodes the image IM, where NHOOD is an array of 0's and 1's that
specifies the structuring element neighborhood. Image can be numeric or logical and it
can be of any dimension. If IM is logical and the structuring element is flat, the output
image is logical; otherwise the output image has the same class as the input. If the input
is packed binary, then the output is also packed binary.
4. Fill Operator:
This operator performs a flood-fill operation on background pixels of the binary image,
starting from the points specified in locations. If locations are a P-by-1 vector, it contains
the linear indices of the starting locations. If locations is a P-by-ndims(BW) matrix, each
row contains the array indices of one of the starting locations. BW2 = imfill(BW,'holes')
fills holes in the binary image BW. A hole is a set of background pixels that cannot be
reached by filling in the background from the edge of the image. I2 = imfill(I) fills holes in
the intensity image I. In this case, a hole is an area of dark pixels surrounded by lighter
pixels. Interactive UseBW2 = imfill(BW) displays the binary image BW on the screen and
lets you select the starting locations using the mouse. Click the mouse button to add
points. Press Backspace or Delete to remove the previously selected point. A shift-click,
right-click, or double-click selects a final point and then starts the fill operation; pressing
Return finishes the selection without adding a point. Note imfill supports interactive use
only for 2-D images. [BW2,locations] = imfill(BW) lets you select the starting points
selected using the mouse, returning the locations of points in locations. locations is a
vector of linear indices into the input image. By default, the function l uses 4-connected
background neighbors for 2-D inputs and 6-connected background neighbors for 3-D
inputs.
-3-
Intelligent Vision Systems [ENT 496]
Laboratory Module 3
Edge:
The edge function is used to detect edges, which are those places in an image that
correspond to object boundaries. To find edges, this function looks for places in the
image where the intensity changes rapidly, using one of these two criteria: Places where
the first derivative of the intensity is larger in magnitude than some threshold Places
where the second derivative of the intensity has a zero crossing edge provides a number
of derivative estimators, each of which implements one of the definitions above. For
some of these estimators, you can specify whether the operation should be sensitive to
horizontal edges, vertical edges, or both. Edge returns a binary image containing 1's
where edges are found and 0's elsewhere.
The Sobel method finds edges using the Sobel approximation to the derivative. It returns
edges at those points where the gradient of the image is maximum.
The most powerful edge-detection method that edge provides is the Canny method. The
Canny method differs from the other edge-detection methods in that it uses two different
thresholds (to detect strong and weak edges), and includes the weak edges in the output
only if they are connected to strong edges. This method is therefore less likely than the
others to be fooled by noise, and more likely to detect true weak edges.
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) Repeat conversion with 3 different threshold values and choose the best
threshold value for the given image.
f)
Convert the binary image obtained to an edge image first by using a Sobel
operator and then by using a Canny operator.
g) Perform the following morphological operations on the binary image obtained in
step (e) and observe and record the results.
1.
2.
3.
4.
Open
Close
Erosion
Fill
h) Write an algorithm to acquire an image and to read, resize and convert to a
binary image and subsequently to an edge image.
i)
Write a mat lab program to read, resize and convert a given image to a binary
image and subsequently to an edge 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 3
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:
_______________________________
_______________________________
_______________________________
Object Name:
_______________________________
_______________________________
_______________________________
(b) Resized Images
Object Name:
_______________________________
_______________________________
_______________________________
Object Name:
_______________________________
_______________________________
_______________________________
Instructor Approval: …………………………………. Date: ……………………
-5-
Intelligent Vision Systems [ENT 496]
Laboratory Module 3
Name:____________________________ Matrix No.:_____________ Date:_________
(c ) Binary Images
Object Name:
Threshold: T =
_______________________________
_______________________________
_______________________________
Object Name:
Threshold : T =
_______________________________
_______________________________
_______________________________
Object Name:
Threshold: T =
_______________________________
_______________________________
_______________________________
(d ) Edge Images
Object Name:
Canny Edge:
_______________________________
_______________________________
_______________________________
Instructor Approval: …………………………………. Date: ……………………
-6-
Intelligent Vision Systems [ENT 496]
Laboratory Module 3
Name: ____________________________ Matrix No.:_____________ Date:_________
Object Name:
Sobel Edge:
_______________________________
_______________________________
_______________________________
(e) Morphological Operations on Binary Image
Open:
_______________________________
_______________________________
_______________________________
Close:
_______________________________
_______________________________
_______________________________
Erosion:
_______________________________
_______________________________
_______________________________
Fill:
_______________________________
_______________________________
_______________________________
Instructor Approval: …………………………………………. Date: ………………
-7-
Intelligent Vision Systems [ENT 496]
Laboratory Module 3
Name:____________________________ Matrix No.:_____________ Date:_________
e) Algorithm to acquire a image and to read, resize and convert to a binary image
using threshold and subsequently to convert to edge image.
Instructor Approval: …………………………………………. Date: ………………
-8-
Intelligent Vision Systems [ENT 496]
Laboratory Module 3
Name:____________________________ Matrix No.:_____________ Date:_________
Mat lab program to read, resize and convert a given image to a binary image using
threshold and subsequently to convert to edge image.
-9-
Intelligent Vision Systems [ENT 496]
Laboratory Module 3
Instructor Approval: …………………………………………. Date: ………………
Name: ____________________________ Matrix No.:_____________ Date: _________
6. DISCUSSION
7. CONCLUSION
Instructor Approval: …………………………………………. Date: ………………
- 10 -
Intelligent Vision Systems [ENT 496]
Laboratory Module 3
Name: ____________________________ Matrix No.:_____________ Date: _________
ANALYSIS
1. What are the initial preprocessing procedures to be followed before binary conversion
can be applied?
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
2. List out all the mat lab functions used in this experiment
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
Instructor Approval: …………………………………………. Date: ………………
- 11 -
Intelligent Vision Systems [ENT 496]
Laboratory Module 3
Name: ____________________________ Matrix No.:_____________ Date: _________
3. Describe briefly the four morphological operations performed on the binary images
and discuss on the effects of the operations on the binary image.
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
4. List out your observations while using a Sobel Edge Detector and a Canny edge
detector.
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
Instructor Approval: …………………………………………. Date: ………………
- 12 -
Download