26 #ifndef MLN_TRANSFORM_HOUGH_HH
27 # define MLN_TRANSFORM_HOUGH_HH
34 # include <mln/core/image/image2d.hh>
35 # include <mln/data/fill.hh>
37 # include <mln/geom/nrows.hh>
38 # include <mln/geom/ncols.hh>
39 # include <mln/geom/min_col.hh>
40 # include <mln/geom/min_row.hh>
41 # include <mln/geom/bbox.hh>
43 # include <mln/opt/at.hh>
45 # include <mln/math/sin.hh>
46 # include <mln/math/cos.hh>
47 # include <mln/math/pi.hh>
49 # include <mln/make/box2d.hh>
51 # include <mln/value/int_u8.hh>
74 hough(
const Image<I>& input_);
78 # ifndef MLN_INCLUDE_ONLY
86 double to_radians(
double angle)
88 return angle * math::pi / 180.0f;
100 trace::entering(
"mln::transform::hough");
102 const I& input = exact(input_);
103 mlc_equal(mln_value(I),
bool)::check();
104 mln_precondition(input.is_valid());
112 int maxRho = (int)(sqrt((ncols * nrows)
122 for (
int angle = 0 ; angle < 360 ; ++angle)
125 theta = internal::to_radians(angle),
126 rho = (p.row() - minrow) * math::cos(theta)
127 + (p.col() - mincol) * math::sin(theta);
129 indexAngle = (int) (angle),
130 indexRho = (int)(rho + maxRho + 0.5);
132 ++
opt::at(accu, indexAngle, indexRho);
135 trace::exiting(
"mln::transform::hough");
140 # endif // ! MLN_INCLUDE_ONLY
147 #endif // ! MLN_TRANSFORM_HOUGH_HH