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 preprocessing 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 regionmerging, userdefined 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 calculusbased 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 realvalued 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.

If and then is convex at .

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 rotationinvariant, 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.
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 preprocessed before the convexity test can be performed. Without preprocessing, 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.
3 Results
In this section, we compare the simple convexitybased 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 multiscale 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.
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 postprocessing. Foreground and background are much more clearly separated than by the gradient watershed. This method also has the advantage of providing multiscale 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 simplyevaluated 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 timedifferenced image of the same scene can be smoothed and areas where change has occurred will be highlighted for further inspection.Appendix  MATLAB Code Example
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.minesparistech.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 EngineeringNew YorkMarcel 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/cellsegmentation/.
 [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.
Comments
There are no comments yet.