
Index: ChangeLog from Simon Odou <simon@lrde.epita.fr> * config/oln.m4: Set LDFLAGS to compile code examples. Index: doc/ChangeLog from Simon Odou <simon@lrde.epita.fr> * ref/out/exdoc.config.in: Use LDFLAGS instead of libs. 2004-05-12 Reda Dehak <reda@lrde.epita.fr> Index: integre/ChangeLog from Simon Odou <simon@lrde.epita.fr> * ntg/core/macros.hh: Add value accessors (sup() and inf()). * ntg/utils/cast.hh: Fix a bug in cast::bound(). Index: olena/ChangeLog from Simon Odou <simon@lrde.epita.fr> * oln/convol/fast_convolution.hh: Clean code. * oln/convol/slow_gaussian.hxx: Fix too generic parameter. * oln/convol/slow_gaussian.hh: Fix delta computation. * oln/convol/fast_gaussian.hxx: Use cast::bound instead of cast::force. * oln/convol/slow_convolution.hh: Clean code. Index: olena/oln/convol/slow_convolution.hh --- olena/oln/convol/slow_convolution.hh Mon, 14 Jun 2004 09:07:03 +0200 odou_s (oln/f/39_convolutio 1.4.1.4.1.6.1.4 600) +++ olena/oln/convol/slow_convolution.hh Mon, 14 Jun 2004 16:26:53 +0200 odou_s (oln/f/39_convolutio 1.4.1.4.1.6.1.4 600) @@ -26,8 +26,8 @@ // Public License. -#ifndef OLENA_CONVOL_SLOW_CONVOLUTION_HH__ -# define OLENA_CONVOL_SLOW_CONVOLUTION_HH__ +#ifndef OLENA_CONVOL_SLOW_CONVOLUTION_HH +# define OLENA_CONVOL_SLOW_CONVOLUTION_HH # include <oln/basics.hh> # include <oln/basics2d.hh> @@ -71,10 +71,10 @@ oln_iter_type(I) p_im(input); for_all(p_im) { - DestValue sum = ntg_zero_val(DestValue); + ntg::float_d sum = ntg_zero_val(ntg::float_d); for (unsigned i = 0; i < win.card(); ++i) - sum += static_cast<DestValue> (win.w(i)) * - static_cast<DestValue> (input[p_im - win.dp(i)]); + sum += ntg::cast::bound<ntg::float_d>(win.w(i)) * + ntg::cast::bound<ntg::float_d>(input[p_im - win.dp(i)]); output[p_im] = sum; } @@ -96,7 +96,7 @@ template<class DestValue, class I, class J> typename mute<I, DestValue>::ret convolve(const abstract::non_vectorial_image< I >& input, - const abstract::image< J >& k) + const abstract::non_vectorial_image< J >& k) { mlc::eq<I::dim, J::dim>::ensure(); @@ -108,26 +108,23 @@ for (unsigned i = 0; i < J::dim; i++) if (k.size().nth(i) > delta) delta = k.size().nth(i); + delta = (delta + 1) / 2; input.border_adapt_copy(delta); // Computer center of the kernel. // \todo FIXME: should be in the image hierarchy. - oln_iter_type(I) p_im(input); - oln_iter_type(I) p_k(k); oln_point_type(I) center; - unsigned i_center = 0; - unsigned real_center = k.npoints() % 2 ? k.npoints() / 2 + 1 : - k.npoints() / 2; - for_all(p_k) - if (++i_center == real_center) - center = p_k; + for (unsigned i = 0; i < J::dim; i++) + center.nth(i) = (k.size().nth(i) - 1) / 2; + oln_iter_type(I) p_im(input); + oln_iter_type(J) p_k(k); for_all(p_im) { - DestValue sum = ntg_zero_val(DestValue); + ntg::float_d sum = ntg_zero_val(ntg::float_d); for_all(p_k) - sum += static_cast<DestValue> (k[p_k]) * - static_cast<DestValue> (input[p_im - (center - p_k)]); + sum += ntg::cast::bound<ntg::float_d>(k[p_k]) * + ntg::cast::bound<ntg::float_d>(input[p_im - (center - p_k)]); output[p_im] = sum; } return output; @@ -161,4 +158,4 @@ } // end namespace oln -#endif // OLENA_CONVOL_SLOW_CONVOLUTION_HH__ +#endif // OLENA_CONVOL_SLOW_CONVOLUTION_HH Index: olena/oln/convol/fast_gaussian.hxx --- olena/oln/convol/fast_gaussian.hxx Mon, 29 Mar 2004 16:40:01 +0200 palma_g (oln/25_fast_gauss 1.7.1.8.1.11 600) +++ olena/oln/convol/fast_gaussian.hxx Mon, 14 Jun 2004 14:33:46 +0200 odou_s (oln/25_fast_gauss 1.7.1.8.1.11 600) @@ -155,7 +155,7 @@ current = start; for (coord i = 0; i < len; ++i) { - image[current] = ntg::cast::force<oln_value_type(I)>(tmp1[i] + tmp2[i]); + image[current] = ntg::cast::bound<oln_value_type(I)>(tmp1[i] + tmp2[i]); current += d; } } @@ -304,7 +304,7 @@ oln_iter_type(I) it(in); for_all(it) - work_img[it] = ntg::cast::force<ntg::float_s>(in[it]); + work_img[it] = ntg::cast::bound<ntg::float_s>(in[it]); // On tiny sigma, Derich algorithm doesn't work. // It is the same thing that to convolve with a Dirac. Index: config/oln.m4 --- config/oln.m4 Sun, 06 Jun 2004 23:17:15 +0200 thivol_d (oln/j/15_oln.m4 1.38.1.6 600) +++ config/oln.m4 Mon, 14 Jun 2004 16:10:57 +0200 odou_s (oln/j/15_oln.m4 1.38.1.6 600) @@ -573,9 +573,7 @@ FFTW_LDFLAGS="-L${with_fftw}/lib" fi oln_save_CXXFLAGS=$CXXFLAGS - oln_save_LDFLAGS=$LDFLAGS CXXFLAGS="$CXXFLAGS $FFTW_CXXFLAGS" - LDFLAGS="$LDFLAGS $FFTW_LDFLAGS" oln_have_fftw=no AC_CHECK_HEADER([fftw.h], [AC_CHECK_LIB([fftw], @@ -585,7 +583,7 @@ AC_DEFINE([HAVE_FFTW], 1, [Define to 1 if we can use fftw])])]) CXXFLAGS=$oln_save_CXXFLAGS - LDFLAGS=$oln_save_LDFLAGS + LDFLAGS="$LDFLAGS $FFTW_LDFLAGS" fi AC_SUBST([FFTW_CXXFLAGS]) AC_SUBST([FFTW_LDFLAGS]) @@ -616,9 +614,7 @@ ZLIB_LDFLAGS="-L${with_zlib}/lib" fi oln_save_CXXFLAGS=$CXXFLAGS - oln_save_LDFLAGS=$LDFLAGS CXXFLAGS="$CXXFLAGS $ZLIB_CXXFLAGS" - LDFLAGS="$LDFLAGS $ZLIB_LDFLAGS" oln_have_zlib=no AC_CHECK_HEADER([zlib.h], [AC_CHECK_LIB([z], @@ -628,7 +624,7 @@ AC_DEFINE([HAVE_ZLIB], 1, [Define to 1 if we can use zlib])])]) CXXFLAGS=$oln_save_CXXFLAGS - LDFLAGS=$oln_save_LDFLAGS + LDFLAGS="$LDFLAGS $ZLIB_LDFLAGS" fi AC_SUBST([ZLIB_CXXFLAGS]) AC_SUBST([ZLIB_LDFLAGS]) Index: integre/ntg/utils/cast.hh --- integre/ntg/utils/cast.hh Thu, 18 Mar 2004 18:24:14 +0100 van-vl_n (oln/i/26_cast.hh 1.3.1.13 600) +++ integre/ntg/utils/cast.hh Mon, 14 Jun 2004 13:54:30 +0200 odou_s (oln/i/26_cast.hh 1.3.1.13 600) @@ -89,12 +89,12 @@ const Tdest bound(const Tsrc& val) { - if (ntg_max_val(Tsrc) > ntg_max_val(Tdest)) - if (val > Tsrc(Tdest(ntg_max_val(Tdest)))) - return ntg_max_val(Tdest); - if (ntg_min_val(Tsrc) < ntg_min_val(Tdest)) - if (val < Tsrc(Tdest(ntg_min_val(Tdest)))) - return ntg_min_val(Tdest); + if (ntg_sup_val(Tsrc) > ntg_sup_val(Tdest)) + if (val > Tsrc(Tdest(ntg_sup_val(Tdest)))) + return ntg_sup_val(Tdest); + if (ntg_inf_val(Tsrc) < ntg_inf_val(Tdest)) + if (val < Tsrc(Tdest(ntg_inf_val(Tdest)))) + return ntg_inf_val(Tdest); return val; } Index: integre/ntg/core/macros.hh --- integre/ntg/core/macros.hh Tue, 13 Apr 2004 17:31:32 +0200 van-vl_n (oln/s/19_macros.hh 1.12 600) +++ integre/ntg/core/macros.hh Mon, 14 Jun 2004 13:54:03 +0200 odou_s (oln/s/19_macros.hh 1.12 600) @@ -110,6 +110,10 @@ # define ntg_min_val(T) ntg::type_traits< T >::min() +# define ntg_sup_val(T) ntg::type_traits< T >::sup() + +# define ntg_inf_val(T) ntg::type_traits< T >::inf() + # define ntg_inf_val(T) ntg::type_traits< T >::inf() # define ntg_sup_val(T) ntg::type_traits< T >::sup() Index: doc/ref/out/exdoc.config.in --- doc/ref/out/exdoc.config.in Mon, 14 Jun 2004 09:07:03 +0200 odou_s (oln/k/7_exdoc.conf 1.8 600) +++ doc/ref/out/exdoc.config.in Mon, 14 Jun 2004 15:33:16 +0200 odou_s (oln/k/7_exdoc.conf 1.8 600) @@ -5,7 +5,7 @@ CAPTIONS = cxx # We want to run cxx on the extracted files (see line below) ALIAS cxx = @CXX@ # Here, cxx means g++ but you can choose other compilers # FIXME: we should write the compilation line in the source file (for libs). - OPTIONS = -lz -lfftw -lrfftw @DOC_CPPFLAGS@ @CXXFLAGS_OPTIMIZE@ @CXXFLAGS_STRICT_ERRORS@ -I@top_srcdir@/integre -I@top_builddir@/olena -I@top_srcdir@/olena -I@top_srcdir@/metalic -I@top_builddir@ $1 -o $2 -DIMG_OUT=\"../img/\" -DIMG_IN=\"@top_srcdir@/olena/img/\" -DHAVE_CONFIG_H # tell how to use the soft, i.e. where to put input and output arguments (default if not overriden) ($1: input, $2: output) FIXME: $* should have explicit name, chek flags + OPTIONS = @DOC_CPPFLAGS@ @CXXFLAGS_OPTIMIZE@ @CXXFLAGS_STRICT_ERRORS@ -I@top_srcdir@/integre -I@top_builddir@/olena -I@top_srcdir@/olena -I@top_srcdir@/metalic -I@top_builddir@ $1 -o $2 -DIMG_OUT=\"../img/\" -DIMG_IN=\"@top_srcdir@/olena/img/\" -DHAVE_CONFIG_H @LDFLAGS@ # tell how to use the soft, i.e. where to put input and output arguments (default if not overriden) ($1: input, $2: output) FIXME: $* should have explicit name, chek flags OUT = out # FIXME: should be obsolete EXT = cc # Extension of generated file STD_OUT_EXT = std # Extension of generated file standard output Index: olena/oln/convol/slow_gaussian.hh --- olena/oln/convol/slow_gaussian.hh Mon, 14 Jun 2004 09:07:03 +0200 odou_s (oln/r/7_slow_gauss 1.3 600) +++ olena/oln/convol/slow_gaussian.hh Mon, 14 Jun 2004 14:31:05 +0200 odou_s (oln/r/7_slow_gauss 1.3 600) @@ -94,6 +94,7 @@ for (unsigned i = 0; i < I::dim; i++) if (in.size().nth(i) > delta) delta = in.size().nth(i); + delta = (delta + 1) / 2; behavior.adapt_border(in, delta); typename mute<I, ntg::float_d>::ret im = Index: olena/oln/convol/slow_gaussian.hxx --- olena/oln/convol/slow_gaussian.hxx Mon, 14 Jun 2004 09:07:03 +0200 odou_s (oln/r/8_slow_gauss 1.3 600) +++ olena/oln/convol/slow_gaussian.hxx Mon, 14 Jun 2004 14:38:20 +0200 odou_s (oln/r/8_slow_gauss 1.3 600) @@ -42,7 +42,7 @@ */ template<class T> inline T - normalise(const T &in) + normalise(const oln::abstract::non_vectorial_image<T> &in) { T w(in.size()); ntg::float_d sum = 0.; Index: olena/oln/convol/fast_convolution.hh --- olena/oln/convol/fast_convolution.hh Mon, 14 Jun 2004 09:07:03 +0200 odou_s (oln/r/12_fast_convo 1.1 600) +++ olena/oln/convol/fast_convolution.hh Mon, 14 Jun 2004 14:56:06 +0200 odou_s (oln/r/12_fast_convo 1.1 600) @@ -26,12 +26,9 @@ // Public License. -#ifndef OLENA_CONVOL_FAST_CONVOLUTION_HH__ -# define OLENA_CONVOL_FAST_CONVOLUTION_HH__ +#ifndef OLENA_CONVOL_FAST_CONVOLUTION_HH +# define OLENA_CONVOL_FAST_CONVOLUTION_HH -# include <oln/basics.hh> -# include <oln/basics2d.hh> -# include <ntg/all.hh> # include <mlc/cmp.hh> # include <mlc/array/all.hh> # include <oln/transforms/fft.hh> @@ -72,6 +69,7 @@ ** using namespace ntg; ** ** int main() { + ** #ifdef HAVE_LIBfft ** image2d<int_u8> src(IMG_IN "lena.pgm"); ** float_d sigma = 2.5; ** float_d radius = 3; @@ -84,6 +82,7 @@ ** for_all(i) ** src[i] = int_u8(tmp[i]); ** save(src, IMG_OUT "oln_convol_fast_convolve.pgm"); + ** #endif ** } ** \endcode ** \image html lena_pgm.png @@ -100,7 +99,7 @@ { mlc::eq<I::dim, J::dim>::ensure(); mlc::eq<I::dim, 2>::ensure(); - assert(input.npoints() > k.npoints()); + assert(input.npoints() >= k.npoints()); // We compute k with a size of input (k is centered in big_k). image2d<oln_value_type(J)> big_k(input.size()); @@ -170,4 +169,4 @@ } // end namespace oln -#endif // OLENA_CONVOL_FAST_CONVOLUTION_HH__ +#endif // OLENA_CONVOL_FAST_CONVOLUTION_HH -- Simon Odou simon@lrde.epita.fr