Very Fast Ellipse Detection using GPU-Based RHT

Very Fast Ellipse Detection using GPU-Based RHT
Jong Kwan Lee
Brian A. Wood
Timothy S. Newman
Department of Computer Science, University of Alabama in Huntsville
{jlee, bwood, tnewman}@cs.uah.edu
Abstract
An approach to very rapid computation of one class
of randomized Hough transform (RHT) using parallel processing capabilities of a programmable graphics
processing unit is described. The method is able to detect ellipses in real-time, even in large images. It uses
fragment processing in recovering ellipse shape parameters. Its effectiveness is evaluated through experiments
on synthetic and real images.
1
Introduction
Automated ellipse detection is beneficial in many application domains, including manufactured object inspection, face detection, medical imaging, remote sensing, etc. Fast and robust ellipse detection is especially
valuable when there are tight real-time processing requirements or when very large numbers of images need
to be processed. In this paper, exploitation of programmable graphics processing unit (GPU) capabilities
to enable very fast ellipse detection is described.
One target application of our work is the automated
processing of a collection of several million satellite
images of the Earth’s aurorae collected over the past
10 years by the NASA Polar Ultraviolet Imager (UVI).
Aurorae (especially the outer boundary of the aurorae)
have an elliptic shape in such images and localization of
the auroral oval in them is a key precursor to effective
use of the images for a variety of geophysical studies.
Localizing the oval also can enable content-based retrieval of aurorae imagery. Figure 1 shows two example
UVI images of the aurora. The white arcing structure
in each image is the auroral oval. While we focus on
such imagery, our approach is applicable to detection of
ellipses in any problem domain.
A typical avenue to ellipse detection is the Hough
Transform (HT) [4] and its variants. The HT methods
transform features of an image into a parameter space
in which patterns representative of ellipses can be de-
978-1-4244-2175-6/08/$25.00 ©2008 IEEE
(a)
(b)
Figure 1. Examples of UVI Aurora Images
tected. In HT, each boundary point maps to one or more
“bins” of the parameter space. The parameters associated with the high count bin are then taken as the HT
result. Standard HT, however, is of limited use for fast
ellipse detection since it requires a lot of computational
processing (and memory). One HT variant that is wellsuited to ellipse detection due to its lessened usage of
memory and fast processing characteristic is the Randomized Hough Transform (RHT) [5] for ellipses, as
proposed by McLaughlin [6]. While HT considers every boundary pixel, RHT instead uses many groups of
boundary pixels, with each group made up of a few randomly selected boundary pixels. Each group maps to a
single entry in a parameter space.
Here, we describe how one class of RHT for ellipse detection can be made to operate very quickly
through use of the parallel processing capabilities of
a programmable GPU. The approach enables real-time
ellipse localization and parameter recovery. To our
knowledge, the work here is the first one to exploit the
GPU for any form of RHT.
2
Related Work
HT-based processing has been used successfully in
many shape-based processing schemes, especially in
the detection of simple shapes. One challenge to use of
HT-based schemes for detecting more complex shapes
is the large amount of memory consumed by the pa-
rameter space bins. Perhaps more critically, computational burden also increases with shape complexity. One
strategy to alleviate the memory and computation challenges that has been previously utilized in HT-based ellipse detection is partitioning the 5-D parameter space
into lower-dimensional subspaces (e.g., [3, 6, 9]). Such
processing involves sequentially finding parameters in
the series of lower dimensional subspaces and, in some
cases (e.g., [9]), application of constraining rules that
speed-up processing. McLaughlin’s [6] RHT for ellipses combines partitioning with the boundary pixel
grouping strategy described in Section 1. Cao and Newman [1] have extended the RHT for ellipses method to
incorporate a linear least squares fitting step that enables
fast operation and application when not all RHT necessary conditions are satisfied. That method, LLS-based
RHT, is discussed in more detail in Section 3.
The recent introduction of graphics cards that have
programmable graphics processing units rather than
fixed-function pipelines has resulted in growing use
of the GPU as a general-purpose (GP) computing
platform. Such GPUs contain hardware highly optimized for mathematical applications and provide a
large amount of parallel processing capacity. GP-GPU
processing has been applied in some shape processing applications. For example, Strzodka et al. [7] have
achieved the Generalized Hough Transform on a GPU
by performing the HT operations directly in texture
memory. In addition, the OpenVIDIA project [2] has
used multiple graphics cards to implement HT through
the use of the GPU shaders and rasterizer. Also, Ujaldon et al. [8] have recently sped up the HT binning process on the GPU rasterizer for detection of circles of
known radius.
3
GPU-Based Approach
Next, the new approach is described. The approach exploits the parallel processing capability of a
programmable GPU to enable very fast computation
of one RHT method for ellipse detection, the linear
least squares-based (LLS-based) RHT [1]. LLS-based
RHT involves partitioning of the parameter space and a
group-based strategy. Its group-based strategy includes
a random component.
Specifically, in LLS-based RHT, the parameter
space accumulation process involves iteratively selecting groups of m (m ≥ 5) boundary pixels (here we
have used m = 5). The members of each group are selected at random. In each iteration, a general quadratic
is fit using least squares on the group elements. If
this quadratic’s invariant descriptors indicate that the
quadratic is elliptic, then the center, semi-axis length,
and axis orientation parameters of that ellipse are computed from the general quadratic. In LLS-based RHT,
the parameter space is partitioned into a 2D space for
the center position, a 2D space for the semi-axis lengths,
and a 1D space for orientation. Thus each recovered parameter is mapped into the appropriate bins of the parameter subspaces. Once a suitable number of iterations
have been applied, the image’s elliptic structure’s parameters are determined from the highest-count bin of
each parameter subspace.
The approach described here performs the random
boundary point selection, linear least squares fitting of
the general quadratic, and computation of ellipse parameters from the general quadratic on the GPU.
3.1
Fragment Processing
The approach’s processing steps exploit the parallel
fragment processing capabilities of current-generation
GPUs. The major input to the GPU is the set of boundary pixels. Specifically, given N boundary pixels in an
image, the locations of these pixels are stored by the
CPU in a T × N array, where T is the number of rows
and T ×N is the number of iterations for the LLS-based
RHT method (we have used T × N =10000 here). The
array’s first row has the N pixel locations and each row
after the first has a duplicate of the first row. This array
is mapped to a texture for GPU operation. Several random numbers, each valued between 1 and N , are also
generated on the CPU.
On the GPU, the first activity is to perform the
randomization part of LLS-based RHT. Randomization
on a GPU is challenging. We achieve randomization
through a random shuffling process which is achievable
on a GPU. That process involves first duplicating the
input T × N texture to create four duplicates of the
original. In each of the five textures, some columns are
swapped in a random fashion. Specifically, for the ith
texture, the ith random number, Ri is used to shuffle
every Rith column of the first dN/2e columns. The first
shuffle is done with column N , the second with column
N − Ri , the third with N − 2Ri , etc. Then the items in
1 2
1 2
3
3
4
4
5 6
5 6
7
7
8 9 10 11
8 9 10 11
1 11 3
9 5
7
6
8
4 10 2
1 11 3
9 5
7
6
8
4 10 2
1 2
3
4
5 6
7
8
9 10 11
1 11 3
9 5
7
6
8
4 10 2
(a)
(b)
3
5
9 5
7 6
6
8
7
8
6 8 4 10 2 1 11
4 10 2 1 11 3 9
4 10 2 1 11 3 9 5
7
(c)
Figure 2. Example of Texture Shuffling
Boundary
points
Apply random texture shuffling
Boundary point Textures
G
P
U
Apply LLS fitting to
2
2
Ax + By + Cxy + Dx + Ey + F = 0
A, B, C, D, E, F Textures
Determine
Ellipse
Center
Center
Texture
C
P
U
Vote for
Ellipse
Center
Determine
Ellipse
Semi axis
Semi axis
Texture
Vote for
Ellipse
Semi axis
Determine
Ellipse
Orientation
Orientation
Texture
Vote for
Ellipse
Orientation
Find maximum votes for
center, semi axis, orientation
Figure 3. Overview of New GPU LLSbased RHT Steps
each row of a texture are shifted by a random amount.
Figure 2 shows an example of random shuffling of a
3 × 11 texture. The original texture is shown in Figure 2(a). Figure 2(b) shows the texture after column
swapping. Figure 2(c) shows the final result after rowshifting. The corresponding items of each texture are
used to form the pixel groups used by LLS-based RHT
(i.e., 5-tuples of boundary pixels are taken from the randomly shuffled textures). The shuffling is performed on
the GPU’s fragment processor.
Following shuffling, least squares fitting of the general quadratic is performed. The fitting and parameter
determination can be done in parallel by the fragment
processor since the same processing operations must be
performed on each element of the original texture.
Figure 3 illustrates the LLS-based RHT’s processing
steps using the GPU-based approach. The steps on the
GPU’s fragment processor are shown in red. We note
that the iterative component of LLS-based RHT is handled via the fragment processor’s operation on packed
textures in a data-parallel way; the fragment processor’s
data parallel approach avoids encoding the iterations explicitly. The approach performs the final accumulation
step on the CPU. This step is one that is not easily performed on the GPU. The transfer to the CPU is quite
efficient, however, since only one GPU texture-to-CPU
accumulator array mapping needs to be performed.
4
Experimental Results
The approach’s effectiveness has been evaluated
for synthetic and real images. The evaluation included comparisons of computational performance of
Figure 4. Parameter Error versus Noise
our GPU-based approach versus LLS-based RHT on
a CPU. The synthetic imagery testing involved Monte
Carlo testing on ellipse boundary images. Such tests
considered five image sizes and seven levels of Gaussian noise, allowing determination of the impact of
noise on fitting and image size on computation speed.
Ellipses were oriented at 5 orientations and each had
semi-axis sizes of 40% and 18% of image size. The real
imagery testing involved 20 satellite images (collected
by the POLAR satellite’s UVI sensor) of aurorae and
20 scaled-up versions of the images. Tests were done
on a computer with a 3.2 GHz Pentium-D with 3 GB of
RAM running Linux. Tests of the GPU-based approach
were done on the same computer’s NVIDIA GeForce
7950GT that has 512 MB of memory.
The synthetic image testing considered images of the
sizes shown in Table 1. The added Gaussian noise had
zero mean and σ’s of 0, 1, 2, 3, 5, 10, and 15 and was
used to perturb boundary positions in one dimension.
A total of ten images for every combination of size and
noise were tested (i.e. 350 images in all). Averages over
the images are reported here. Due to space limits, we
show the GPU-based approach’s parameter fitting errors
for only the largest images (in color Figure 4). For the
GPU-based approach, average parameter errors across
the entire set of tests averaged less than 3 pixels for
the centroid and axis lengths and less than 1 degree for
orientation. We note that the errors of the GPU-based
RHT are comparable to those observed for the CPU.
Table 1 shows the execution times and speedups for the
approaches. The GPU-based approach was much faster
(about 7 to 9 times) than LLS-based RHT on the CPU,
as shown in Table 1, with speed-up increasing slightly
with image size.
The UVI images are 200 × 228. The scaled-up images were each versions of an underlying UVI image.
They were created six times larger in each dimension
using bilinear interpolation. The aurorae outer bound-
ary pixels were found in these images using the UVI image pre-processing described by Cao and Newman [1].
Since the true parameters are unknown for these images,
the ellipse detection results were manually inspected.
The recovered ellipses were always within a few pixels
of the optimal (manually-determined) boundary. The
average errors in parameters recovered by our GPUbased approach versus manual inspection are shown in
Table 2. Two example results are shown in Figure 5 (for
the images first shown in Figure 1). In the figure, the
blue overlay is the ellipse detected by LLS-based RHT
on the CPU and the red overlay is the ellipse detected by
our GPU-based approach. The GPU-based approach’s
speed advantage ranged from 7 to 9 times, as shown in
Table 3. It is worth noting that although the GPU-based
approach was a less random approach than LLS RHT on
a CPU, the random shuffling process did not noticeably
impact method accuracy.
5
(a)
Figure 5. Results on Real Aurora Images
Table 2. Average Divergence in Recovered
Ellipse Parameters
Image Sizes
Center X Position
Center Y Position
Major Axis Length
Minor Axis Length
Orientation
Conclusion
We have presented a very fast ellipse detection approach for a class of RHT. The core of our approach
is performing the LLS-based RHT ellipse parameter recovery using the fragment processor on a programmable
GPU. Through evaluation of the approach, we have
shown that the approach can provide consistent and
very fast automated detection of ellipses. The approach
achieved 226 f.p.s. and 52 f.p.s. for single ellipse detection in 200×228 and 1200×1368 real aurora images,
respectively.
Image Sizes
200×228
400×456
800×912
1200×1368
1600×1824
On CPU
30.1
44.5
93.6
177.5
283.4
New Approach
4.2
5.6
10.8
19.1
30.5
Image Sizes
200×228
1200×1368
and
Speedup
7.167
7.946
8.667
9.293
9.292
[3]
[4]
[5]
[6]
Acknowledgment
This work was partially supported by NASA Science
Mission Directorate under grant NNG05GA88G.
[7]
[8]
References
[9]
[1] C. Cao and T. S. Newman. Shape-based mechanisms
for content-based retrieval of aurora images. In Proc.,
200×228
0.30
1.00
0.65
0.80
1.85
1200×1368
2.55
5.75
6.70
3.85
1.65
Table 3. Execution Times (msec.)
Speedups using Real Images
[2]
Table 1. Execution Times (msec.)
Speedups using Synthetic Images
(b)
LLS-RHT
28.6
176.7
GPU LLS-RHT
4.4
19.2
and
Speedup
6.477
9.221
SPIE Conf. Wavelet Applications in Industry Processing
IV, volume 6383, pages 63830T–1–63830T–12, 2006.
J. Fung, S. Mann, and C. Aimone. Openvidia: Parallel
gpu computer vision. In Proc., 13th Annual ACM Int’l
Conf. Multimedia, pages 849–852, 2005.
C. Ho and L. Chen. A high-speed algorithm for elliptical object detection. IEEE Trans. Image Processing,
5(3):547–550, 1996.
P. V. C. Hough. Method and means for recognizing complex patterns, 1962. U.S. Patent, 3,069,654.
P. Kultanen, L. Xu, and E. Oja. Randomized hough transform (rht). In Proc., 10th Int’l Conf. Pattern Recognition,
volume 1, pages 631–635, 1990.
R. A. McLaughlin. Randomized hough tranform: Improved ellipse detection with comparison. Pattern Recognition Letters, 19(3–4):299–305, 1998.
R. Strzodka, I. Ihrke, and M. Magnor. A graphics hardware implementation of the generalized hough for fast
object recognition, scale, and 3d pose detection. In Proc.,
Int’l Conf. Img. Anal. and Proc., pages 188–193, 2003.
M. Ujaldon, A. Ruiz, and N. Guil. On the computation
of the circle hough transform by a gpu rasterizer. Pattern
Recognition Letters, 29(3):309–318, 2007.
S. Zhang and Z. Liu. A robust, real-time ellipse detector.
Pattern Recognition, 38(2):273–287, 2005.