Keywords

1 Introduction

A shape signature is any one-dimensional function which represents a two-dimensional shape. Several versions are proposed in the literature, such as centroid distance, centroidal profile, complex coordinates, tangent angle, cumulative angle; overviews of shape descriptors can be found in [3, 10]. Among them, signature based on centroid distance is popular due to its simple and intuitive definition, as well as its suitability for further processing and, e.g., derivation of Fourier or wavelet descriptors of the shape. As a boundary based descriptor, however, centroid distance signature suffers from noise sensitivity. Additionally, the signature of a discrete shape representation is often altered by translation and/or rotation of a shape, which is an undesired property of a shape descriptor.

We suggest, in this paper, to improve accuracy and precision (i.e., reduce bias and variance) of the centroid distance signature by computing it from a pixel coverage representation of the shape [7, 8], instead of following the traditional approach and utilize a crisp shape representation. Previous results on shape representation based on coverage of pixels by the imaged object have confirmed that such an information rich representation may be utilized to increase accuracy and precision of several shape descriptors, compared to binary (crisp) approaches [6, 7]. In a coverage representation every pixel is assigned an intensity value proportional to the relative coverage of the pixel by the imaged shape. This intensity value can be utilized to determine sub-pixel position of the shape boundary, which can then be used to produce more precise and accurate shape signature. In this paper, we propose a novel method for estimating the shape signature of a starshaped object utilizing a coverage representation of the shape. We present an algorithm which iteratively improves accuracy of the computed signature, alternating between estimation of boundary position and shape normal direction. Evaluation results confirm a number of advantages of the proposed approach. The signature derived for a coverage representation is computed by a simple and fast procedure, and exhibits increased accuracy and precision, and invariance to rotation and translation, as well as decreased sensitivity to noise, compared to previously used crisp approach.

2 Background

Usually, an object is extracted from an image by crisp segmentation, providing a crisp representation of the shape, such that each pixel is either completely included, or completely excluded, in/from it. This process is associated with a loss of information about the original shape. Shape descriptors are then computed utilizing this crisp representation. The reduced amount of information preserved in the crisp representation reduces the descriptors’ accuracy and precision, as well as their invariance under translation and rotation. One way to improve performance of shape descriptors is to compute them from a coverage representation of the shape. Advantages of such an approach, compared to utilizing a crisp representation, are observed in, e.g., [2, 6, 7]. These results motivated our work on development of an estimator for centroid distance shape signature which utilizes coverage representation of the shape. Before presenting the algorithm for signature computation in Sect. 3, and showing the results of its evaluation in Sect. 4, we introduce the main concepts and notions we utilize.

2.1 Fuzzy Set Theory

Fuzzy set theory is a generalization of the classical (crisp) set theory, allowing partial belongingness of elements of some reference set to a fuzzy set.

Definition 1

[9] A fuzzy subset S of a reference set X is a set of ordered pairs \(S=\lbrace (x,\mu _S(x))\ |\ x\in X \rbrace ,\) where \(\mu _S:X \rightarrow [0,1]\) is the membership function of S in X.

A crisp set is a special case of a fuzzy set and its characteristic function, allowing only values \(\{0,1\}\), is a special case of a fuzzy membership function.

Important notions related to fuzzy set are those of \(\alpha \)-cut and support:

Definition 2

[9] For \(\alpha \in (0,1],\) the \(\alpha -\)cut of S,  defined by \(\mu _S,\) is the crisp set \(S_{\alpha }=\lbrace x \in S \ |\ \mu _S(x) \ge \alpha \rbrace .\)

Definition 3

[9] The support of a fuzzy set S is the crisp set \(Supp(S)=\lbrace x \in X \ |\ \mu _S(x) > 0 \rbrace .\)

Definition 4

For a fuzzy set \(S=\lbrace ((x,y),\mu (x,y))\ |\ (x,y)\in X \rbrace ,\) defined on a discrete reference set \(X \subset R^2\), the coordinates of its centroid \((x_c,y_c)\) are

$$\begin{aligned} x_c=\frac{\sum _x \sum _y x \cdot \mu (x,y)}{\sum _x \sum _y \mu (x,y)}, \qquad y_c=\frac{\sum _x \sum _y y\cdot \mu (x,y)}{\sum _x \sum _y \mu (x,y)}. \end{aligned}$$

Definition 4 can be used to compute the centroid of a crisp shape as well, utilizing the characteristic function of the crisp shape as its membership function.

2.2 Shape Signature

The centroid distance signature of a continuous shape is a continuous function which assigns distance from the shape centroid to every point on the continuous shape boundary, parametrized in some appropriate way. For a starshaped object, it holds that every straight half-line starting from the centroid intersects the boundary of the shape in exactly one point; therefore there exists a one-to-one mapping from the interval \([0,2\pi )\) of angles to the set of boundary points, which we use for parametrization.

Definition 5

The signature of a continuous starshaped object S is a continuous function \(r(\theta )\) which assigns the length of the vector determined by the shape centroid \((x_c,y_c)\) and the boundary point \((x(\theta ), y(\theta ))\), to every angle \(\theta \in [0,2\pi )\), where \(\theta = \arctan \left( \frac{y(\theta )-y_c}{x(\theta )-x_c}\right) \):

$$\begin{aligned} r(\theta ) = \sqrt{(x(\theta )-x_c)^2+(y(\theta )-y_c)^2}. \end{aligned}$$
(1)

Throughout the paper we assume that \(\arctan \left( \frac{y}{x}\right) \) computes the four-quadrant inverse tangent, appropriately handling the case \(x=0\) and providing an output in the range \([0,2\pi )\).

The signature of a discrete representation of a continuous shape is a restriction of the continuous shape signature to some appropriate sample values \(\theta _i\) of the interval \([0,2\pi )\). The sample values \(\theta _i\) can be determined beforehand, or be derived as a part of the process of signature computation. Often used sample points/angles are those of a 4-connected, or an 8-connected boundary.

Definition 6

The signature of a discrete representation of a (continuous) starshaped object S is a collection of pairs \((r(\theta _i),\theta _i)\), where \(r(\theta _i)\) assigns the length of the vector determined by the shape centroid \((x_c,y_c)\) and the boundary point \((x(\theta _i), y(\theta _i))\), to a set of values \(\theta _i \in [0,2\pi )\):

$$\begin{aligned} r(\theta _i) = \sqrt{(x(\theta _i)-x_c)^2+(y(\theta _i)-y_c)^2}, \qquad i=1,2,\dots , N. \end{aligned}$$
(2)

In absence of any information about the boundary location within a pixel, the centre point of the pixel is a reasonable sample point. It is, however, rather unlikely that the centre of a pixel belongs to the boundary of the continuous object, which introduces errors in computation of the signature, and leads to translation and rotation variance of this descriptor.

An approach to compute the signature of a fuzzy shape representation, and by that reduce negative effects of crisp segmentation, is proposed in [1]. Following one of the main fuzzification principles, the signature of a fuzzy shape is computed as the average of the signatures of all its \(\alpha \)-cuts. This approach is shown to outperform crisp approach in terms of achieved precision of the estimator. Bias of the estimator is not addressed/corrected, which affects its accuracy.

2.3 Coverage Model

Let the Voronoi region in \(\mathbb {R} ^2\) of a grid point \(\varvec{x} \in \mathbb {Z} ^2\), i.e., a pixel, be denoted by \(\sigma (\varvec{x})\). Coverage digitization in \(\mathbb {R} ^2\) is defined in [8] as:

Definition 7

For a given continuous object \(S \subset \mathbb {R} ^2,\) inscribed into an integer grid \(\mathbb {Z} ^2,\) the pixel coverage digitization of S is

$$\begin{aligned} \mathcal {D}_{\mathcal {C}}(S)=\Big \lbrace (\varvec{x},a(\varvec{x})) \,\big |\, \varvec{x} \in \mathbb {Z} ^2 \Big \rbrace , \qquad a(\varvec{x})=\frac{|\,\sigma (\varvec{x}) \cap S|}{|\,\sigma (\varvec{x})|}, \end{aligned}$$
(3)

where |S| denotes area of a set S.

For a real image, the pixel coverage values can be estimated by coverage segmentation methods, [4, 5, 7].

Coverage representation of a continuous crisp shape is characterized by pixel values equal to one, for pixels completely covered by the shape, pixel values equal to zero for pixels completely covered by the background, and pixel values strictly between 0 and 1, for partly covered pixels that typically form a one pixel thick discrete shape boundary.

The coverage function a is a particular type of fuzzy membership function, suitable for representation of imaged objects. Definitions and properties derived for (spatial) fuzzy sets are thus directly applicable to the coverage representation.

3 Shape Signature with Sub-pixel Precision

We present a novel approach for estimating shape signature based on a pixel coverage representation of the object. If we approximate the boundary of a shape within a pixel with a straight line segment, we can estimate the edge position with sub-pixel accuracy from the pixel (coverage) value, assuming that we know the edge direction. We can then compute a discrete signature of the shape by selecting a sample point on the estimated edge. Any point on the edge segment is a possible choice. To have a well defined inner point of the pixel, we use the midpoint of the estimated edge as a sample point for the proposed signature computation. Based on the above, we propose the following Pixel Coverage Shape Signature (PCSS), in accordance with Defintion 6.

The pixel coverage signature of a starshaped continuous object S is a set of pairs \((r(\theta _i),\theta _i)\), where \(r(\theta _i)\) assigns the length of the vector given by the shape centroid \((x_c,y_c)\) and the point \((x_\text {mid}(\theta _i), y_\text {mid}(\theta _i))\), to every angle \(\theta _i \in [0,2\pi )\), such that \(\theta _i = \arctan \left( \frac{y_\text {mid}(\theta _i)-y_c}{x_\text {mid}(\theta _i)-x_c}\right) \), where \((x_\text {mid}(\theta _i), y_\text {mid}(\theta _i))\) is the midpoint of the edge in the i-th pixel along the object boundary and

$$\begin{aligned} r(\theta _i) = \sqrt{(x_{\text {mid}}(\theta _i)-x_c)^2+(y_{\text {mid}}(\theta _i)-y_c)^2}, \quad i=1,2,\dots , N. \end{aligned}$$
(4)

3.1 Computation of Midpoint of Edge Segment Within a Pixel

Assuming that the object boundary within a pixel centred at (xy) can be approximated by a straight edge, let us denote the normal direction of the edge by \(\varvec{n}=(\cos \varphi , \sin \varphi )\), and the coverage value of the observed pixel by a.

The coordinates of the midpoint of the edge inside the observed pixel can be expressed as

$$\begin{aligned} \big (x+ e_x(a,\varphi ),\,y+ e_y(a,\varphi )\big )\,, \end{aligned}$$
(5)

where, for angles \(\varphi \in [0,\pi /4]\), it holds that

$$\begin{aligned} \big (e_x(a,\varphi ),e_y(a,\varphi )\big )\!=\!\left\{ \begin{array}{ll} \big (\sqrt{\frac{a\tan \varphi }{2}}-\frac{1}{2},\sqrt{\frac{a}{2\tan \varphi }}-\frac{1}{2}\big ), &{} 0\le a \le \frac{1}{2}\tan \varphi \,,\\[1ex] \big (a-\frac{1}{2},0\big ), &{} \frac{1}{2}\tan \varphi \le a \le 1-\frac{1}{2}\tan \varphi ,\\[1ex] \big (\frac{1}{2}\!-\!\sqrt{\frac{(1-a)\tan \varphi }{2}},\frac{1}{2}\!-\!\sqrt{\frac{1-a}{2\tan \varphi }}\big ), &{}1-\frac{1}{2}\tan \varphi \le a \le 1 \,.\\[1ex] \end{array}\right. \end{aligned}$$
(6)

Due to (anti)symmetry of the above expressions, it is enough to consider values \(0 \le a \le 0.5\) and \(\varphi \in [0,\pi /4]\); other cases can be obtained by changing the sign and/or swapping the coordinates of the computed midpoint.

3.2 Algorithm for Shape Signature Estimation

To compute PCSS using (4) and (5), we need to estimate the normal direction \(\varvec{n}=(\cos \varphi , \sin \varphi )\) of the edge within each boundary pixel. We propose an iterative procedure which utilizes the current signature estimate to derive the normal direction of the edge, and then to improve the signature itself. This method is simple and fast, utilizes only the values of the observed pixel and its two neighbours, and does not require convolution masks for gradient estimation.

An initial signature is computed as a sequence of distances from the shape centroid to midpoints of the edges in each boundary pixel. We consider boundary pixels to be pixels with \(a>0\) which are 8-connected to the pure background pixels, having coverage \(a=0\). For an object without holes, such boundary consists of a thin 4-connected sequence of pixel which is easily detected and indexed. For computation of initial midpoints, normal directions are initialized as \(\varphi _i = \theta _i\).

In each iteration the estimate of the edge position in a pixel is updated by computing the normal of the line connecting the midpoints of the edges in the two boundary pixels neighbouring the observed one. These midpoints are determined based on the signature estimate in the previous iteration. The new edge position (and its new midpoint) is computed using the new normal estimate and the given coverage value. Figure 1 illustrates this process. The procedure terminates when the difference between two consecutive signature estimates stays below a given tolerance, or when some predefined number of iterations is reached.

Fig. 1.
figure 1

(a) Shape signature based on pixel coverage, PCSS, computed to the midpoint of the edge segment of a pixel \((x_i,y_i)\), for coverage \(a_i\) and normal direction \(\varphi _i\). (b) and (c) Illustration of iterative estimation of boundary position (midpoint \(\text {mid}_i=(x_i+e_x(a_i,\varphi _i),y_i+e_y(a_i,\varphi _i))\,\)) and edge normal direction \(\varphi _i\), in two consecutive iterations (k and \(k+1\)) of Algorithm 1, by using estimated midpoints of the edges in two neighbouring boundary pixels.

The complete algorithm is presented below. Each line in the algorithm assumes parallel/vectorized computation for all \(i \in \{1,2,\ldots ,N\}\). Cyclic indexing is assumed when index \(i \pm 1\) reaches the end values of the sequence.

figure a

For poorly resolved non-smooth objects, there may be cases where one boundary pixel is intersected several times by the shape boundary, i.e., where a single straight edge segment poorly models the boundary position. In such cases the above algorithm may produce suboptimal edge position estimates. We therefore adjust utilization of coverage values for edge direction estimation if a pixel is visited more than once while the boundary is traversed. We appropriately split its coverage and utilize it for each of the edge estimates separately. This is conveniently achieved by a simple update of the coverage values to be used by the algorithm, as follows:

figure b

This pre-processing step results in improved boundary estimation at sharp corners, as illustrated in Fig. 2.

Fig. 2.
figure 2

Example showing the need for adjusting coverage of pixels intersected by more than one edge. Pixel A (with coverage 0.52) is intersected twice by the true object boundary (red dashed line), passing pixel B (with a small positive coverage) in between. Without adjustment, both edge midpoints of A would incorrectly be placed very close to the pixel centre. If we instead assume that each intersecting edge cuts away half of the background and utilize a coverage value (for each edge individually) of 0.76, a better result (blue line, the crosses indicate computed edge midpoints) is achieved (Color figure online).

4 Evaluation

We evaluate performance of the proposed method for computation of the signature from a coverage representation of a shape, by comparing it with methods utilizing crisp shape representation, according to Definition 6, and utilizing \(\alpha \)-cuts of a fuzzy representation of the shape, as proposed in [1]. The approaches are denoted by BSS (Binary Shape Signature), ACSS (\(\alpha \)-cut Shape Signature) and PCSS (Pixel Coverage Shape Signature). Our evaluation is focused on accuracy, precision, noise sensitivity, and invariance to translation and rotation.

The observed test objects are disks, 6-cornered stars, and rectangles, for which the true signatures used in comparisons are analytically derived. Crisp shape representations of the observed objects are obtained by Gauss centre point digitization of continuous shapes. The coverage representations of these objects are analytically derived, and therefore exact (to the level of floating point operations). The fuzzy representation considered is the coverage representation, i.e., ACSS and PCSS are applied to the same shape representations. Tolerance used for the exit criterion in Algorithm 1 is set to \(\varepsilon =0.0001\) and maxiter = 100.

Fig. 3.
figure 3

Shape signatures computed by BSS (8-connected boundary observed), ACSS and PCSS for a disk with radius of 66.64 pixels. At this scale, errors of the PCSS method are too small to be visible.

We first show an illustrative example motivating our proposed approach. Figure 3 presents centroid distance signatures estimated by BSS, ACSS, and PCSS, of a disk with radius \(r=66.64\) pixels. Comparing with the true signature of the disk (constant function \(y=66.64\)), we observe very high accuracy and precision of the proposed PCSS method, compared to rather precise, but non-accurate (biased) ACSS, and comparably imprecise and also biased BSS.

The distributions of errors for the different methods are presented in Fig. 4, estimated for a disk and a 6-cornered star, both of a radius \(r=66.64\). Each object is digitized 100 times, at random positions (and rotations) in the grid, and errors are computed relative to the resp. true continuous shape. Both 4- and 8-connected boundaries are considered for BSS, whereas only 8-connected boundary is observed for ACSS (per recommendation in [1]). For PCSS it is most natural to use the 4-connected boundary, which gives more sample points than the 8-connected one. Excellent performance of the proposed PCSS in terms of accuracy is clearly visible and confirmed by the significantly smaller range of errors, compared to the range of errors of both BSS (4- and 8-connected boundary), and ACSS. The biases of BSS and ACSS are also clearly visible.

Fig. 4.
figure 4

Histograms of errors of BSS, ACSS and PCSS applied to a disk (a) and a star (b), of radius of 66.64 pixels. Errors larger than 0.01 pixel are very rare for PCSS.

We further present results of a statistical study of the estimation error, for the three observed signature estimators for objects of increasing sizes. We observe the root-mean-square error \(\text {RMSE}=\sqrt{\frac{1}{N}\sum _{i=1}^{N}(\hat{x}_i-x_i)^2}\,,\) where N is the number of boundary pixels, \(x_i\) are true values of the shape signature and \(\hat{x}_i\) are estimated shape signature values. We also analyse the maximal absolute error (MaxErr) of the methods. For each radius in the range 0 to 100 pixels, 100 disks (100 stars) with centres randomly translated within one pixel, are observed and their signatures compared with the ground truth (true signatures of the corresponding continuous objects). For the case of stars, random rotations of the objects are included as well.

To compare and evaluate performance of the estimators in terms of their precision, we correct for the bias of BSS and ACSS. We estimate their resp. bias by averaging signatures of 100 randomly positioned disks of a radius 1000, and subtract it from estimated signatures observed in the test.

Fig. 5.
figure 5

RMSE and MaxErr (in pixels) of BSS (4- and 8-connected), ACSS (8-conn) and PCSS, applied to disks (first and second row) and stars (third row) of increasing radii.

Figure 5 presents plots of obtained RMSE and MaxErr. Outstanding performance of the proposed PCSS estimator on the disks can better be appreciated in the log-log plots. Linear decrease of both RMSE and MAE is observed for PCSS for disks, with increase of object size (or image resolution). The proposed method clearly outperforms the competitors also when applied to the more complex objects (stars) with non-smooth boundaries.

Rotation invariance of the proposed PCSS estimator is illustrated in Fig. 6. Three rotations of a rectangle (\(9 \times 11\) pixels), shown in Fig. 6(b) by their coverage representations, are observed. Corresponding signatures of these shapes, estimated by the three compared methods, are shown in Fig. 6(a). Each plot represents signatures of the three shapes, with differently marked points (triangles, squares, and stars), estimated by one of the three observed methods. The blue continuous line indicates the true signature of the observed rectangle. The signatures are shifted to the same starting angle so that they, in the ideal case, should coincide. Translation and rotation invariance is however violated for BSS, but also ACSS, due to discretization. The cloud of points clearly deviates from the blue line (lack of accuracy) for both BSS and ACSS as well as between observations (lack of precision). For the PCSS estimate, the points are consistently correctly positioned, exhibiting both high accuracy and high precision.

Fig. 6.
figure 6

Signatures of three rotations of a rectangle, estimated by BSS, ACSS, and PCSS. Points of the different signatures are marked by triangles, squares, and stars. Coverage representations of the displaced rectangles are shown to the right.

Fig. 7.
figure 7

RMSE for the methods for increasing levels of Gaussian noise. Both PCSS and ACSS perform better when degraded by up to 20 % noise than what a noise free crisp approach (blue dotted line) does. (b) Part of the observed object with \(20\,\%\) noise added. (c) Asymptotic behavior of the sequence \(\left||\varvec{r}^k - \varvec{r}^{k-1} \right||_\infty ,\ k \in {\text {I}\!\text {N}}\) for different cases (Color figure online).

Sensitivity to noise of PCSS is evaluated in comparison with the performance of BSS and ACSS, observing RMSE of the estimated signatures of a star, in presence of increasing levels of added zero mean Gaussian noise with standard deviation in the range [0, 0.25] (where a white pixel has level 1). Each object is segmented by either Otsu thresholding (for crisp approaches) or with the fast soft thresholding technique proposed in [7] (for ACSS and PCSS). We observe, in Fig. 7, that both PCSS and ACSS perform better than what a noise free crisp approach does (blue dotted line), even when the coverage based approaches are degraded by up to 20 % of noise.

Illustration of convergence of the proposed algorithm is given in Fig. 7(c). Results of the empirical evaluation indicate that the sequence \(\left||\varvec{r}^k - \varvec{r}^{k-1} \right||_\infty \) showing difference of two consecutive signature estimates (non-monotonically) decreases for shapes which do not have sharp corners. Convergence of the algorithm when signature of a star is estimated is violated, so the algorithm terminates with the reached maximal number of iterations. However, if the sharp peaks of the star are smoothed by a morphological opening, the algorithm converges, and so it does when applied to both noisy and noise-free disks.

Processing time is around 0.01 s for a 600 pixel long signature (Star) on a single 3 GHz CPU in Matlab. The algorithm is easy to parallelize if higher processing speed is required.

5 Conclusion

We propose a novel method for estimating the centroid distance signature of a shape utilizing its pixel coverage representation. Pixel value, representing fraction of the pixel area covered by the imaged object, is used to estimate the edge position of the object inside the pixel. Midpoint of the estimated edge is used to define the signature. An iterative procedure is suggested to improve edge direction estimation, and by that to improve the signature estimate in each iterative step. Evaluation of the proposed method confirms its superiority regarding accuracy, precision, robustness to noise, and invariance w.r.t. rotation and translation, compared to the shape signatures estimated from crisp shape representation, or by averaging the signatures of the \(\alpha \)-cuts of the coverage representation. The proposed iterative algorithm is fast, intuitive and simple.

We have, on the example of shape signature, again confirmed that the information rich coverage representation enables estimation of shape descriptors with high accuracy and precision.