Beruflich Dokumente
Kultur Dokumente
1. Edge Detection
1.1 Problem Overview
In the field of Image Processing, the extraction of geometric features from images is very common problem. Over the years, several different approaches have been
devised to extract these features.
These different approaches can be characterized and classified in several different ways.
Some of the techniques involve global examination of the image, while others only involve local examination of each pixel in the image.
Typically, the first step in the process is to perform some form of edge detection on the image, and to generate a new Binary edge image that provides the necessary
segmentation of the original image.
Edge detection algorithms operate on the premise that each pixel in a grayscale digital image has a First derivative, with regard to the change in intensity at that
point, if a significant change occurs at a given pixel in the image, then a black pixel is placed in the binary image, otherwise, a white pixel is placed there instead.
In general, the gradient is compared at each pixel that gives the degree of change at each point in the image.The question basically amounts to how much change in
the intensity should be required in order to constitute a feature point in the binary image.
To find the accuracy location of an edge, a Second derivative is often used to find the point that corresponds to the local maximum and minimum in the first
derivative.
This is often referred to as a Zero Crossing because it is the point at which the second derivative equals to zero, but its left and right neighbors are non-zero and
have opposite signs.
For some of these estimators, it is possible to specify whether the edge detector is sensitive to horizontal or vertical edges or to both. The general syntax for the edge
function is:
where f is the input image, the most popularly used approaches are listed in the following table, and parameters are additional parameters explained in the following
discussion.
In the output, g is a logical array with 1's at the locations where edge points were detected in f and 0's elsewhere. Parameter t is optional, it gives the threshold used
by edge to determine which gradient values are strong enough to be called edge points.
Now let us try those different methods and parameters to see what is the difference between them:
T=100;
f=zeros(128,128);
f(32:96,32:96)=255;
[g1, t1]=edge(f, 'sobel', 'vertical');
imshow(g1);
t1
sigma=1;
f=zeros(128,128);
f(32:96,32:96)=255;
ftp://www.cs.uregina.ca/pub/class/425-nova/Lab4/index.html 1/5
21/12/2018 Edge Detection and Hough Transform
[g3, t3]=edge(f, 'canny', [0.04 0.10], sigma);
figure,imshow(g3);
t3
2. Hough Transform
2.1 What is the Hough Transform
The Hough Transform (HT) is a robust method for finding lines in images that was developed by Paul Hough.
For each line L, there is a unique line L?perpendicular to L which passes through the origin.
L?has a unique distance and angle from the horizontal axis of the image. This angle and distance define a point in the parameter space, sometimes known as
Hough space.
A point in image space has an infinite number of lines that could pass through it, each with a unique distance and angle.
This set of lines corresponds to a sinusoidal function in parameter space. Two points on a line in image space correspond to two sinusoids which cross at a
point in parameter space.
That point in parameter space corresponds to that line in image space, and all sinusoids corresponding to points on that line will pass through that point.
The real solution to implement this algorithm is to quantize the parameter space by using a 2D array of counters, where the array coordinates represent the
parameters of the line; this is commonly known as an accumulator array.
The HT method for finding lines in images generally consists of the following three stages:
Perform accumulation on the accumulator array using the binary edge image.
Find peak values in the accumulator array
Verify that the peaks found correspond to legitimate lines, rather than noise.
The MATLAB has a function called hough that computes the Hough Transform.
In the following example, we will illustrate the use of function hough on a simple binary image.
f=zeros(101,101);
f(1,1)=1;
f(101,1)=1;
f(1,101)=1;
f(101,101)=1;
f(51,51)=1;
ftp://www.cs.uregina.ca/pub/class/425-nova/Lab4/index.html 2/5
21/12/2018 Edge Detection and Hough Transform
2.3 Hough Transfrom Peak Detection
Now we have hough space stored in H, the next step is peak detection.
where H is the Hough Transfrom matrix, and the numpeaks is the maximum number of peak locations to look for.
In the output,r and c are the row and column coordinates of the identified peaks, HNEW is the Hough Transform with peak neighborhood suppressed.
Once a set of candidate peaks has been identified in the Hough transform, it remains to be determined if there are line segments associated with those peaks, as well
as start and ending points.
For each peak, the first step is to find the location of all nonzero pixels in the image that contributed to that peak. the function houghpixels can do this.
3. Global Threshoding
1. Select an initial estimate for T.(A suggested initial value is the midpoint between the minimum and maximun intensity values in the image.)
2. Segment the image using T. This will produce two groups of pixels, G1 consisting of all pixels with intensity values > T, and G2, consisting of pixels with
values < T.
3. Compute the average intensity values x1 and x2 for the pixels in regions G1 and G2.
4. Compute a new threshod value: T=1/2(x1+x2)
5. Repeat steps 2 through 4 until the difference in T in successive iterations is smaller than a predifined parameter T0.
You can also use IPT's function graythresh to reah the same goal.
T = graythresh(f)
4. References
Digital Image Processing, Using MATLAB, by Rafael C. Gonzalez, Richard E. Woods, and Steven L. Eddins
Image Processing Toolbox, For Use with MATLAB (MATLAB's documentation)--available through MATLAB's help menu or online at:
http://www.mathworks.com/access/helpdesk/help/toolbox/images/
5. Exercises
Part 1: Identifying and Using Edge function
ftp://www.cs.uregina.ca/pub/class/425-nova/Lab4/index.html 3/5
21/12/2018 Edge Detection and Hough Transform
1. Download the following image "building.jpg" and store it in MATLAB's "Current Directory".
3. Reproduce the results for input image building.jpg. I encourage you to try different T and Sigma to get the best result.
Deliverables:
1. Download the following image "text.jpg" and store it in MATLAB's "Current Directory".
ftp://www.cs.uregina.ca/pub/class/425-nova/Lab4/index.html 4/5
21/12/2018 Edge Detection and Hough Transform
2. Reproduce the results to get the image looks like the following enhace_text.jpg.
Deliverables:
Value of optimal T
image after threshoding
ftp://www.cs.uregina.ca/pub/class/425-nova/Lab4/index.html 5/5