Unit3 CV
Unit3 CV
Line detection – Hough Transform (HT) for line detection – foot-of-normal method – line localization
– line fitting – RANSAC for straight line detection – HT based circular object detection – accurate
center location – speed problem – ellipse detection – Case study: Human Iris location – hole detection
– generalized Hough Transform (GHT) – spatial matched filtering – GHT for ellipse detection – object
location – GHT for feature collation.
1, LINE DETECTION
• In computer vision, line detection is an algorithm that takes a collection of n edge
points and finds all the lines on which these edge points lie
• The most popular line detectors are the Hough transform and convolution-based
techniques.
Application of the hough transform to line detection:
• The Hough transform can be used to detect lines and the output is a parametric
description of the lines in an image,
• The basic concept involved in locating lines by the HT is point-line duality.
• A point P can be defined either as a pair of coordinates or in terms of the set of lines
passing through it.
• The concept starts to make sense if we consider a set of collinear points Pi, then list
the sets of lines passing through each of them, and finally note that there is just one
line that is common to all these sets.
• Thus, it is possible to find the line containing all the points Pi merely by eliminating
those that are not multiple hits.
• For just as a point can define a set of lines, so a line can define a set of points. This
makes the above approach to line detection a mathematically elegant one,
• The form in which the method was originally applied involves parametrizing lines
using the slope_intercept equation:
• Every point on a straight edge is then plotted as a line in (m, c) space corresponding
to all the (m, c) values consistent with its coordinates, and lines are detected in this
space.
• Replace the slope_intercept formulation with the so-called “normal” (θ, ρ) form
for the straight line.
• To apply the method using this form, the set of lines passing through each point Pi
is represented as a set of sine curves in (θ, ρ) space: for example, for point
P1ðx1; y1Þ, the sine curve has equation:
• Then multiple hits in (θ, ρ) space indicate, via their (θ, ρ) values, the presence
of lines in the original image.
The Hough transform algorithm is as follows:
2. Foot-of-Normal Concept: The “foot of the normal” refers to the point on the line that
is closest to the origin. This point is significant because it helps in parameterizing
the line in the Hough space. The coordinates of this point can be used to determine
the parameters ( r ) and ( \theta ).
3. Detection Process: During the line detection process, each point in the image space
votes for all possible lines that could pass through it. These votes are accumulated in
the Hough space, and the peaks in this space correspond to the most likely lines in
the image.
• Definition: This refers to the precise identification and localization of lines that run
longitudinally (along the length) in an image. This is particularly important in tasks
like lane detection in autonomous vehicles.
• Techniques:
o Edge Detection: Techniques like Canny edge detection are often used as a
preprocessing step to identify potential line segments1.
o Vanishing Point Estimation: This involves identifying the point where parallel
lines appear to converge, which helps in accurately localizing longitudinal
lines.
• Final line fitting in line detection is a crucial step to accurately represent detected
lines in an image.
• Dudani and Luk (1978) found it useful to include a least-squares fitting stage to
complete the analysis of the straight edges present in an image.
• This is a standard approach to minimize the sum of the squares of the differences between the
observed points and the points predicted by the line.
• This is carried out by taking the x, y coordinates of points on the line as input data
and minimizing the sum of squares of distances from the data points to the best fit
line.
• Their reason for adding such a stage was to eliminate local edge orientation accuracy
as a source of error. This motivation is generally reasonable if the highest possible
accuracy is required (e.g., obtaining line orientation to significantly better than 1
degree).
• The diameter bisection method of Tsuji and Matsumoto (1978) is very simple in
concept.
• First, a list is compiled of all the edge points in the image.
• Then, the list is sorted to find those that are antiparallel, so that they could lie at
opposite ends of ellipse diameters; next, the positions of the center points of the
connecting lines for all such pairs are taken as voting positions in parameter space.
• As for circle location, the parameter space that is used for this purpose is
congruent to image space. Finally, the positions of significant peaks is parameter
space are located to identify possible ellipse centers.
FIGURE
• The set of edge points that contribute to a given peak in parameter space is used
to construct a histogram of R values,
• If a significant peak is found in this histogram, then there is clear evidence of an
ellipse at the specified location in the image.
• If two or more such peaks are found, then there is evidence of a corresponding
number of concentric ellipses in the image.
• If, however, no such peaks are found, then a rectangle, super ellipse, or other
symmetrical shape may be present and each of these would need its own
identifying test.
2. The Chord_Tangent Method:
• The chord_tangent method was devised by Yuen et al. (1988) and makes use of
another simple geometric property of the ellipse.
• Again pairs of edge points are taken in turn, and for each point of the pair, tangents
to the ellipse are constructed and found to cross at T, the midpoint of the
connecting line is found at M, and then the equation of line TM is calculated and
all points that lie on the portion MK of this line are accumulated in parameter
space (Fig. 12.14) (clearly, T and the center of the ellipse lie on the opposite sides
of M).
• Finally, peak location proceeds as before.
Here are some of the primary methods used for ellipse detection:
1. Hough Transform-Based Methods
The Hough Transform (HT) is a popular technique for detecting geometric shapes.
For ellipse detection, the image is transformed into a parametric space, and the
ellipse parameters are estimated by finding peaks in this space. This method is
robust but computationally expensive due to the high dimensionality of the
parameter space1.
2. Least Squares Fitting-Based Methods
These methods involve fitting an ellipse to a set of edge points by minimizing the
sum of squared distances between the points and the ellipse. This approach is
efficient and provides accurate results, especially when the edge points are well-
defined2.
3. Edge Following-Based Methods
Edge following methods detect ellipses by tracing the edges of objects in an
image. These methods typically involve:
• Extracting edge points using edge detection algorithms like Canny.
• Grouping edge points into arcs.
• Fitting ellipses to these arcs based on geometric constraints3.
4. Line Segment-Based Methods
These methods detect ellipses by first identifying line segments in the image and
then grouping these segments into ellipses. This approach can be more efficient
than HT-based methods and is particularly useful in images with well-defined
edges1.
5. Optimization-Based Methods
Optimization methods frame ellipse detection as an optimization problem, where
the goal is to find the ellipse parameters that best fit the observed data. Techniques
like genetic algorithms or particle swarm optimization can be used to solve this
problem3.
6. Deep Learning-Based Methods
Recent advances in deep learning have led to the development of neural network-
based methods for ellipse detection. These methods can learn to detect ellipses
from large datasets and are particularly effective in complex and noisy images.
7. Real-Time Ellipse Detection
For applications requiring real-time performance, such as robotics, specialized
methods have been developed. These methods often combine multiple
techniques, such as HSV color space transformation, arc selection, and clustering,
to achieve high-speed and accurate ellipse detection,
• This Hough-based approach can be a very efficient one for locating the centers of
circular objects, virtually all the superfluous operations having been eliminated,
leaving only edge detection, location of candidate center points, and center point
averaging to be carried out.
• The efficiency of the above technique means that it takes slightly less time to
perform the actual HT part of the calculation than to evaluate and threshold the
intensity gradient over the whole image.
The problem of unknown circle radius
• There are a number of situations where circle radius is initially unknown. One such
situation is where a number of circles of various sizes are being sought—as in the case
of coins, or different types of washer.
• All circular objects have to be found and their radii measured. In such cases, the
standard technique is to accumulate candidate center points simultaneously in a
number of parameter planes in a suitably augmented parameter space, each plane
corresponding to one possible radius value.
• The centers of the peaks detected in parameter space give not only the location of
each circle in two dimensions but also its radius. Although this scheme is entirely viable
in principle, there are several problems in practice:
o 1. Many more points have to be accumulated in parameter space.
o 2. Parameter space requires much more storage.
o 3. Significantly greater computational effort is involved in searching parameter
space for peaks.
Fast Center Finding Algorithm in Circle object Detection.
There are a number of causes of inaccuracy in locating the centers of circles using the HT:
1. Natural edge width may add errors to any estimates of the location of the center.
2. Image noise may cause the radial position of the edge to become modified.
3. Image noise may cause variation in the estimates of local edge orientation.
4. The object itself may be distorted, in which case the most accurate and robust estimate of circle
center is what is required (i.e., the algorithm should be ableto ignore the distortion and take a useful
average from the remainder of the boundary).
5. The object may appear distorted because of inadequacies in the method of illumination.
6. The edge orientation operator will have a significant inherent inaccuracy of its own, which
contributes to inaccuracy in the estimation of center location.
• Find a point D in the region of the center and use it to obtain a better approximation A to the
center by moving from the current edge pixel P a distance equal to the expected radius r in the
direction of D (Fig. 12.6).
• Then repeat the process 1 edge pixel at a time until all edge pixels have been taken into account.
• Although intuition indicates that this strategy will lead to a good final approximation to the
center, the edge points need to be taken in random order to prevent the bias of the initial center
approximation from permanently affecting the final result.
• To improve the speed of computation two methods are tried: (1) sampling the image data and
(2) using a simpler edge detector.
• First, the amount of computation involved in the original Hough-based approach is modeled
by:
• where T0 is the total time taken to run the algorithm on an N3N pixel image; s is the time taken
per pixel to compute the Sobel operator and to threshold the intensity gradient g; S is the number
of edge pixels that are detected; and t0 is thetime taken to compute the position of a candidate
center point.
• Next, the amount of computation in the basic chord bisection approach is modeled as:
• where T is the total time taken to run the algorithm; q is the time taken per pixel to compute a
two-element x or y edge detection operator and to perform thresholding; Q is the number of
edge pixels that are detected in one or other scan direction; and t is the time taken to compute
the position of a candidate center point coordinate (either xc or yc).
• he overall gain in speed from using the chord bisection scheme should be:
12. Explain how Hough Transform is used in locating human iris and in hole
detection.
Human Iris Location:
• Human iris location is an important application of computer vision for three reasons:
(1) it provides a useful cue for human face analysis;
(2) it can be used for the determination of gaze direction; and
(3) it is useful in its own right for biometric purposes, that is to say, for identifying individuals
almost uniquely.
• We can tackle the iris location and recognition task reasonably straightforwardly.
• First, if the head has been located with reasonable accuracy, then it can form a region of
interest, inside which the iris can be sought. In a front view with the eyes looking ahead, the
iris will be seen as a round often high-contrast object, and can be located straightforwardly
with the aid of a HT.
• In some cases, this will be less easy because the iris is relatively light and the color may not be
distinctive—although a lot will depend on the quality of the illumination.
• Perhaps more important, in some human subjects, the eyelid and lower contour of the eye may
partially overlap the iris (Fig. 12.15(a)), making it more difficult to identify, although, as
confirmed below, HTs are capable of coping with a fair degree of occlusion.
• A number of the points made above are illustrated by the example in Fig. 12.15.
• Far from being a trivial application of the HT, there are a surprisingly large number of edges
in the eye region: these produce significant numbers of additional votes, which interfere with
those from the irises.
• These arise from the upper and lower eyelids and the folds of skin around them. Hence, the
accuracy of the method is not assured: this makes gradient weighting especially valuable.
• The radii of the irises shown in Fig. 12.15 are about 17.5 pixels, and there is no particular
evidence of ellipticity in their shape. However, more accurate location of the iris and
measurement of ellipticity in order to estimate orientation (e.g., to determine the angle of gaze)
require considerably greater resolution, with iris radii approaching 100 pixels, whereas pictures
that analyze iris texture patterns for biometric purposes require even larger radii.
HOLE DETECTION:
• HT technique is used for Hole Detection, votes will have to be accumulated on moving a
distance 2R along the direction of the local edge normal.
• There is no difficulty with this for large holes, but as the holes become smaller, complications
tend to occur because of poor lighting inside the holes.
• As a result, large regions of shadow are likely to occur, and the contrast is liable to be weak
and variable.
• We shall not consider the general situation further as it is so dependent on size, illumination,
and other factors, such as 3-D shape and the material within which the hole appears.
• Nevertheless, for small holes a few pixels across, detection can be important as they constitute
point features, and these can be valuable for precise object location, as happens for biscuits,
hinges, brackets, and a host of other manufactured parts .
• In fact, circular holes may even be preferable to corners for object location, as they are, ideally,
isotropic and thus less liable to bias when used for measurement.
• Very small holes can be detected using template matching.
• This involves applying a Laplacian type of operator, and in a 333 neighborhood this may take
the form of one of the following convolution masks:
• Having applied the convolution, the resulting image is thresholded to indicate regions where
holes might be present.
• Note that the coefficients in each of the above masks sum to zero so that they are insensitive
to varying levels of background illumination.
• If the holes in question are larger than 1_2 pixels in diameter, the above masks will prove
inadequate.
• Clearly, larger masks are required if larger holes are to be detected efficiently at their centers.
• For much larger holes, the masks that are required become impracticably large, and the HT
approach becomes a more attractive option.