Use of convexity in contour detection

05/30/2019 ∙ by Victor Churchill, et al. ∙ 0

In this paper, we formulate a simple algorithm that detects contours around a region of interest in an image. After an initial smoothing, the method is based on viewing an image as a topographic surface and finding convex and/or concave regions using simple calculus-based testing. The algorithm can achieve multi-scale contour detection by altering the initial smoothing. We show that the method has promise by comparing results on several images with the watershed transform performed on the gradient images.

READ FULL TEXT VIEW PDF
POST COMMENT

Comments

There are no comments yet.

Authors

page 3

page 4

page 5

page 6

page 7

This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

1 Introduction

In its first application, the watershed transform was performed on the gradient modulus of an image in order to detect contours around catchment basins, [3]. In this paper, a simple method for detecting similar contours is presented. In particular, contours at the boundary of convex and concave regions in the image are detected. This is achieved by locating zero crossings of Gaussian curvature in the image when viewed as a topographic surface. To identify depressions in the topography, convex regions of the surface are located. To identify protrusions, concave regions are located. In the proposed method these two region types can be viewed separately or together depending on the application.

The paper begins by considering convex regions in differentiable functions. In general, a twice differentiable function of variables is convex at a point if and only if Hessian matrix is positive semidefinite at that point, [5]. Similarly is concave if and only if the Hessian matrix is negative semidefinite. This condition can be interpreted geometrically as the requirement that has positive (upward or downward, respectively) Gaussian curvature at each point . If we were considering both convex and concave regions, this is where the surface has positive Gaussian curvature. For bivariate functions, these tests for convexity and concavity are performed by considering the behavior of the determinant of the Hessian matrix as well the second derivative with respect to the first variable. In order to formulate perform these convexity and concavity tests on a digital image, a pre-processing smoothing is performed so that the image better approximates a differentiable function. The size of the smoothing kernel determines the size of the features around which contours are formed.

The results show that this contour detection method provides several advantages over the watershed transform. The boundaries are always closed contours for segmentation, as it is impossible to move from from positive to negative Gaussian curvature without crossing zero. The method generally avoids oversegmentation that occurs with the watershed and any potential region-merging, user-defined markers [8], or geodesic correction [9]. The other core advantage of this technique is algorithmic and code simplicity. Unlike the watershed transform, we don’t need any notions of flooding, topographic distance [7], or graph theory [10]. The results are achieved using simple calculus-based testing. This enables a very fast computation. In our results, we compare with the watershed transform performed on the gradient modulus of the image of interest.

2 Methods

2.1 Contour detection via convexity for functions

Convexity of smooth bivariate functions can be determined by performing the second partial derivative test at every point in the domain. Images inherently have two dimensions, so it makes intuitive sense that the second partial derivative test for functions of two variables should have a connection with concavity in images.

Let be a differentiable real-valued function of two variables whose second partial derivatives exist. The Hessian matrix of is

(1)

Define as the determinant of

(2)

The following conditions define convexity for bivariate functions.

  1. If and then is convex at .

  2. If and then is concave at .

Note that these two conditions are equivalent to being positive semidefinite and negative semidefinite, respectively. This can also be viewed as a condition on the Gaussian curvature, defined by

(3)

As the denominator is greater than zero, . Hence if we wish to look at convex and concave regions as a single unit, we only need to find , which corresponds precisely to regions with positive Gaussian curvature. Note that Gaussian curvature is rotation-invariant, so it suffices to consider partial derivatives in the cardinal directions.

Example

As an example of finding convex and concave regions in a differentiable function of two variables whose second partial derivatives exist, we consider the function

(4)

The function and its topographic surface are shown in Figure 1, and its convex and concave regions and their boundary contours are shown in Figure 2. Note that the majority region where the function is neither convex nor concave corresponds to negative Gaussian curvature. That is, in these areas the principal curvatures are of differing signs.

Figure 1: Image and surface plot of .
Figure 2: Convex (blue) and concave (red) regions of and their boundaries.

2.2 Contour detection via convexity for images

Digital space is fundamentally different than function space. There are no infinitely small elements that are required for calculus. Hence an image needs to be pre-processed before the convexity test can be performed. Without pre-processing, the test typically generates very small scale closed contours which are not typically useful. Here, this is addressed by performing a smoothing whereby the image is convolved with a Gaussian kernel defined by

(5)

The parameter determines the size of the smoothing kernel. As increases, increasingly large convex and concave regions are typically flattened and hence not detected by the test. Hence, as shown later in the results, there is an inherent opportunity to detect contours at multiple scales in the same image by performing boundary detection on two differently smoothed versions of the same image. This can be seen in Figures 5 and 6. The algorithm for contour detection is written out fully in Algorithm 1.

1:  Smooth the image using a Gaussian kernel of size to obtain .
2:  Compute at each pixel in .
3:  If is a pixel such that and , label it with a . Otherwise, .
4:  Consider the exterior boundary of the region found in the previous step.
Algorithm 1 Contour detection via convexity

3 Results

In this section, we compare the simple convexity-based contour detection algorithm with the watershed transform as formed in [7] applied to gradient images. In the original paper on watersheds, [3], one application considered was bubble detection in a radiographic plate, [4]. This example is repeated in Figures 3. We also look at detecting dark circular shapes in a gel electrophoresis image in Figure 4, where many more dark, and overlapping, spots are present. Figure 5 shows the ability of the method to detect features of different scales using . Figure 6 combines the and results to depict multi-scale features of the original image. Small features are shown as filled in regions and large scales are shown as boundaries. Finally, Figure 7 shows a large ( pixel) image of galaxies from which concave regions have been detected such that individual galaxies are identified by bounding contours.

Figure 3: Bubble detection in a radiographic plate [2] via watershed (left) and convexity (right).
Figure 4: Contours on an electrophoresis gel image [2] via watershed (left) and convexity (right).
Figure 5: Contour detection via convexity in an image of nuclei [6] using three different-sized smoothing kernels. Right is a closeup of the full image on the left.
Figure 6: Multi-scale detection via convexity in an image of nuclei [6] using two different-sized smoothing kernels. Right is a closeup of the full image on the left.
Figure 7: Galaxy contour detection on an image from the Hubble Space Telescope, [1]. Right is a closeup of the full image on the left.

4 Conclusion and Future Work

This paper presented a contour detection algorithm that identifies convex and concave regions of an image. The results show several advantages of the proposed method for contour detection over the gradient watershed which we summarize below. First, the method typically does not oversegment if a reasonable smoothing parameter is chosen. Even if extraneous convex or concave regions are identified, they are always in the form of closed contours, and pruning based on size could be performed as post-processing. Foreground and background are much more clearly separated than by the gradient watershed. This method also has the advantage of providing multi-scale feature information in the image through the use of multiple smoothing kernels of different sizes. The simplicity of the method is superior both heuristically and in the code, an example of which is shown in the Appendix. This simplicity enables a very fast execution. A final advantage is how easily extended this method is to higher dimensions. As mentioned in the introduction, the convexity of an

-dimensional function is determined by the Hessian being positive semidefinite, or negative semidefinite for concavity. This simply-evaluated condition will allow contour and region detection on 3D and 4D datasets that have been appropriately smoothed as well. Finally, it is the author’s hope that this technique will also aid in the problem of change detection, where a time-differenced image of the same scene can be smoothed and areas where change has occurred will be highlighted for further inspection.

Appendix - MATLAB Code Example

% load image of type double
im_original = imread(’image’);
% smooth image
sigma = 10;
im = imgaussfilt(im_original,sigma);
% compute Hessian determinant
[imx,imy] = imgradientxy(im);
[imxx,imxy] = imgradientxy(imx);
[~,imyy] = imgradientxy(imy);
D = imxx.*imyy - imxy.^2;
% find convex and concave regions
logical = D > 0;
% consider the exterior boundary
dilate = imdilate(logical,ones(3));
boundary = and(~logical,dilate);

References

  • [1] Hubble sees galaxies galore. Hubble Space Telescope (Mar 2014). Credit: NASA, ESA, and S. Beckwith (STScI) and the HUDF Team. https://www.spacetelescope.org/images/heic0406a/.
  • [2] Beucher, S. The watershed transformation. Image Segmentation and Mathematical Morphology - Centre for Mathematical Morphology (May 2010). https://www.cmm.mines-paristech.fr/ beucher/wtshed.html.
  • [3] Beucher, S., and Lantuejoul, C. Use of watersheds in contour detection. In Proceedings of the International Workshop on Image Processing (1979), CCETT.
  • [4] Beucher, S., and Meyer, F. The morphological approach to segmentation: the watershed transformation. Optical Engineering-New York-Marcel Dekker Incorporated- 34 (1992), 433–433.
  • [5] Boyd, S., and Vandenberghe, L. Convex optimization. Cambridge university press, 2004.
  • [6] Eddins, S. Cell segmentation. Steve on Image Processing and MATLAB (Jun 2006). Credit: Image courtesy of Dr. Ramiro Massol. https://blogs.mathworks.com/steve/2006/06/02/cell-segmentation/.
  • [7] Meyer, F. Topographic distance and watershed lines. Signal processing 38, 1 (1994), 113–125.
  • [8] Meyer, F. The watershed concept and its use in segmentation: a brief history. arXiv preprint arXiv:1202.0216 (2012).
  • [9] Najman, L., and Schmitt, M. Geodesic saliency of watershed contours and hierarchical segmentation. IEEE Transactions on pattern analysis and machine intelligence 18, 12 (1996), 1163–1173.
  • [10] Vincent, L., and Soille, P. Watersheds in digital spaces: an efficient algorithm based on immersion simulations. IEEE Transactions on Pattern Analysis & Machine Intelligence, 6 (1991), 583–598.