
Youpi. C'est bien. Il reste une partie pour Giovanni.
+++ olena/oln/convol/slow_gaussian.hh Mon, 14 Jun 2004 08:31:10 +0200 odou_s (oln/r/7_slow_gauss 1.2 644) @@ -30,7 +30,7 @@ # define SLOW_GAUSSIAN_HH # include <oln/core/image.hh> # include <ntg/float.hh> -# include "convolution.hh" +# include <oln/convol/slow_convolution.hh> # include <oln/core/behavior.hh>
namespace oln { @@ -87,7 +87,14 @@ { const typename gaussian_kernel<I::dim>::ret k = gaussian_kernel<I::dim>::kernel(sigma, radius_factor); - behavior.adapt_border(in, coord(k.delta())); + + // Compute Delta. + // \todo FIXME: should be in the image hierarchy. + coord delta = 0; + for (unsigned i = 0; i < I::dim; i++) + if (in.size().nth(i) > delta) + delta = in.size().nth(i); + behavior.adapt_border(in, delta);
(delta + 1) / 2.
typename mute<I, ntg::float_d>::ret im = oln::convol::slow::convolve<ntg::float_d> (in, k); Index: olena/oln/convol/slow_gaussian.hxx --- olena/oln/convol/slow_gaussian.hxx Wed, 09 Jun 2004 20:13:57 +0200 van-vl_n (oln/r/8_slow_gauss 1.2 644) +++ olena/oln/convol/slow_gaussian.hxx Mon, 14 Jun 2004 05:42:37 +0200 odou_s (oln/r/8_slow_gauss 1.2 644)
inline T normalise(const T &in)
T peu être remplacé par abstract::non_vectorial_image.
+ w(x + size, y + size) = inv_sigma_sigma_pi_2
Comme je te l'ai déjà dit je n'aime pas avoir deux centres dans une seule image. Faire le changement de repère à la main, c'est pas top. Mais bon c'est pas de ta faute.
+ image3d<ntg::float_d> w(size * 2 + 1, + size * 2 + 1, + size * 2 + 1); + const ntg::float_d k = 1. / (sigma * sigma * sigma * sqrt((M_PI * 2.) * (M_PI * 2.) * (M_PI * 2.))); @@ -186,9 +191,11 @@ for (int y = -size; y <= +size; ++y) for (int z = -size; z <= +size; ++z) if (x * x + y * y + z * z <= size) - w.add(x, y, z, k * + w(x + size, y + size, z + size) = k * exp(-(x * x + y * y + z * z) - ) / (2. * sigma * sigma)); + ) / (2. * sigma * sigma); + else + w(x + size, y + size, z + size) = 0; return w; } };
+# include <oln/basics.hh> +# include <oln/basics2d.hh> +# include <ntg/all.hh>
Ces trois lignes sont à éviter.
+# include <mlc/cmp.hh> +# include <mlc/array/all.hh> +# include <oln/transforms/fft.hh> +# include <oln/morpher/piece_morpher.hh> + +namespace oln { +
+ 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()); +#define CENTER_DST(I) \ +((I) % 2 ? (I) / 2 + 1 : (I) / 2) +#define CENTER_SRC(I) \ +((I) % 2 ? (I) / 2 : ((I) - 1) / 2)
Beuh... Macro... Macro en majuscule...
Il reste a lire cette partie de la news. | | V
@@ -41,6 +41,7 @@ # include <ntg/basics.hh> # include <ntg/all.hh> # include <oln/basics2d.hh> +# include <oln/morpher/piece_morpher.hh>
namespace oln {
@@ -485,6 +486,84 @@ }
/*! + ** \brief Shift zero-frequency component of discrete Fourier transform + ** to center of spectrum. + ** + ** \param T1 The data type of the image returned. + ** + ** The zero-frequency component of discrete Fourier transform are moved + ** to center of the image : + ** + ** \htmlonly + ** <table> + ** <tr><td>1</td><td>2</td></tr> + ** <tr><td>3</td><td>4</td></tr> + ** </table> + ** becomes + ** <table> + ** <tr><td>4</td><td>3</td></tr> + ** <tr><td>2</td><td>1</td></tr> + ** </table> + ** \endhtmlonly + ** + */ + template <class T1> + image2d<T1> shift_transform_inv() + { + image2d<T1> t = transform_inv<T1>(); + image2d<T1> st(t.size()); + + // We have to exchange t_1 with t_1_dest and not directly t_3 because + // they have not he same size. + typedef morpher::piece_morpher< image2d<T1> > piece_t; + piece_t t_1(t, dpoint2d(0, 0), + image2d_size((t.size().nrows() - 1) / 2, + (t.size().ncols() - 1) / 2, + t.border())); + piece_t t_1_dest(st, dpoint2d(t.nrows() - t_1.nrows(), + t.ncols() - t_1.ncols()), + image2d_size(t_1.nrows(), t_1.ncols(), + t.border())); + piece_t t_2(t, dpoint2d(0, (t.size().ncols() - 1) / 2), + image2d_size((t.size().nrows() - 1) / 2, + t.size().ncols() - (t.size().ncols() - 1) / 2, + t.border())); + piece_t t_2_dest(st, dpoint2d(t.nrows() - t_2.nrows(), 0), + image2d_size(t_2.nrows(), t_2.ncols(), + t.border())); + piece_t t_3(t, dpoint2d((t.size().nrows() - 1) / 2, 0), + image2d_size(t.size().nrows() - (t.size().nrows() - 1) / 2, + (t.size().ncols() - 1) / 2, + t.border())); + piece_t t_3_dest(st, dpoint2d(0, t.ncols() - t_3.ncols()), + image2d_size(t_3.nrows(), t_3.ncols(), + t.border())); + piece_t t_4(t, dpoint2d((t.size().nrows() - 1) / 2, + (t.size().ncols() - 1) / 2), + image2d_size(t.size().nrows() - (t.size().nrows() - 1) / 2, + t.size().ncols() - (t.size().ncols() - 1) / 2, + t.border())); + piece_t t_4_dest(st, dpoint2d(0, 0), + image2d_size(t_4.nrows(), t_4.ncols(), + t.border())); + + oln_iter_type(piece_t) i1(t_1); + for_all(i1) + t_1_dest[i1] = t_1[i1]; + oln_iter_type(piece_t) i2(t_2); + for_all(i2) + t_2_dest[i2] = t_2[i2]; + oln_iter_type(piece_t) i3(t_3); + for_all(i3) + t_3_dest[i3] = t_3[i3]; + oln_iter_type(piece_t) i4(t_4); + for_all(i4) + t_4_dest[i4] = t_4[i4]; + + return st; + } + + /*! ** \brief Compute and return the invert transform. */ image2d<T> transform_inv() @@ -492,6 +571,15 @@ return transform_inv<T>(); }
+ /*! + ** \brief Shift zero-frequency component of discrete Fourier transform + ** to center of spectrum. + */ + image2d<T> shift_transform_inv() + { + return shift_transform_inv<T>(); + } + };
/*!
Index: olena/tests/convol/Makefile.am --- olena/tests/convol/Makefile.am Tue, 05 Aug 2003 21:39:33 +0200 burrus_n (oln/f/38_Makefile.a 1.13 600) +++ olena/tests/convol/Makefile.am Mon, 14 Jun 2004 07:24:23 +0200 odou_s (oln/f/38_Makefile.a 1.13 600) @@ -1,4 +1,7 @@ include ../check/Makefile.runtests
+LDADD_RUNTESTS += $(FFTW_LDFLAGS) +CXXFLAGS_RUNTESTS += $(FFTW_CFLAGS) + EXTRA_DIST += sum_on_random.pgm CLEANFILES += lena-sobel.pgm Index: olena/tests/convol/tests/slow_sum_2d_1
--- doc/ref/out/exdoc.config.in Fri, 09 Apr 2004 16:53:44 +0200 thivol_d (oln/k/7_exdoc.conf 1.7 600) +++ doc/ref/out/exdoc.config.in Mon, 14 Jun 2004 07:03:20 +0200 odou_s (oln/k/7_exdoc.conf 1.7 600) @@ -4,7 +4,8 @@ TAG_CLOSE = endcode 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 - OPTIONS = @DOC_CPPFLAGS@ @CXXFLAGS_OPTIMIZE@ @CXXFLAGS_STRICT_ERRORS@ -I@top_srcdir@/integre -I@top_builddir@/olena -I@top_srcdir@/olena -I@top_srcdir@/metalic $1 -o $2 -DIMG_OUT=\"../img/\" -DIMG_IN=\"@top_srcdir@/olena/img/\" # 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 + # 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 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/makefile.src
-- Niels