11/*
2- * (c)2018-2021, Cris Luengo.
2+ * (c)2017, Wouter Caarls.
3+ * (c)2018-2025, Cris Luengo.
34 * Based on original DIPlib code: (c)1995-2014, Delft University of Technology.
45 *
56 * Licensed under the Apache License, Version 2.0 (the "License");
@@ -53,12 +54,19 @@ namespace dip {
5354
5455// / \brief Hough transform for circles in 2D binary images.
5556// /
56- // / Computes the Hough parameter space for circles in 2D images, with the radius dimension collapsed.
57- // / The parameter space `out` has the same sizes as the binary input image `in`. `gv` is a vector image
58- // / of the same sizes as `in`, with the gradient vector for each pixel of `in`.
57+ // / Computes the Hough parameter space for circles in 2D binary images, with the radius dimension collapsed.
58+ // / The parameter space `out` has the same sizes as the input image `in`.
59+ // /
60+ // / `gv` is a vector image of the same sizes as `in`, with 2D vectors that point normal to the circle at
61+ // / each pixel in `in`.
62+ // / This version of the algorithm does not draw a full cone in a 3D parameter space (x, y, r) for each
63+ // / set pixel in the input, but draws a line along the normal in a 2D parameter space (x, y).
64+ // / The magnitude of the vector is used as weight, meaning that the length of the vector can be used
65+ // / to encode confidence in the direction. See \ref dip::FindHoughCircles for an example how to generate
66+ // / the input images.
5967// /
6068// / `range` must be empty, or have exactly two elements representing the minimum and maximum radius to
61- // / be considered. If empty, the minimum radius is 0, and the maximum is the length of the image diagonal.
69+ // . be considered. If empty, the minimum radius is 0, and the maximum is the length of the image diagonal.
6270DIP_EXPORT void HoughTransformCircleCenters (
6371 Image const & in,
6472 Image const & gv,
@@ -106,14 +114,24 @@ DIP_EXPORT Distribution PointDistanceDistribution(
106114// / using \ref dip::HoughTransformCircleCenters, and then a radius is calculated for each center. Note that
107115// / only a single radius is returned per center coordinates.
108116// /
109- // / `gv` is a vector image of the same sizes as `in`, with the gradient vector for each pixel of `in`.
117+ // / `gv` is a vector image of the same sizes as `in`, with 2D vectors that point normal to the circle at
118+ // / each pixel in `in`. See \ref dip::HoughTransformCircleCenters for details.
110119// /
111120// / `range` must be empty, or have exactly two elements representing the minimum and maximum radius to
112121// / be considered. If empty, the minimum radius is 0, and the maximum is the length of the image diagonal.
113122// /
114123// / `distance` is the minimum distance between centers, used to suppress noisy results.
115124// / `fraction` is the minimum height of a peak in the Hough transform, with respect to the largest peak,
116125// / that should be considered, again to suppress noisy results.
126+ // /
127+ // / The output array contains three values per circle found: the x and y coordinates, and the radius.
128+ // /
129+ // / Example usage:
130+ // / ```cpp
131+ // / dip::Image gv = dip::Gradient( img );
132+ // / dip::Image mask = dip::Norm( gv ) > 10; // Some threshold that removes irrelevant gradients, keeping only significant edges
133+ // / auto hough = dip::FindHoughCircles( mask, gv, { 50, 150 } );
134+ // / ```
117135DIP_EXPORT FloatCoordinateArray FindHoughCircles (
118136 Image const & in,
119137 Image const & gv,
@@ -122,6 +140,7 @@ DIP_EXPORT FloatCoordinateArray FindHoughCircles(
122140 dfloat fraction = 0.1
123141);
124142
143+
125144// / \brief Stores the parameters for one hypersphere (circle, sphere).
126145struct RadonCircleParameters {
127146 FloatArray origin; // /< Coordinates of the origin of the hypersphere
@@ -184,7 +203,7 @@ using RadonCircleParametersArray = std::vector< RadonCircleParameters >;
184203// / - C.L. Luengo Hendriks, M. van Ginkel and L.J. van Vliet,
185204// / "Underestimation of the radius in the Radon transform for circles and spheres",
186205// / Technical Report PH-2003-02, Pattern Recognition Group, Delft University of Technology, The Netherlands, 2003.
187- // TODO: If `mode` is `"full"`, then the parameter space is computed chunks to save memory.
206+ // TODO: If `mode` is `"full"`, then the parameter space is computed in chunks to save memory.
188207DIP_EXPORT RadonCircleParametersArray RadonTransformCircles (
189208 Image const & in,
190209 Image& out,
@@ -209,9 +228,9 @@ DIP_NODISCARD inline Image RadonTransformCircles(
209228 return out;
210229}
211230
212-
213231// / \endgroup
214232
233+
215234// / \group detection_corners Corner detectors
216235// / \ingroup detection
217236// / \brief Corner detection algorithms
0 commit comments