Elsevier

Parallel Computing

Volume 25, Issue 4, April 1999, Pages 405-416
Parallel Computing

A cost optimal parallel algorithm for weighted distance transforms

https://doi.org/10.1016/S0167-8191(99)00006-XGet rights and content

Abstract

The distance transform and the nearest feature transform are useful operations in image processing. These transforms are based on various kinds of distance functions because the distance functions have different efficiency or usefulness. In this paper, we consider these transforms based on the weighted distance, which is a generalization of many distances, such as city block, chessboard and chamfer distances. This paper presents a parallel algorithm for these transforms of an n×n binary image. The algorithm runs in O(logn) time using n2/logn processors on the EREW PRAM and in O(loglogn) time using n2/loglogn processors on the common CRCW PRAM. The algorithm also runs in O(n2/p2+n) time on a p×p mesh and in O(n2/p2+(nlogp)/p) time on a p2 processor hypercube (for 1⩽pn). From these complexities, the algorithm is cost optimal on all models. Also we obtained an Ω(logn) lower bound for the transform on the CREW PRAM. This implies that the algorithm is time optimal on the EREW PRAM.

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(logn) time algorithm for the city block distance transform and an O(log2n) 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(logn) time using O(n2/logn) processors on the EREW PRAM, in O(logn/loglogn) time using O(n2loglogn/logn) processors on the CRCW PRAM and in O(logn) 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(logn) time using n2/logn processors on the EREW PRAM, in O(loglogn) time using n2/loglogn processors on the common CRCW PRAM, in O(n2/p2+n) time on a p×p mesh and in O(n2/p2+(nlogp)/p) time on a p2 processor hypercube (for 1⩽pn).

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(logn) time, n2/logn processors (EREW PRAM),

  • O(loglogn) time, n2/loglogn processors (common CRCW PRAM),

  • O(n2/p2+n) time, p2 processors (mesh),

  • O(n2/p2+(nlogp)/p) time, p2 processors (hypercube),

where 1⩽pn.

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 1⩽p⩽n) and on the hypercube (for 1⩽p⩽n/logn). Also we obtained an Ω(logn) 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.

This paper is organized as follows. In Section 2, we give definitions and models of parallel computation. In Section 3, we describe our algorithm, and in Section 4, we discuss complexities of the algorithm for each model. We conclude this paper in Section 5.

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⩽in−1,0⩽jn−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,dw(p1,p2)=w0|i1−i2|+w1|j1−j2|if|i1−i2|⩾|j1−j2

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 byPN(i,j)={(i−g,j+h)|0⩽g⩽i,max{−j,−g}⩽h⩽min{n−1−j,g}},PS(i,j)={(i+g,j+h)|0⩽g⩽n−1−i,max{−j,−g}⩽h⩽min{n−1−j,g}},PE(i,j)={(i+g,j+h)|max{−i,−h}⩽g⩽min{n−1−i,h},0⩽h⩽n−1−j}},PW(i,j)={(i+g,j−h)|max{−i,−h}⩽g⩽min{n−1−i,h},0⩽h⩽j}}.

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(logn) time using n2/logn processors on the EREW PRAM and in O(loglogn) time using n2/loglogn 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(n2/p2+(nlogp)/p) time on a p2 processor hypercube (for 1⩽pn). Consequently the algorithm is cost

References (16)

There are more references available in the full text version of this article.

Cited by (4)

  • A novel O (1) time algorithm for 3D block-based medial axis transform by peeling corner shells

    2009, Parallel Computing
    Citation 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.

  • Parallel 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)
View full text