Keywords

1 Introduction

Point Pattern Matching (PPM) is a fundamental approach for the task of finding correspondences within two arbitrary sets of points [1,2,3,4]. The Hausdorff Distance (HD) has often been used for PPM or the similarity between two sets of points in various fields of application, such as object matching, recognition tasks, trajectory matching, and evaluation of medical image segmentation. Furthermore enhanced methods, such as Partial Hausdorff Distance (PHD) and Modified Hausdorff Distance (MHD) have also exhibited good performances [5,6,7,8,9,10,11,12]. Efficient computational algorithms for an accurate and fast HD have been proposed [13,14,15]. However, MHD still has the weakness that the computation cost increases dramatically as the number of feature points or the increase of data sets.

In this paper, we propose the Multi-Hilbert Scanning Distance (MHSD), which is a novel distance measure based on Hilbert scans. The novel approach of distance measurement for a pattern point matching is introduced by using features of Hilbert scans. The Hilbert scan has some important features that can be utilized for point pattern matching [16, 17]; for example, the Hilbert scan is capable of preserving the coherence between pixels and a one-to-one mapping function between 2-Dimensional (2-D) space and 1-Dimensional (1-D) space. This enables the algorithm to be simplified, speeding up the computation. MHSD is made up of a combination of four directional Hilbert scans and diagonally shifted scans. It computes the minimum value among distances for the nearest point which are obtained by each Hilbert scan. To retain the fast computation time, MHSD utilizes two types of look-up tables which are generated in advance: coordinate loop-up tables and address loop-up tables. As a result, MHSD can have a much lower computation cost than that of the modified Hausdorff distance and shows good performance for matching tasks. In the study, we do not discuss alignment strategies between point sets. Thus, the proposed method is focused on a distance measurement for the point pattern matching between coarsely aligned point sets.

Fig. 1.
figure 1

Hilbert scans with Hilbert orders and scanning directions. (a) Hilbert scans according to the change of a Hilbert order. (b) Hilbert scans according to the scanning directions(\(\alpha \)-scan, \(\beta \)-scan, \(\gamma \)-scan, and \(\delta \)-scan).

2 Multi-Hilbert Scanning Distance

2.1 Hilbert Scan

The order r of a Hilbert scan is an important parameter for determining the scanning resolution or the size of the Hilbert curve. When the Hilbert order is r, the scanning resolution is \(2^r\times 2^r\) in 2-D space \(R^2\). Figure 1(a) shows Hilbert scans according to a change in the Hilbert order r: \(1^{st}\), \(2^{nd}\), and \(3^{rd}\). It also shows the change in the image resolution: \(2\times 2\), \(4\times 4\), and \(8\times 8\). There are four types of Hilbert scans according to the scanning directions. Figure 1(b) shows the four directional Hilbert scans when the Hilbert order is 2. In this study, \(\alpha \)-scan, \(\beta \)-scan, \(\gamma \)-scan, and \(\delta \)-scan are named according to the scanning directions.

Fig. 2.
figure 2

Distance measurements by Hausdorff distance and Hilbert scan on an image with two point sets P(\(\bullet \)) and Q(\(\blacktriangle \)).

Figure 2 shows distance measurements by the modified Hausdorff distance and a single Hilbert scan on an image including point sets \(P(\bullet )\) and \(Q(\blacktriangle )\). The modified Hausdorff distance measures distances between all q and \(p_2\) for searching the nearest point of \(p_2\). However, the single Hilbert scan only needs to measure distances of front and back two neighborhood points for searching the nearest point of \(p_2\) in the 1-D sequence. But, the single Hilbert scan can not always guarantee a good performance of a PPM task, because it often misses the nearest point in 2-D space. In the next Section, details on how to measure distance using Hilbert scans will be stated.

2.2 Definition of Multi-Hilbert Scanning Distance

A basic concept of distance measurements by \(\alpha \)-scan and diagonally 1-shifted \(\beta \)-scan is presented in Fig. 3. In \(\alpha \)-scan, if the nearest point \(q \in Q\) of point \(p_4\) is measured, it selects point \(q_6\) that is closest to \(p_4\) on the 1-D sequence obtained by \(\alpha \)-scan. The distance between \(p_4\) and \(q_6\) is 21 on the 1-D sequence. However, the nearest point q of \(p_4\) in 2-D space is actually point \(q_3\). In the diagonally 1-shifted \(\beta \)-scan, if the nearest point search of point \(p_4\) is performed, the nearest point will be \(q_3\), which is the closest point to \(p_4\) on the 1-D sequence obtained by the diagonally 1-shifted \(\beta \)-scan. The distance between \(p_4\) and \(q_3\) by the diagonally 1-shifted \(\beta \)-scan is 1 on the 1-D sequence.

Here, we introduce Multi-Hilbert Scans (MHS) to overcome the drawbacks of a single Hilbert scan, which consists of a combination of four directional Hilbert scans and diagonally shifted Hilbert scans. MHS is defined as follows:

$$\begin{aligned} MHS_{K} = \{hs^{\alpha ,0}, hs^{\beta ,1}, hs^{\gamma ,2}, hs^{\delta ,3}, \cdots , hs^{s,k}, \cdots , hs^{s,K-1}\}, \end{aligned}$$
(1)
$$ s= {\left\{ \begin{array}{ll} \alpha , &{}\text{ if } (k~\text {mod}~4) = 0 \\ \beta , &{}\text{ if } (k~\text {mod}~4) = 1 \\ \gamma , &{}\text{ if } (k~\text {mod}~4) = 2 \\ \delta , &{}\text{ if } (k~\text {mod}~4) = 3 \end{array}\right. } $$

where K is the number of Hilbert scans, k denotes the shift length of the Hilbert scan, and \(0\le k \le K-1\). For example, \(hs^{\alpha ,0}\), \(hs^{\beta ,1}\), \(hs^{\gamma ,2}\), and \(hs^{\delta ,3}\) denote \(\alpha \)-scan, diagonally 1-shifted \(\beta \)-scan, diagonally 2-shifted \(\gamma \)-scan, diagonally 3-shifted \(\delta \)-scan, respectively. To measure distances by using Hilbert scan, two point sets P and Q are converted into the new point sets U (\(U = \{u_0, u_1, \cdots , u_{M-1}\}\), \(\forall u \in \mathbb {Z}\)) and V (\(V = \{v_0, v_1, \cdots , v_{N-1}\}\), \(\forall v \in \mathbb {Z}\)), where u and v denote the addresses of points on Hilbert curve. Thus, the new point sets \(U^{s,k}\) and \(V^{s,k}\) generated from \(hs^{s,k}\) are defined as follows:

$$\begin{aligned} U^{s,k} = \{u^{s,k}_0, u^{s,k}_1, \cdots , u^{s,k}_{M-1}\}, \end{aligned}$$
(2)
$$\begin{aligned} V^{s,k} = \{v^{s,k}_0, v^{s,k}_1, \cdots , v^{s,k}_{N-1}\}, \end{aligned}$$
(3)

where \(u^{s,k}\) and \(v^{s,k}\) denote the addresses of points on \(hs^{s,k}\). According to our statistical analysis, this paper recommends that K has 4: \(MHS_{4} = \{hs^{\alpha ,0}, hs^{\beta ,1}, hs^{\gamma ,2},\) \(hs^{\delta ,3}\}\). The analysis for the combinations of Hilbert scans will be discussed in Sect. 4.1.

Fig. 3.
figure 3

Distance measurements by single Hilbert scan (\(k=0\)) and diagonally 1-sifted Hilbert scan (\(k=1\)).

Fig. 4.
figure 4

Distance measurement using \(MHS_{4}\) on an image with two point sets P and Q.

To measure distance by using \(MHS_{4}\), we will introduce Multi-Hilbert Scanning Distance. Two point sets P and Q are converted into two new sets \(U = \{U^{\alpha ,0}, U^{\beta ,1}, U^{\gamma ,2},\) \(U^{\delta ,3}\}\) and \(V = \{V^{\alpha ,0}, V^{\beta ,1}, V^{\gamma ,2}, V^{\delta ,3}\}\) by the \(MHS_{4}\), respectively. The distance measurement for all u between \(U^{s,k}\) and \(V^{s,k}\) is defined as follows:

$$\begin{aligned} d(U^{s,k}, V^{s,k}) = \min (\parallel u_i^{s,k} - v_t^{s,k} \parallel , \parallel u_i^{s,k} - v_{t+1}^{s,k} \parallel ), \end{aligned}$$
(4)

where \(\parallel \cdot \parallel \) is the Euclidean norm distance in 1-D space and \(0\le i \le M-1\). \(v_t\) and \(v_{t+1}\) are front and back neighbor points of \(u_i\) on \(hs^{s,k}\). The directed MHSD from P to Q is defined as following:

$$\begin{aligned} mhsd(P,Q) = \frac{1}{M}\sum \limits _{u \in U}\min _{v \in V}(d(U^{s,k}, V^{s,k})), \end{aligned}$$
(5)

where M is the size of the point set P and \(0\le k \le 3\) for \(MHS_{4}\). The directed MHSD from Q to P can be computed similarly. MHSD is defined as following:

$$\begin{aligned} MHSD(P,Q) = \max (mhsd(P,Q), mhsd(Q,P)). \end{aligned}$$
(6)

Figure 4 illustrates distance measurement for \(p_1\) using \(MHS_4\) on an 32\(\times \)32 image. First, two point sets P and Q are converted into the 1-D sequences by \(MHS_4\). Then, \(d(p_1^{s,k},Q^{s,k})\) on the each 1-D sequence is calculated by Eq. 4. Lastly, the distance between \(p_1\) and Q is determined by minimum value of distances calculated by \(d(p_1^{s,k},Q^{s,k})\). The distances of the other points can be obtained using the same computation.

figure a

3 Efficient Computation of MHSD

In this study, two kinds of look-up tables are prepared and are called a coordinate look-up table and an address look-up table. The coordinate look-up tables are generated in advance according to the types of Hilbert scans in MHS and are defined as follows:

$$\begin{aligned} crd\_LUT^{s,k}[i] = (x, y), \end{aligned}$$
(7)

where (sk) denotes types of Hilbert scans in MHS, i is an address on 1-D point sequence of \(h^{s,k}\), and (xy) is a Cartesian coordinate on an image. If the coordinate look-up table of \(hs^{\alpha ,0}\) is generated by constructing Hilbert curve [16], the coordinate look-up tables of the other \(hs^{s,k}\) can be easily obtained by using transformation rules. If the coordinate look-up table of \(hs^{\alpha ,0}\) is \(crd\_LUT^{\alpha ,0}[i]\) (\(crd\_LUT^{\alpha ,0}[i] = (x^{\alpha }_{i}, y^{\alpha }_{i}))\), the other coordinate look-up tables are formulated as follows:

$$\begin{aligned}&crd\_LUT^{\alpha ,k}[i]=(x^{\alpha }_{i}+k, y^{\alpha }_{i}+k),\end{aligned}$$
(8)
$$\begin{aligned}&crd\_LUT^{\beta ,k}[i]=(y^{\alpha }_{i}+k, x^{\alpha }_{i}+k),\end{aligned}$$
(9)
$$\begin{aligned}&crd\_LUT^{\gamma ,k}[i]=(N-x^{\alpha }_{i}+k,N-y^{\alpha }_{i}+k)\end{aligned}$$
(10)
$$\begin{aligned}&crd\_LUT^{\delta ,k}[i]=(N-y^{\alpha }_{i}+k,N-x^{\alpha }_{i}+k) \end{aligned}$$
(11)

where \(N = 2^r\) and r is the Hilbert order for scanning an image. The address look-up tables are generated in advance by using the coordinate look-up tables and are defined as follows:

$$\begin{aligned} addr\_LUT^{s,k}[x, y] = i. \end{aligned}$$
(12)

Thus, for \(MHS_{4}\), \(addr\_LUT^{\alpha ,0}\), \(addr\_LUT^{\beta ,1}\), \(addr\_LUT^{\gamma ,2}\), and \(addr\_LUT^{\delta ,3}\) are generated in advance by using \(crd\_LUT^{\alpha ,0}\), \(crd\_LUT^{\beta ,1}\), \(crd\_LUT^{\gamma ,2}\), and \(crd\_LUT^{\delta ,3}\), respectively.

figure b

The computation of mhsd(P, Q) using \(MHS_{4}\) is summarized as the following steps:

  • Step 1. Convert the point set P to 1-D sequences \(U (U = \{U^{\alpha ,0}, U^{\beta ,1}, U^{\gamma ,2}, U^{\delta ,3}\})\) by using Eq. 12, and do the same process for 1-D sequences \(V (V = \{V^{\alpha ,0}, V^{\beta ,1}\), \(V^{\gamma ,2}, V^{\delta ,3}\})\) with the point set Q.

  • Step 2. Compute minimum distances of all \(p (p \in P)\) on \(hs^{\alpha ,0}\) with \(U^{\alpha ,0}\) and \(V^{\alpha ,0}\) by Eq. 4. The pseudo code for this step is presented in Algorithm 1.

  • Step 3. Repeat Step 2 with (\(U^{\beta ,1}\) and \(V^{\beta ,1}\)), (\(U^{\gamma ,2}\) and \(V^{\gamma ,2}\)), and (\(U^{\delta ,3}\) and \(V^{\delta ,3}\)).

  • Step 4. Compute the minimum among minimum distances obtained from \(MHS_{4}\) for a point \(p (p \in P)\). The minimum distance is computed by using address loop-tables and coordinate loop-tables.

  • Step 5. Repeat Step 4 until all p have been processed. The pseudo code for Step 4 and 5 is presented in Algorithm 2.

  • Step 6. Obtain mhsd(PQ) by calculating the mean value of minimum distances of all p.

The process of computing mhsd(QP) is the same as the above steps. Finally, MHSD is obtained by choosing the larger one of mhsd(PQ) and mhsd(QP).

Fig. 5.
figure 5

Statistical analysis of scanning length for some combined Hilbert scans and the proposed MHSD. (a) \(A-scan\) (\(hs^{\alpha ,0}\)), (b) \(B-scann\) (\(hs^{\alpha ,0}\) and \(hs^{\beta ,0}\)), (c) \(C-scan\) (\(hs^{\alpha ,0}\), \(hs^{\beta ,0}\), \(hs^{\gamma ,0}\), and \(hs^{\delta ,0}\)), (d) \(D-scan\) (\(hs^{\alpha ,0}\), \(hs^{\alpha ,1}\), \(hs^{\beta ,1}\), \(hs^{\gamma ,1}\), and \(hs^{\delta ,1}\)), (e) \(E-scan\) (\(hs^{\alpha ,0}\), \(hs^{\beta ,0}\), \(hs^{\gamma ,0}\), \(hs^{\delta ,0}\), \(hs^{\alpha ,1}\), \(hs^{\beta ,1}\), \(hs^{\gamma ,1}\), and \(hs^{\delta ,1}\)), and (f) the proposed Hilbert scans.

4 Experimental Results

4.1 Statistical Analysis for MHSD

In this Section, we present a statistical analysis of the proposed method and some combined Hilbert scans by using a statistical method [18]. The statistical method analyzes the proportional property of a square Euclidean distance \(d = (b_x-a_x)^2+ (b_y-a_y)^2\) and a scanning length \(l (l \in [0, R_x \times R_y])\) between the two points \(a (a_{x}, a_{y})\) and \(b (b_{x}, b_{y})\), where \(R_x \times R_y\) is the size of an image. Other scanning methods are combined for the statistical analysis, which are a single Hilbert scan, two Hilbert scans, four Hilbert scans, a single Hilbert scan and four diagonally shifted Hilbert scans, and four Hilbert scans and four diagonally shifted Hilbert scans. Figure 5 shows the relation between the average scanning length and the square Euclidean distance corresponding to two points. In Fig. 5(a), (b), and (c), the scanning length l fluctuates over a wide range when \(d > 25\). Figure 5(a) and (b) have the scanning length greater than 1 when \(d = 1\). However, Fig. 5(f) has a small fluctuation and the square Euclidean distance is proportional to l.

Fig. 6.
figure 6

Vehicles image and edge images with different noise levels. All noisy images were made by imnoise function in Matlab. (a) Real model of a single vehicle. (b) Edge image of (a). (c) Real image of some similar vehicles. (d) Edge image of (c). (e) Edge image of (c) with Gaussian noise (\(\sigma \) = 0.02, \(\sigma \) means the variance). (f) Edge image of (c) with Poisson noise. (g) Edge image of (c) with salt&pepper noise (d=0.2, d is the noise density). (h) Edge image of (c) with Multiplicative noise (v=0.2, v means the variance).

Fig. 7.
figure 7

Samples of vehicle model images in a data-set and edge images of the vehicle models.

4.2 Evaluation of MHSD on Vehicle Images

The proposed approach was tested with vehicle model images. Firstly, we tested the ability of MHSD to find a vehicle model in an image including many vehicles. Generally, a vehicle model image is smaller than an image including many vehicles. Thus, the directed distance measure from a model to an image is performed by translating the model on the fixed image. The minimum value of any distance measure under translation can be computed as follows [19].

$$\begin{aligned} M_{\varPsi }(A, B)=\min _{\psi }h(A,B\oplus \psi ) \end{aligned}$$
(13)

where h is any distance measure such as HD, PHD, MHD, single Hilbert scan (SHS) or MHSD, and \(\oplus \) is the standard Minkowski sum notation(i.e., \(B\oplus \psi ={b+\psi |b\in B}\)). The test sets in Fig. 6 are a vehicle model (\(128 \times 128\) size) and an image (\(512 \times 256\) size) including some similar vehicles. The proposed method was compared with HD, PHD (80\(\%^{th}\) ranked value), Single Hilbert Scan (SHS), and MHD on edge images. Figures 6(a)-(d) show the original images and the binary edge images obtained by Meer [21], and (e)-(h) are the edge images of noisy images adding Gaussian, Poisson, salt&pepper, and Multiplicative noise [20] to Fig. 6(c), respectively. The best matching position of the vehicle model is (20, 111) here. In practice, the best matching position was obtained using graphics tool. Table 1 shows the matching results. The matching position can be evaluated using the Euclidean distance between the best matching positions. The smaller this distance is, the better the distance measure is. From Table 1, the Euclidean distances between the best matching and the HD results are 0, 312, 11, 185, and 200 for (d)-(h), respectively. This shows that HD matching suffers with noisy images. MHD showed good matching results. However, MHSD presented the best matching results for all images.

Table 1. Position results of experiment shown in Fig. 6

Secondly, the proposed method was tested by using the real vehicle model images (in Fig. 7). In this study, 40 real vehicles were involved and 200 images were acquired for the experiment. In Fig. 7(f)-(j), the edge images were obtained by applying the edge detection algorithm of Meer [21] and the image size is \(512 \times 512\) pixels. The proposed method was compared with HD, PHD (80\(\%^{th}\) ranked value), SHS, and MHD on edge images of vehicle models. To evaluate the performance of the proposed method, top-rank order and Bulls-eye statistics were used. Bulls-eye test counts how many of the 5 possible correct matches are presented in the top 10 nearest objects.

Table 2. Comparison of recognition rate (%)
Table 3. Comparison of running time (sec)

Table 2 shows the recognition results by the proposed method and the compared methods. MHD exhibit better performances than HD, PHD, and single Hilbert scan. Nevertheless, the proposed method outperforms the compared methods. For evaluating the computation cost, the proposed method was compared with the NAIVE MHD and the MHD using KD-Tree with samples of vehicle edge images. Table 3 shows that the running time of the proposed method is less than that of the MHD using KD-Tree. The running time of the MHSD algorithm in Table 3 includes the times of converting into 1-D sequences U and V. If the 1-D sequences U and V of point sets are registered in advance and distance measurement is performed with those, MHSD can have a much lower computational cost. These experiments demonstrate that the proposed algorithm outperforms the compared algorithms.

5 Conclusion

In this study, we propose a multi-Hilbert scanning distance which is a distance measurement for fast and accurate point pattern matching and object recognition. MHSD measures distance using five 1-D point sequences from multi-Hilbert scanning and has two types of look-up tables to lower the computation cost. Evaluation of MHSD was performed using vehicle images. MHSD was compared with other distance measures, such as HD, PHD, SHS, MHD. MHSD showed good performance in terms of matching accuracy and computation cost. Experimental results demonstrate the possibility of the distance measurement for fast and accurate point pattern matching. The future works will aim at applying efficient alignment strategies and extending the application fields.