1 Introduction

Accurate estimation of the length of a digital contour of an object is needed for various image-processing applications. The length estimated from a digital contour is often found to differ significantly from the actual geometric length of the contour corresponding to the real object. Additionally, the rotation of a digital object with respect to coordinate-axes impacts the length of its contour. In other words, because of the discreteness of the underlying pixel-grid, the estimated length varies with the orientation on the object. To the best of our knowledge, the variation of contour-length with respect to rotation has not yet been studied in the literature. In this paper, we propose a new length-estimator based on the concept of stitched digital cover for digital curves and digital objects. We also study the change in contour-length caused by rotation of the object and analyze their correlation for the purpose of identifying the angle of its rotation with respect to a reference position.

Digitization of the continuous contour of a real object leads to a sequence of discrete points that are sampled from the contour based on the chosen pixel-grid geometry. For the purpose of length estimation [5] for a digital contour, previous researchers used different measures such as chain code [8] digital straight line segment (DSS) [10], or minimum-length polygonal approximation (MLP) [13]. The DSS-method is based on the partition of a digital curve into digital straight segments, whereas the MLP-method relies on the construction of the minimum-length polygon in an open boundary of a digital region [10]. Klette et al. reported a comparative study on the performance and accuracy of such length-estimators [10]. Further studies on length-estimators for binary images were reported by Kulpa [12]. Proffit and Rosen [15] derived various properties of a digital contour. Kenmochi et al. [9] had proposed had proposed a boundary-extraction method using combinatorial topology.

The effect of rotation on digital contours has been studied by several research groups. Bennett et al. [2] defined quantization noise and analyzed the curvature of a digital object in a quantized environment. Contour length and area estimation through volume measurement was reported by Verbeek et al. [16]. The change in object-contour and shape due to rotation is observed to satisfy certain characteristics for rotation and scaling-invariant systems [6, 14]. Wang et al. designed a rotation and scaling-invariant shape descriptor by introducing a hierarchical string-cut method to partition a shape into multi-level curve segments [17]. Farooque et al. proposed a scale-invariant feature-transformation system for object recognition [7]. In this work, we propose a new method for length-estimation and study the effect of rotation on the contour-length of a digital object We show that this technique can be effectively used to detect positioning error (rotation) [4] in an X-ray imaging system.

2 Definitions

Digital plane - The digital plane, \(\mathbb {Z}^{2}\), is the set of all points having integer coordinates in the real plane \(\mathbb {R}^{2}\). A point in the digital plane is called a digital point, or a pixel in the case of a digital image.

k-connectedness - The set of k adjacent points of a point \(p(x,y) \in \mathbb {Z}^{2}\) is represented as \(N_{k}(p)\) := {\((x',y') : (x',y') \in \mathbb {Z}^{2} \wedge max(|x-x'|, |y-y'|)=1\)}. Each point in \(N_{k}(p)\) is said to be a k-neighbor (\(k = 4\) or 8) of p. Two points p and q are k-connected in a digital set \(S \subset \mathbb {Z}^{2}\) if and only if there exists a sequence \(h_{p} := p_{0}; p_{1};\dots ; p_{n} := q_{i} \subseteq S\) such that \(p_{i} \subset N_{k}(p{i-1})\) for \(1 \le i \le n\). For any point \(p \in S\), the set of points that are k-connected to \(p \in S\) is called a k-connected component of S. In this work, we have used 8-connectedness to define the inner and outer digital cover of an object.

Digital object - A digital object is a finite subset of \(\mathbb {Z}^{2}\), which consists of one or more k-connected components.

Digital grid - A digital grid \(G := (H;V)\) consists of a set H of horizontal (digital) grid lines and a set V of vertical (digital) grid lines. The intersection of vertical and horizontal grid line at the point \((i; j) \in \mathbb {Z}^{2}\), is called a grid point.

Object Cover - The contour points of a real life object may not exactly fall on the pixel grid points after digitization (as shown in Fig. 1(a) shows the outer cover of the object). For a given digital object S, the outer Jordan digitization \(J^{+}(S)\) is defined as the union of all such 2-cells (grid squares) that have non-empty intersections with S, and the inner Jordan digitization \(J^{-}(S)\) is the union of all 2-cells that are completely contained within S [11]. Jordan digitization (inner or outer) gives the union of cells but does not specify the (inner/outer) covers as a sequence of vertices.

Fig. 1.
figure 1

(a) Object without pixel grid, (b) Object on pixel grid with outer (yellow) and inner (red) cover (Color figure online)

To define the digital contour of a real object, we propose single-pixel thin inner and outer cover using 8-connectedness. We consider \(\mathfrak {J}\) to be a finite rectangular subset of \(\mathbb {Z}^{2}\), which contains the entire object S. Let the height h and the width w of \(\mathfrak {J}\) be such that the grid size, g, divides both \(h - 1\) and \(w - 1\), and the boundary unit grid blocks (UGBs) of \(\mathfrak {J}\) do not contain any part of S [3].

Outer digital cover- The outer digital cover of an object is defined as the set of pixels (\(C_{o}\)’s) that belong to the 8-neighbour of any contour point (\(cp_{i}\)) of the object outside the object region. Thus, from any point outside the object boundary, if we move towards a point on the object contour, the respective outer digital cover point will be the last pixel point (outside the object region) before reaching the object contour. Figure 1(b) shows the outer digital cover of the object with yellow points mark the selected pixel grids for outer cover.

Inner digital cover- The inner digital cover of an object is defined as the set of pixels (\(C_{i}\)’s) that belong to the 8-neighbour of any contour point (\(cp_{i}\)) of the object inside the object region. Thus, from any point inside the object, if we move towards a contour point, the respective inner digital cover point will be the last pixel point before reaching the object boundary. Figure 1(b) shows the inner digital cover of the object with red points mark the selected pixel grids for inner cover.

Stitched digital cover- In the proposed length estimator, we have used a novel stitched digital cover. The stitched digital cover of an object is defined as the set of points (\(C_{s}\)’s), where each \(C_{s}\) denotes the middle point between every pixel (\(C_{o}\)) on the outer-cover and its nearest pixel (\(C_{i}\)) lying on the inner-cover.

3 Proposed Approach

Accurate computation of the perimeter of a real life object in digital domain is a challenging task. We have proposed an approach based on stitched digital cover to compute the perimeter of the object. In this approach, the object (S) is placed on a digital grid (g) and the inner and outer digital covers are generated based on the occupancy of the object contour in each grid cell [3]. The stitched cover is then computed by using the pixels from both inner and outer cover. The proposed algorithm (getstitchlength( S,g )) is shown in Fig. 2. Here the grid is considered as unit grid (\(g=1\)) for generation of the tightest cover. For each pixel \(p_{i}\) in the outer cover of S, the nearest inner cover pixel \(q_{i}\) is identified from 8-neighbouring pixels of \(p_{i}\) (clock-wise direction). The arithmetic mean (\(m_{i}\)) of the coordinate positions of each (\(p_{i}\),\(q_{i}\)) pair is computed from the pixel positions of \(p_{i}\) and \(q_{i}\) (as shown in Fig. 3).

Fig. 2.
figure 2

Stitched cover generation and length estimation algorithm

Fig. 3.
figure 3

(a) Proposed stitched cover (in red), (b) Magnified view of region ‘A’ (Color figure online)

3.1 Effect of Rotation on Object Contour

On rotation of the object, the position of 8-nearest neighbour grid pixels change for inner and outer digital contour. This results in the change in digital contour length under rotation. Chain code representation of object contour [8] shows that the direction of contour pixel traversal can have three possible values - vertical (top and bottom), horizontal (left and right), and diagonal (corners positions) (Fig. 4(a)). Thus the length of each move in contour traversal is unity (for vertical and horizontal move) and \(\surd 2\) (for diagonal move). Figure 4(b) shows the chain code direction of pixels in a digital curve contour. The contour length of the curve is computed from the number of diagonal pixels (5 pixels, each contributing \(\surd 2\)) and number of horizontal or vertical pixels (3 pixels, each contributing unit length). As a result of object rotation, few horizontal or vertical pixels are re-positioned as diagonal pixels, and few diagonal pixels are re-positioned as vertical pixels. This results in change in contour length of the object. We have studied this change in digital contour length with each \(10^{o}\) of object rotation with respect to its centroid. Figure 4(c) shows the variation in contour length of a rectangular object with angle of rotation varies from \(0^{o}\) to \(90^{o}\). It can be noticed that the contour length is minimum at \(0^{o}\) and it changes with increase in angle of rotation. The contour length becomes minimum again at \(90^{o}\).

Fig. 4.
figure 4

(a) Chain code directions, (b) Digital curve of length (\(3+5\surd 2\)), (c) Length variation of rectangle with angle of rotation

4 Applications to Positioning-Error Detection

Studies on object rotation may find several applications in image registration, hand-writing analysis, contour-length estimation, and in other areas [2, 7, 17]. We have studied the application of object rotation in the domain of medical image processing. A common error in X-ray imaging is positioning error. In many situations, portable X-ray machines are used to take X-ray of bedridden patients. In such scenarios, the chest, femur, knee X-ray images appear with position error due to angular posture of the patient [4]. The study on change in image contour length with rotation can be applied to detect the wrong posture of the patient automatically and help technician to correct the position before capturing the final image. Figure 5(a) and (b) show the chest X-ray taken at correct position and the segmented contour of the left chest. Entropy based segmentation [1] is applied to segment the chest contour from the X-ray image. If positioning error occurs, the chest appear in rotated posture (shown in Fig. 5(e) and (f)). We have performed the analysis of normal and rotated chest contour. These contour images are rotated from \(0^{o}\) to \(90^{o}\) and the histogram of vertical and horizontal pixels and diagonal pixels at every \(10^{o}\) change in rotation are generated. Figure 5(d) shows that number of diagonal pixels is minimum at \(0^{o}\) and it changes with rotation for normal chest contour (Fig. 5(b)). For rotated chest contour (Fig. 5(f)), the minimum number of diagonal pixel doesn’t appear at \(0^{o}\) (as shown in Fig. 5(h)). This analysis indicates that the positioning error (rotation) in X-ray can be detected by analysing the erroneous X-ray image.

Fig. 5.
figure 5

(a) Chest X-ray (normal position), (b) Segmented left chest contour (normal), (c) Horizontal and vertical pixel count of (b), (d) Diagonal pixel count of (b), (e) Chest X-ray (positioning error-rotation), (f) Segmented left chest contour (positioning error), (g) Horizontal and vertical pixel count of (f), (h) Diagonal pixel count of (f)

5 Experimental Results

To quantify the effect of rotation on object contours, several binary test images are taken. The expected or actual perimeter length is calculated using chain code. After that, the objects are placed on digital grid of size \({1 \times 1}\) to calculate the inner and outer digital cover and compute the stitched cover length. For each pixel on the outer cover, the nearest inner cover pixel is identified and the stitched cover point is computed as the mid-point of the inner and outer cover pixels. We calculate the Euclidean distance (\(e_{i}\)) between each pair of stitched cover points (\(p_{i},p_{i+1}\)) and the stitched cover length is computed as \(\sum e_{i}\). For an arbitrary curve with concave or convex curvatures, the number of pixels in the outer-cover (inner-cover) may be larger (smaller) than that on the actual contour. In such scenarios, multiple outer-cover pixels may map to the same inner-cover pixel while generating the stitched-cover; the number of pixels on the stitched-cover points may be less than that on the actual contour of the object. Since the chain-code is constructed on the basis of the connected contour-pixels of the object, the length computed based on stitched-cover is observed to be slightly less than or equal to that computed from the chain code length. For some convex polygonal shapes such as rectangle and square, the two method yields the same value of the estimated length. Figure 6(a) shows the variation of estimated length from chain code length of different images. We have also predicted the length of an object at any unknown angle from the length at known angles. Figure 6(b) shows that the length of heel X-ray image at any unknown angle is predicted from the length of the same object at known angles. Here the contour length of heel X-ray is computed by proposed approach after each \(10^{o}\) of rotation about its centroid. The contour length at any unknown angle is predicted by computing the mean length between two known angles. This prediction performs better for symmetric objects.

Fig. 6.
figure 6

(a) Comparison of contour length estimation of different object, (b) Length estimation at different angles for heel X-ray image

6 Conclusion

In this paper we study the effect of rotation on the length of a digital contour and propose a new contour-length estimator. This study can be extended to develop an automated system for the detection of X-ray positioning-error. It can also be applied for efficient image registration.