A cost optimal parallel algorithm for weighted distance transforms
Introduction
The distance transform of a black and white binary image is an operation which computes, for each pixel, the distance to the nearest black pixel. The distance transform is first introduced by Rosenfeld and Pfaltz [15], and is used in many image processing operations, such as nearest neighbor interpolation, morphological processing (skeletonization, thinning) and pattern matching [12].
These distance transforms are based on many kinds of distance functions because the distance functions have different efficiency or usefulness. The distance transform based on the Euclidean distance is preferred in various applications, but the Euclidean distance transform is a time-consuming operation. Consequently, many approximations to the Euclidean distance have been considered, such as city block, chessboard and chamfer distances.
For distance transforms of n×n binary images based on these distances, many O(n2) time sequential algorithms are proposed. For example, Borgefors [2] proposed a city block distance transform algorithm. The algorithm consists of only two scans; one is downward scan from left to right and the other is upward scan from right to left. Hirata [7] proposed an algorithm which is applicable to a wide class of distance transforms. The class contains almost all kinds of distance transforms for image processing operations.
For parallel computation, some algorithms are proposed. Schwarzkopf [16] proposed an O time algorithm for the city block distance transform and an O time algorithm for the chessboard distance transform on the mesh of trees with n2 processors. Lee and Horng [11] proposed a chessboard distance transform algorithm. The algorithm runs in O time using O processors on the EREW PRAM, in O time using O processors on the CRCW PRAM and in O time on an O(n2) processor hypercube.
Lee and Horng also showed in [10] that computation of the chessboard distance transform is interchangeable with computation of the medial axis transform. For the medial axis transform, Fujiwara et al. [6] proposed an efficient parallel algorithm. By using the algorithm, the chessboard distance transform can be computed in O time using processors on the EREW PRAM, in O time using processors on the common CRCW PRAM, in O(n2/p2+n) time on a p×p mesh and in O time on a p2 processor hypercube (for 1⩽p⩽n).
Some algorithms are also proposed for real machines. Paglieroni [13] proposed a unified distance transform algorithm and its architecture. Embrechts and Roose proposed two algorithms, one is for the city block distance transform [4] and the other is for the chamfer3-4 distance transform [5]. They implemented their algorithms on a parallel computer iPSC/2.
In this paper, we present a parallel algorithm for the weighted distance transform. The weighted distance is a generalization of the above mentioned distances, such as city block, chessboard and chamfer distances, which are approximations to the Euclidean distance. Complexities of our algorithm are,
- •
O time, processors (EREW PRAM),
- •
O time, processors (common CRCW PRAM),
- •
O(n2/p2+n) time, p2 processors (mesh),
- •
O time, p2 processors (hypercube),
The cost of a parallel algorithm is defined as the product of the running time and the number of processors of the algorithm. A parallel algorithm is called cost optimal if its cost is equal to a lower bound of sequential time for the problem. Also a parallel algorithm is called time optimal if its running time is the best possible time complexity using a polynomial number of processors. Finding a cost and/or time optimal parallel algorithm is an important objective in parallel computation research. Our algorithm is apparently cost optimal on the PRAMs, on the mesh (for ) and on the hypercube (for ). Also we obtained an lower bound for the time complexity of the transform on the CREW PRAM. This implies that the algorithm is time optimal on the EREW PRAM.
Our algorithm is also applicable to the nearest feature transform [12] with the same complexities. The nearest feature transform is an operation which computes, for each pixel, the coordinates of the nearest black pixel. From the result of the nearest feature transform, we can easily solve the nearest neighbor problem and the Voronoi diagram problem in binary images. Our algorithm first computes the nearest feature transform of an input image, and then computes the distance transform. Note that most of the known algorithms for computing distance transforms cannot be applied to the nearest feature transform.
Our algorithm mainly uses some prefix operations. The chessboard distance transform algorithm proposed by Lee and Horng [11] uses a similar method based on the prefix operations. While their algorithm uses only diagonal prefix operations, ours uses horizontal and diagonal prefix operations. As a result of this difference, our algorithm has the following advantages over theirs.
- 1.
Our algorithm can apply to a wider class of distance functions: the weighted distance is a generalization of the many distances. On the other hand, their algorithm can apply only to the distance transform based on chessboard distance.
- 2.
Our algorithm computes the nearest feature transform as well as the distance transform, but their algorithm cannot compute it.
- 3.
Our algorithm needs smaller space: their algorithm needs four times as much space as ours.
Section snippets
Weighted distance, distance transform and nearest feature transform
Given an n×n image I, let I[i,j]∈{0,1} denote a value for a pixel (i,j) of I (0⩽i⩽n−1,0⩽j⩽n−1), where i (resp. j) stands for the row (resp. column) index. We assume the pixel (0,0) is on the top left corner of the image. For clarity of description, we call a pixel (i,j) a black pixel if I[i,j]=1, otherwise we call the pixel a white pixel.
The weighted distance dw(p1,p2), between a pixel p1=(i1,j1) and p2=(i2,j2), is defined by the following expression,
Basic idea
First we introduce a basic idea of our algorithm.
To compute the weighted distance transform and the nearest black pixel easily, we divide an input image into four sets of pixels for each pixel (i,j), which are PN(i,j), PS(i,j), PE(i,j) and PW(i,j). These four sets are given by
Complexities of the algorithm
By applying the algorithm which computes NFTE to NFTN, NFTS and NFTW, we can compute the weighted distance transform and the nearest feature transform. If we use the algorithm directly, eight diagonal prefix minima and four horizontal or vertical prefix minima operations are needed. However, by reusing the results of the diagonal prefix operations, we can compute the transforms using four diagonal prefix minima and four horizontal or vertical prefix minima operations.
For asymptotical
Conclusion
In this paper, we presented a parallel algorithm for computing the weighted distance transform. The algorithm can also be applied to the nearest feature transform. The algorithm runs in O time using processors on the EREW PRAM and in O time using processors on the common CRCW PRAM. We also showed that the algorithm runs in O(n2/p2+n) time on a p×p mesh and in O time on a p2 processor hypercube (for 1⩽p⩽n). Consequently the algorithm is cost
References (16)
- et al.
Optimal doubly logarithmic parallel algorithms based on finding all nearest smaller values
Journal of Algorithms
(1993) Distance transformations in arbitrary dimensions
Computer Vision, Graphics and Image Processing
(1984)- et al.
MIMD divide-and-conquer algorithms for the distance transformation. Part I: City block distance
Parallel computing
(1995) A unified linear-time algorithm for computing distance maps
Information Processing Letters
(1996)Distance transforms: properties and machine vision applications
CVGIP: Graphical Models and Image Processing
(1992)- et al.
Upper and lower bounds for parallel random access machines without simultaneous writes
SIAM Journal on Computing
(1986) - et al.
MIMD divide-and-conquer algorithms for the distance transformation. Part II: Chamfer3–4 distance
Parallel computing
(1995) - A. Fujiwara, M. Inoue, T. Masuzawa, H. Fujiwara. A simple parallel algorithm for the medial axis transform of binary...
Cited by (4)
A novel O (1) time algorithm for 3D block-based medial axis transform by peeling corner shells
2009, Parallel ComputingCitation Excerpt :Similar to the BB_MAT problem, although the computation of the CDT problem has been studied both in the sequential and parallel domains [6,12,25], almost all proposed approaches are dedicated to solving the 2D_CDT problem only and are very difficult to extend to a solution of the 3D_CDT problem.
An approach to generate spatial Voronoi Treemaps for points, lines, and polygons
2015, Journal of Electrical and Computer EngineeringParallel algorithms for the weighted distance transform on linear arrays with a reconfigurable pipelined bus system
2009, Lecture Notes in Computer Science (including subseries Lecture Notes in Artificial Intelligence and Lecture Notes in Bioinformatics)A parallel algorithm for medial axis transformation
2003, Lecture Notes in Computer Science (including subseries Lecture Notes in Artificial Intelligence and Lecture Notes in Bioinformatics)