
Index: ChangeLog from Nicolas Widynski <nicolas.widynski@lrde.epita.fr> Update laplacian convolution. * oln/convolution/laplacian.hh: Update laplacian convolution for first and second derivatives. laplacian.hh | 66 +++++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 55 insertions(+), 11 deletions(-) Index: oln/convolution/laplacian.hh --- oln/convolution/laplacian.hh (revision 378) +++ oln/convolution/laplacian.hh (working copy) @@ -40,19 +40,48 @@ template <typename I> oln_type_of(I, concrete) - laplacian(const abstract::image<I>& input); + laplacian_first_derivative(const abstract::image<I>& input); + + template <typename I> + oln_type_of(I, concrete) + laplacian_second_derivative_xy_yx(const abstract::image<I>& input); + + template <typename I> + oln_type_of(I, concrete) + laplacian_second_derivative_xx_yy(const abstract::image<I>& input); namespace impl { - // FIXME : type I must be a ntg::int_u8 + // FIXME : type I must be a ntg::int_s8 u8... + + template <typename I> + oln_type_of(I, concrete) + laplacian_first_derivative_(const abstract::image2d<I>& input) + { + oln_type_of(I, concrete) lpl(input.size(), "laplacian first derivative"); + oln_type_of(I, fwd_piter) p(input.size()); + oln_type_of(I, point) pt; + oln_type_of(I, value) v; + + for_all_p(p) + { + pt = p; + lpl[p] = (input[oln_type_of(I, point)((coord_t)(pt.row() - 1), pt.col())].value() + + input[oln_type_of(I, point)((coord_t)(pt.row()), pt.col())].value() + + input[oln_type_of(I, point)(pt.row(), (coord_t)(pt.col() - 1))].value() + + input[oln_type_of(I, point)(pt.row(), (coord_t)(pt.col()))].value() - + 4 * input[p].value()) / 4; + } + return lpl; + } template <typename I> oln_type_of(I, concrete) - laplacian_(const abstract::image2d<I>& input) + laplacian_second_derivative_xx_yy_(const abstract::image2d<I>& input) { - oln_type_of(I, concrete) lpl(input.size(), "laplacian"); + oln_type_of(I, concrete) lpl(input.size(), "laplacian second derivative"); oln_type_of(I, fwd_piter) p(input.size()); oln_type_of(I, point) pt; oln_type_of(I, value) v; @@ -60,25 +89,40 @@ for_all_p(p) { pt = p; - lpl[p] = (abs(input[oln_type_of(I, point)((coord_t)(pt.row() - 1), pt.col())].value() + - input[oln_type_of(I, point)((coord_t)(pt.row() + 1), pt.col())].value() - - 2 * input[p].value()) + - abs(input[oln_type_of(I, point)(pt.row(), (coord_t)(pt.col() - 1))].value() + + lpl[p] = (input[oln_type_of(I, point)((coord_t)(pt.row() - 1), pt.col())].value() + + input[oln_type_of(I, point)((coord_t)(pt.row() + 1), pt.col())].value() + + input[oln_type_of(I, point)(pt.row(), (coord_t)(pt.col() - 1))].value() + input[oln_type_of(I, point)(pt.row(), (coord_t)(pt.col() + 1))].value() - - 2 * input[p].value())) % 255; + 4 * input[p].value()) / 4; } return lpl; } + } // end of namespace oln::convolution::impl template <typename I> oln_type_of(I, concrete) - laplacian(const abstract::image<I>& input) + laplacian_first_derivative(const abstract::image<I>& input) + { + return impl::laplacian_first_derivative_(input.exact()); + } + + template <typename I> + oln_type_of(I, concrete) + laplacian_second_derivative_xy_yx(const abstract::image<I>& input) + { + return impl::laplacian_first_derivative_(impl::laplacian_first_derivative_(input.exact())); + } + + template <typename I> + oln_type_of(I, concrete) + laplacian_second_derivative_xx_yy(const abstract::image<I>& input) { - return impl::laplacian_(input.exact()); + return impl::laplacian_second_derivative_xx_yy_(input.exact()); } + } // end of namespace oln::convolution } // end of namespace oln