URL:
https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog:
2009-06-19 Etienne FOLIO <folio(a)lrde.epita.fr>
Update histo compute and project tests and algorithms.
* folio/mln/histo/compute_histo_3d.hh: Add headers.
* folio/mln/histo/project_histo_3d.hh: New projection algorithm.
* folio/test/histo/compute_histo_3d.cc: New test.
* folio/test/histo/project_histo_3d_add.cc: New test.
* folio/test/histo/project_histo_3d_mean.cc: New test.
---
mln/histo/compute_histo_3d.hh | 30 +++++++++++--
mln/histo/project_histo_3d.hh | 56 +++++++++++++++++++++++++
test/histo/compute_histo_3d.cc | 54 ++++++++++++++++++------
test/histo/project_histo_3d_add.cc | 75 +++++++++++++++++++++++++++++++++
test/histo/project_histo_3d_mean.cc | 80 ++++++++++++++++++++++++++++++++++++
5 files changed, 277 insertions(+), 18 deletions(-)
Index: trunk/milena/sandbox/folio/test/histo/project_histo_3d_mean.cc
===================================================================
--- trunk/milena/sandbox/folio/test/histo/project_histo_3d_mean.cc (revision 0)
+++ trunk/milena/sandbox/folio/test/histo/project_histo_3d_mean.cc (revision 4173)
@@ -0,0 +1,80 @@
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to produce
+// an executable, this file does not by itself cause the resulting
+// executable to be covered by the GNU General Public License. This
+// exception does not however invalidate any other reasons why the
+// executable file might be covered by the GNU General Public License.
+
+
+#include <mln/accu/stat/mean.hh>
+#include <mln/literal/all.hh>
+#include <mln/value/rgb8.hh>
+
+#include "../../mln/histo/compute_histo_3d.hh"
+#include "../../mln/histo/project_histo_3d.hh"
+
+using namespace mln;
+using namespace value;
+
+
+inline
+void
+init_test_image(image2d<rgb8>& ima)
+{
+ rgb8 red = literal::red;
+ rgb8 green = literal::green;
+ rgb8 black = literal::black;
+
+ for (unsigned i = 1; i < 8; ++i)
+ for (unsigned j = 0; j < 8; ++j)
+ ima(point2d(j, i)) = black;
+
+ for (unsigned i = 0; i < 8; ++i)
+ ima(point2d(i, 0)) = red;
+
+ ima(point2d(4, 5)) = green;
+}
+
+
+int
+main(int argc, char* argv[])
+{
+ // build test image
+ image2d<rgb8> ima(8, 8);
+ init_test_image(ima);
+
+ // build histo
+ image3d<unsigned> histo = histo::compute_histo_3d(ima);
+
+ // project it
+ image2d<unsigned> proj =
+ histo::project_histo<accu::stat::mean<unsigned, unsigned>, 1>(histo);
+
+ // mln_fwd_piter_(image2d<unsigned>) p(proj.domain());
+ // for_all(p)
+ // if (proj(p) != 0)
+ // std::cout << p << " " << proj(p) <<
std::endl;
+
+ // verify...
+ mln_assertion(proj(point2d(255, 0)) == 8);
+ mln_assertion(proj(point2d(0, 0)) == 56);
+ mln_assertion(proj(point2d(0, 255)) == 0);
+}
Index: trunk/milena/sandbox/folio/test/histo/compute_histo_3d.cc
===================================================================
--- trunk/milena/sandbox/folio/test/histo/compute_histo_3d.cc (revision 4172)
+++ trunk/milena/sandbox/folio/test/histo/compute_histo_3d.cc (revision 4173)
@@ -1,27 +1,45 @@
-/*!
- * \file compute_histo_rgb.cc<2>
- * \author etiennefolio <ornthalas(a)gmail.com>
- */
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to produce
+// an executable, this file does not by itself cause the resulting
+// executable to be covered by the GNU General Public License. This
+// exception does not however invalidate any other reasons why the
+// executable file might be covered by the GNU General Public License.
+
-#include <iostream>
#include <mln/literal/all.hh>
-#include <mln/value/rgb.hh>
#include <mln/value/int_u8.hh>
+#include <mln/value/rgb8.hh>
#include "../../mln/histo/compute_histo_3d.hh"
-int main()
-{
using namespace mln;
using namespace value;
- typedef rgb<3> rgb3;
- // build test image
- image2d<rgb3> ima(8, 8);
- rgb3 red = literal::red;
- rgb3 green = literal::green;
- rgb3 black = literal::black;
+void
+init_test_image(image2d<rgb8>& ima)
+{
+ rgb8 red = literal::red;
+ rgb8 green = literal::green;
+ rgb8 black = literal::black;
for (unsigned i = 1; i < 8; ++i)
for (unsigned j = 0; j < 8; ++j)
@@ -38,6 +56,14 @@
point2d p(4, 5);
ima(p) = green;
+}
+
+
+int main()
+{
+ // build test image
+ image2d<rgb8> ima(8, 8);
+ init_test_image(ima);
// build histo
image3d<unsigned> out = histo::compute_histo_3d(ima);
Index: trunk/milena/sandbox/folio/test/histo/project_histo_3d_add.cc
===================================================================
--- trunk/milena/sandbox/folio/test/histo/project_histo_3d_add.cc (revision 0)
+++ trunk/milena/sandbox/folio/test/histo/project_histo_3d_add.cc (revision 4173)
@@ -0,0 +1,75 @@
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to produce
+// an executable, this file does not by itself cause the resulting
+// executable to be covered by the GNU General Public License. This
+// exception does not however invalidate any other reasons why the
+// executable file might be covered by the GNU General Public License.
+
+
+#include <mln/accu/math/sum.hh>
+#include <mln/literal/all.hh>
+#include <mln/value/rgb8.hh>
+
+#include "../../mln/histo/compute_histo_3d.hh"
+#include "../../mln/histo/project_histo_3d.hh"
+
+using namespace mln;
+using namespace value;
+
+
+inline
+void
+init_test_image(image2d<rgb8>& ima)
+{
+ rgb8 red = literal::red;
+ rgb8 green = literal::green;
+ rgb8 black = literal::black;
+
+ for (unsigned i = 1; i < 8; ++i)
+ for (unsigned j = 0; j < 8; ++j)
+ ima(point2d(j, i)) = black;
+
+ for (unsigned i = 0; i < 8; ++i)
+ ima(point2d(i, 0)) = red;
+
+ ima(point2d(4, 5)) = green;
+}
+
+
+int
+main(int argc, char* argv[])
+{
+ // build test image
+ image2d<rgb8> ima(8, 8);
+ init_test_image(ima);
+
+ // build histo
+ image3d<unsigned> histo = histo::compute_histo_3d(ima);
+
+ // project it
+ image2d<unsigned> proj =
+ histo::project_histo<accu::math::sum<unsigned, unsigned>, 1>(histo);
+
+ // verify...
+ mln_assertion(proj(point2d(255, 0)) == 8);
+ mln_assertion(proj(point2d(0, 0)) == 56);
+ mln_assertion(proj(point2d(0, 255)) == 0);
+}
Index: trunk/milena/sandbox/folio/mln/histo/project_histo_3d.hh
===================================================================
--- trunk/milena/sandbox/folio/mln/histo/project_histo_3d.hh (revision 0)
+++ trunk/milena/sandbox/folio/mln/histo/project_histo_3d.hh (revision 4173)
@@ -0,0 +1,56 @@
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to produce
+// an executable, this file does not by itself cause the resulting
+// executable to be covered by the GNU General Public License. This
+// exception does not however invalidate any other reasons why the
+// executable file might be covered by the GNU General Public License.
+
+
+#include <mln/accu/image/init.hh>
+#include <mln/accu/image/take.hh>
+#include <mln/accu/image/to_result.hh>
+#include <mln/core/image/dmorph/unproject_image.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/fun/v2v/projection.hh>
+
+
+namespace mln
+{
+ namespace histo
+ {
+
+ template <typename A, unsigned Direction, typename V>
+ image2d<mln_result(A)>
+ project_histo(const image3d<V>& h)
+ {
+ image2d<A> h_2d_a(h.nrows(), h.ncols());
+ accu::image::init(h_2d_a);
+
+ accu::image::take( unproject( h_2d_a,
+ h.domain(),
+ fun::v2v::projection<point3d, Direction>() ).rw(),
+ h );
+
+ return accu::image::to_result(h_2d_a);
+ }
+
+ }
+}
Index: trunk/milena/sandbox/folio/mln/histo/compute_histo_3d.hh
===================================================================
--- trunk/milena/sandbox/folio/mln/histo/compute_histo_3d.hh (revision 4172)
+++ trunk/milena/sandbox/folio/mln/histo/compute_histo_3d.hh (revision 4173)
@@ -1,12 +1,34 @@
-/*!
- * \file compute_histo_3d.cc
- * \author etiennefolio <ornthalas(a)gmail.com>
- */
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to produce
+// an executable, this file does not by itself cause the resulting
+// executable to be covered by the GNU General Public License. This
+// exception does not however invalidate any other reasons why the
+// executable file might be covered by the GNU General Public License.
+
#include <mln/core/image/image2d.hh>
#include <mln/core/image/image3d.hh>
#include <mln/trait/value/comp.hh>
+
namespace mln
{
namespace histo