Olena-patches
Threads by month
- ----- 2025 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
May 2009
- 11 participants
- 312 discussions
26 May '09
#96: Update Olena's Web site for Olena 1.0
-----------------------+----------------------------------------------------
Reporter: levill_r | Owner: Olena Team
Type: task | Status: new
Priority: critical | Milestone: Olena 1.0
Component: Web | Version: 1.0
Resolution: | Keywords: organization
-----------------------+----------------------------------------------------
Changes (by levill_r):
* keywords: => organization
Old description:
> Update http://olena.lrde.epita.fr (TWiki site).
> * Create/update the release page.
> * Update the main page.
>
> * Don't forget to announce the release
> * on LRDE's Web site;
> * to the `annonce` mailing list.
>
> * Reformat to follow this new outline (from the May 26, 2009 meeting):
> {{{
> *** Home
> **** Overview
> Description rapide
> Objectifs
> Composants
> etc.
> **** News
>
> *** Demos
> **** Morphers
> **** Morpho Math
> Support du papier ISMM'09.
>
> *** Download
> **** Sources
> **** Installing
>
> *** Documentation
> **** Tutorial
> **** Publications
> **** Related Links
> **** Quick Tour
> **** Presentation
> **** White Paper
> **** Contents / What's in it? / What's inside?
> **** Features
> **** Platform Architecture
> **** Reference documentation
>
> *** FAQ
>
> *** Platform Components
> À base de liens et d'inclusions de pages.
> **** Swilena
> **** SCRIBO
> **** ICDAR
>
> *** Development
> Ou encore:
> Contributing
> For Developers
> Developers' Corners
>
> *** Contact
>
> *** About
> **** Contributors
> **** History
> **** License
>
> *** Plan du site
> }}}
New description:
Update http://olena.lrde.epita.fr (TWiki site).
* Create/update the release page.
* Update the main page.
* Don't forget to announce the release
* on LRDE's Web site;
* to the `annonce` mailing list.
* Reformat to follow this new outline (from the May 26, 2009 meeting):
1. Home
* Overview
* Short Description
* Goals
* Components
* News
1. Demos
* Morphers Examples
* Mathematical Morphology Examples
* Supporting example for the ISMM'09 paper.
1. Download
* Binary Distributions?
* Source Distributions
* Source Repository Access (see also Development)
* Installing
1. Documentation
* Tutorial
* Publications
* Related Links
* Quick Tour
* Presentation
* White Paper
* Contents / What's In It? / What's Inside?
* Features
* Platform Architecture
* Reference Documentation
1. FAQ
1. Platform Components (using links and inclusions)
* Milena
* Swilena
* SCRIBO
* ICDAR
1. Development (or ''Contributing'' or ''For Developers'' or
''Developers' Corners''
1. Contact
1. About
* Contributors
* History
* License
1. Site Map
--
Comment:
Turn the outline into lists.
Translate French parts of the outline into English.
--
Ticket URL: <https://trac.lrde.org/olena/ticket/96#comment:3>
Olena <http://olena.lrde.epita.fr>
Olena, a generic and efficient C++ image processing library.
1
0
26 May '09
#96: Update Olena's Web site for Olena 1.0
-----------------------+----------------------------------------------------
Reporter: levill_r | Owner: Olena Team
Type: task | Status: new
Priority: critical | Milestone: Olena 1.0
Component: Web | Version: 1.0
Resolution: | Keywords:
-----------------------+----------------------------------------------------
Changes (by levill_r):
* priority: major => critical
* component: Olena => Web
Old description:
> Update http://olena.lrde.epita.fr (TWiki site).
> * Create/update the release page.
> * Update the main page.
>
> * Don't forget to announce the release
> * on LRDE's Web site;
> * to the `annonce` mailing list.
New description:
Update http://olena.lrde.epita.fr (TWiki site).
* Create/update the release page.
* Update the main page.
* Don't forget to announce the release
* on LRDE's Web site;
* to the `annonce` mailing list.
* Reformat to follow this new outline (from the May 26, 2009 meeting):
{{{
*** Home
**** Overview
Description rapide
Objectifs
Composants
etc.
**** News
*** Demos
**** Morphers
**** Morpho Math
Support du papier ISMM'09.
*** Download
**** Sources
**** Installing
*** Documentation
**** Tutorial
**** Publications
**** Related Links
**** Quick Tour
**** Presentation
**** White Paper
**** Contents / What's in it? / What's inside?
**** Features
**** Platform Architecture
**** Reference documentation
*** FAQ
*** Platform Components
À base de liens et d'inclusions de pages.
**** Swilena
**** SCRIBO
**** ICDAR
*** Development
Ou encore:
Contributing
For Developers
Developers' Corners
*** Contact
*** About
**** Contributors
**** History
**** License
*** Plan du site
}}}
--
Comment:
Add a new outline.
--
Ticket URL: <https://trac.lrde.org/olena/ticket/96#comment:2>
Olena <http://olena.lrde.epita.fr>
Olena, a generic and efficient C++ image processing library.
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2009-05-25 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Add mln::morpho::closing::sum().
* mln/morpho/closing/all.hh: Add entry for mln::morpho::closing::sum
* mln/morpho/closing/sum.hh: New closing based on morpho sum.
---
all.hh | 1
sum.hh | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 85 insertions(+)
Index: trunk/milena/mln/morpho/closing/sum.hh
===================================================================
--- trunk/milena/mln/morpho/closing/sum.hh (revision 0)
+++ trunk/milena/mln/morpho/closing/sum.hh (revision 3872)
@@ -0,0 +1,84 @@
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory
+// (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library 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 this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library 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.
+
+#ifndef MLN_MORPHO_CLOSING_SUM_HH
+# define MLN_MORPHO_CLOSING_SUM_HH
+
+/// \file mln/morpho/closing/sum.hh
+///
+/// Morphological sum closing.
+
+# include <mln/morpho/closing/leveling.hh>
+# include <mln/morpho/attribute/sum.hh>
+
+
+namespace mln
+{
+
+ namespace morpho
+ {
+
+ namespace closing
+ {
+
+ /// Morphological sum closing.
+ template <typename I, typename N>
+ mln_concrete(I)
+ sum(const Image<I>& input, const Neighborhood<N>& nbh,
+ unsigned lambda);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I, typename N>
+ inline
+ mln_concrete(I)
+ sum(const Image<I>& input, const Neighborhood<N>& nbh,
+ unsigned lambda)
+ {
+ trace::entering("morpho::closing::sum");
+
+ mln_precondition(exact(input).is_valid());
+
+ mln_concrete(I) output;
+ output = closing::leveling(input, nbh, attribute::sum<I, float>(), lambda);
+
+ trace::exiting("morpho::closing::sum");
+ return output;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::morpho::closing
+
+ } // end of namespace mln::morpho
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MORPHO_CLOSING_SUM_HH
Index: trunk/milena/mln/morpho/closing/all.hh
===================================================================
--- trunk/milena/mln/morpho/closing/all.hh (revision 3871)
+++ trunk/milena/mln/morpho/closing/all.hh (revision 3872)
@@ -39,6 +39,7 @@
#include <mln/morpho/closing/height.hh>
#include <mln/morpho/closing/leveling.hh>
#include <mln/morpho/closing/structural.hh>
+#include <mln/morpho/closing/sum.hh>
#include <mln/morpho/closing/volume.hh>
1
0
25 May '09
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog:
2009-05-25 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Change processing chain, now filter before normalization.
* fabien/igr/Makefile: Add filter target.
* fabien/igr/filter.cc: New tool for filtering input.
* fabien/igr/fixed_seg/main.cc: Update closing to
closing::sum
* fabien/igr/point_filtering/main.cc: Minor update.
---
Makefile | 5 +
filter.cc | 232 ++++++++++++++++++++++++++++++++++++++++++++++++
fixed_seg/main.cc | 146 +++++++-----------------------
point_filtering/main.cc | 29 +++---
4 files changed, 287 insertions(+), 125 deletions(-)
Index: trunk/milena/sandbox/fabien/igr/Makefile
===================================================================
--- trunk/milena/sandbox/fabien/igr/Makefile (revision 3870)
+++ trunk/milena/sandbox/fabien/igr/Makefile (revision 3871)
@@ -67,6 +67,11 @@
#####################
+filter: filter.cc
+ ${CXX} -I../../../ ${CXXFLAGS} $^ -o filter
+
+#####################
+
clean:
rm -rf *.dump *.p?m *.plot *.log *.csv *.dSYM
rm seg2d seg3d wsd2d wsd3d nbasins_finder grad clo_vol wst graph med thres matlab time_max first_slice_dicom
Index: trunk/milena/sandbox/fabien/igr/point_filtering/main.cc
===================================================================
--- trunk/milena/sandbox/fabien/igr/point_filtering/main.cc (revision 3870)
+++ trunk/milena/sandbox/fabien/igr/point_filtering/main.cc (revision 3871)
@@ -9,6 +9,7 @@
#include <mln/morpho/closing/structural.hh>
#include <mln/morpho/opening/structural.hh>
#include <mln/util/array.hh>
+#include <mln/win/segment1d.hh>
using namespace mln;
@@ -19,6 +20,7 @@
if (argc != 2)
{
std::cout << "Usage: " << argv[0] << "point.plot" << std::endl;
+ return 1;
}
util::array<float> arr;
@@ -30,16 +32,17 @@
io::plot::save(ima, "raw.plot");
// Morpho filtering.
- window1d win_1;
- win_1
- .insert(-2)
- .insert(-1)
- .insert(0)
- .insert(1)
- .insert(2);
+ win::segment1d seg3(3);
+ win::segment1d seg5(5);
+ win::segment1d seg7(7);
+ win::segment1d seg9(9);
+ win::segment1d seg11(11);
+ win::segment1d seg13(13);
+ win::segment1d seg15(15);
+ win::segment1d seg21(21);
- image1d<float> opening_ima = morpho::opening::structural(ima, win_1);
- image1d<float> closing_ima = morpho::closing::structural(ima, win_1);
+ image1d<float> opening_ima = morpho::opening::structural(ima, seg21);
+ image1d<float> closing_ima = morpho::closing::structural(ima, seg21);
image1d<accu::mean<float> > result;
@@ -52,8 +55,8 @@
io::plot::save(ima_morpho, "morpho.plot");
// Morpho (again).
- opening_ima = morpho::opening::structural(ima_morpho, win_1);
- closing_ima = morpho::closing::structural(ima_morpho, win_1);
+ opening_ima = morpho::opening::structural(ima_morpho, seg13);
+ closing_ima = morpho::closing::structural(ima_morpho, seg13);
initialize(result, ima_morpho);
@@ -64,8 +67,8 @@
io::plot::save(ima_morpho2, "morpho2.plot");
// Morpho (the return of the revenge).
- opening_ima = morpho::opening::structural(ima_morpho2, win_1);
- closing_ima = morpho::closing::structural(ima_morpho2, win_1);
+ opening_ima = morpho::opening::structural(ima_morpho2, seg5);
+ closing_ima = morpho::closing::structural(ima_morpho2, seg5);
initialize(result, ima_morpho2);
Index: trunk/milena/sandbox/fabien/igr/fixed_seg/main.cc
===================================================================
--- trunk/milena/sandbox/fabien/igr/fixed_seg/main.cc (revision 3870)
+++ trunk/milena/sandbox/fabien/igr/fixed_seg/main.cc (revision 3871)
@@ -19,7 +19,6 @@
#include <mln/value/int_u12.hh>
#include <mln/value/label_16.hh>
#include <mln/value/rgb8.hh>
-#include <mln/value/float01_8.hh>
#include <mln/accu/sum.hh>
#include <mln/accu/mean.hh>
@@ -41,13 +40,14 @@
#include <mln/math/diff_abs.hh>
#include <mln/morpho/dilation.hh>
#include <mln/morpho/erosion.hh>
-#include <mln/morpho/closing/area.hh>
+#include <mln/morpho/closing/sum.hh>
#include <mln/morpho/closing/structural.hh>
#include <mln/morpho/opening/structural.hh>
#include <mln/morpho/elementary/gradient.hh>
#include <mln/morpho/watershed/flooding.hh>
#include <mln/pw/all.hh>
#include <mln/util/array.hh>
+#include <mln/win/segment1d.hh>
#include <mln/world/inter_pixel/display_edge.hh>
#include <mln/world/inter_pixel/compute.hh>
@@ -65,7 +65,6 @@
using value::int_u8;
using value::int_u12;
using value::label_16;
-using value::float01_8;
const float saturation = 1.0;
@@ -74,18 +73,6 @@
namespace mln
{
- struct int_u12_from_float : Function_v2v< int_u12_from_float >
- {
- typedef value::int_u12 result;
- result operator()(float f) const
- {
- mln_precondition(f >= 0.f && f <= 1.f);
- unsigned i = f / saturation * 4095;
- return i > 4095 ? 4095 : i;
- }
- };
-
-
template <typename I>
void io_save_edges_int_u12(const I& input,
value::int_u8 bg,
@@ -107,21 +94,16 @@
// Mean image.
//------------
+
template <typename V>
inline
image1d<float>
-mean_image(image1d<V>& input)
+mean_image(image1d<V>& input, unsigned seg_size)
{
- window1d win_1;
- win_1
- .insert(-2)
- .insert(-1)
- .insert(0)
- .insert(1)
- .insert(2);
+ win::segment1d seg(seg_size);
- image1d<V> closing_ima = morpho::closing::structural(input, win_1);
- image1d<V> opening_ima = morpho::opening::structural(input, win_1);
+ image1d<V> closing_ima = morpho::closing::structural(input, seg);
+ image1d<V> opening_ima = morpho::opening::structural(input, seg);
image1d<accu::mean<float> > result;
@@ -166,19 +148,21 @@
res /= std::max(sum_v1, sum_v2);
res = 1 - res;
- res = res * 4095;
+ res = res * (4095 / saturation);
+ if (res > 4095)
+ return 4095;
return (int) res;
}
} dist;
-/*struct dist_morpho_t : Function_vv2v<dist_morpho_t>
+struct dist_morpho_t : Function_vv2v<dist_morpho_t>
{
- typedef float result;
+ typedef int_u12 result;
template <typename V>
- float operator()(util::array<V> v1, util::array<V> v2) const
+ int_u12 operator()(util::array<V> v1, util::array<V> v2) const
{
float res = 0.f;
@@ -186,12 +170,16 @@
image1d<V> tmp_ima;
convert::from_to(v1, tmp_ima);
- image1d<float> morpho_ima = mean_image(tmp_ima);
+ image1d<float> morpho_ima = mean_image(tmp_ima, 15);
+ morpho_ima = mean_image(morpho_ima, 11);
+ morpho_ima = mean_image(morpho_ima, 7);
float sum_v1 = level::compute(accu_sum, morpho_ima);
image1d<V> tmp_ima2;
convert::from_to(v2, tmp_ima2);
- image1d<float> morpho_ima2 = mean_image(tmp_ima2);
+ image1d<float> morpho_ima2 = mean_image(tmp_ima2, 15);
+ morpho_ima2 = mean_image(tmp_ima2, 11);
+ morpho_ima2 = mean_image(tmp_ima2, 7);
float sum_v2 = level::compute(accu_sum, morpho_ima2);
mln_piter(image1d<float>) p(morpho_ima.domain());
@@ -202,10 +190,14 @@
return 1;
res /= std::max(sum_v1, sum_v2);
+ res = 1 - res;
+ res = res * (4095 / saturation);
+ if (res > 4095)
+ return 4095;
- return 1 - res;
+ return res;
}
-} dist_morpho;*/
+} dist_morpho;
@@ -252,18 +244,16 @@
// Edges distance computation.
image_if<image2d<int_u12>, world::inter_pixel::is_separator> edges;
- //if (!is_smooth)
+ if (!is_smooth)
edges = world::inter_pixel::compute(imax, dist);
- //else
- // edges = world::inter_pixel::compute(imax, dist_morpho);
- //io::dump::save(edges.unmorph_(), "edges.dump");
- //mln_VAR(d, level::transform(edges, int_u12_from_float()));
+ else
+ edges = world::inter_pixel::compute(imax, dist_morpho);
io_save_edges_int_u12(edges, 0, "dist.pgm");
// Closing.
- /*mln_VAR(d_clo, morpho::closing::area(d, world::inter_pixel::e2e(), lambda));
- //io_save_edges_int_u12(d_clo, 0, "d_clo.pgm");
+ mln_VAR(d_clo, morpho::closing::sum(edges, world::inter_pixel::e2e(), lambda));
+ io_save_edges_int_u12(d_clo, 0, "d_clo.pgm");
// Watershed.
@@ -271,11 +261,11 @@
L nbasins;
mln_VAR(wst, morpho::watershed::flooding(d_clo, world::inter_pixel::e2e(), nbasins));
- std::cout << "nbasins: " << nbasins << std::endl;*/
+ std::cout << "nbasins: " << nbasins << std::endl;
- /*mln_VAR(w_all, wst.unmorph_());
- io::dump::save(w_all, "watershed_edges.dump");
+ mln_VAR(w_all, wst.unmorph_());
+ //io::dump::save(w_all, "watershed_edges.dump");
//data::fill((w | (!world::inter_pixel::is_separator())).rw(), nbasins.next());
mln_VAR(w_pixels, w_all | world::inter_pixel::is_pixel());
data::paste(morpho::dilation(extend(w_pixels, pw::value(w_all)), c4().win()), w_all);
@@ -284,7 +274,7 @@
data::paste(morpho::erosion(extend(w_dots, pw::value(w_all)), c4().win()), w_all);
//io::ppm::save(labeling::colorize(value::rgb8(), w, nbasins.next()), "result.ppm");
- io::pgm::save(labeling::wrap(int_u8(), w_all), "watershed.pgm");*/
+ io::pgm::save(labeling::wrap(int_u8(), w_all), "watershed.pgm");
@@ -326,74 +316,6 @@
- // Deviation.
- /*util::array<accu::stat::deviation<float> > arr_dev;
- for (unsigned i = 0; i < means.nelements(); ++i)
- arr_dev.append(accu::stat::deviation<float> (means[i]));
- util::array<float> deviations = labeling::compute(arr_dev, e, wst, nbasins);
-
- // Display.
- {
- typedef image_if<image2d<float>, world::inter_pixel::is_separator> Fsx;
- Fsx ima_dev;
- initialize(ima_dev, wst);
- data::paste(wst, ima_dev);
- for (unsigned i = 1; i < deviations.nelements(); ++i)
- data::fill((ima_dev | pw::value(ima_dev) == pw::cst(i)).rw(), deviations[i]);
- mln_VAR(display_dev, world::inter_pixel::display_edge(ima_dev.unmorph_(), 0.0, 3));
- io::pgm::save(level::stretch(int_u8(), display_dev), "05_dev.pgm");
- }*/
-
-
-
- // Plots labels.
- /*image2d<L> w_simple = world::inter_pixel::full2image(w_all);
- plot_label(input, w_simple, 191u);
- plot_label(input, w_simple, 171u);
- plot_label(input, w_simple, 188u);
-
- plot_label(input, w_simple, 16u);
-
- plot_label(input, w_simple, 187u);*/
-
-
-
-
-
-
-
-
-
- /*mln_VAR(clo, morpho::closing::volume(edges | world::inter_pixel::dim2::is_edge(), world::inter_pixel::e2e(), atoi(argv[2])));
-
- // Debug.
- //debug::println("clo", clo);
-
- // Display.
- image2d<float> display_ima2 = world::inter_pixel::display_edge(clo.unmorph_(), 0.0, 3);
- io::pgm::save(level::stretch(int_u8(), display_ima2), "edges2.pgm");
-
- // Watershed.
- typedef label_16 L;
- L nbasins;
- mln_VAR(wst, morpho::watershed::flooding(clo, world::inter_pixel::e2e(), nbasins));
-
- // Debug.
- //debug::println("wst", wst);
-
- // Extension.
- image2d<L> w_all = wst.unmorph_();
- // edges -> pixel
- mln_VAR(w_pixels, w_all | world::inter_pixel::dim2::is_pixel());
- data::paste(morpho::dilation(extend(w_pixels, pw::value(w_all)), c4().win()), w_all);
- // edges -> dots
- mln_VAR(w_dots, w_all | world::inter_pixel::dim2::is_dot());
- data::paste(morpho::erosion(extend(w_dots, pw::value(w_all)), c4().win()), w_all);
-
-
- // Save labels map.
- std::cout << "nbasins: " << nbasins << std::endl;
- io::dump::save(wst.unmorph_(), "watershed_fixed.dump");*/
return 0;
}
Index: trunk/milena/sandbox/fabien/igr/filter.cc
===================================================================
--- trunk/milena/sandbox/fabien/igr/filter.cc (revision 0)
+++ trunk/milena/sandbox/fabien/igr/filter.cc (revision 3871)
@@ -0,0 +1,232 @@
+#include <algorithm>
+
+#include <mln/core/image/image1d.hh>
+#include <mln/core/alias/window1d.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/neighb2d.hh>
+#include <mln/core/image/image3d.hh>
+#include <mln/core/image/slice_image.hh>
+#include <mln/core/image/image_if.hh>
+#include <mln/core/routine/duplicate.hh>
+#include <mln/core/routine/extend.hh>
+#include <mln/core/var.hh>
+
+#include <mln/io/dump/all.hh>
+#include <mln/io/pgm/save.hh>
+#include <mln/io/ppm/save.hh>
+
+#include <mln/value/int_u8.hh>
+#include <mln/value/int_u12.hh>
+#include <mln/value/label_16.hh>
+#include <mln/value/rgb8.hh>
+
+#include <mln/accu/sum.hh>
+#include <mln/accu/mean.hh>
+#include <mln/accu/image/all.hh>
+#include <mln/accu/stat/deviation.hh>
+#include <mln/arith/div.hh>
+#include <mln/data/fill.hh>
+#include <mln/data/paste.hh>
+#include <mln/debug/quiet.hh>
+#include <mln/convert/from_to.hh>
+#include <mln/fun/v2v/fit.hh>
+#include <mln/labeling/compute.hh>
+#include <mln/labeling/wrap.hh>
+#include <mln/level/compute.hh>
+#include <mln/level/convert.hh>
+#include <mln/level/stretch.hh>
+#include <mln/make/image2d.hh>
+#include <mln/make/w_window1d.hh>
+#include <mln/math/diff_abs.hh>
+#include <mln/morpho/dilation.hh>
+#include <mln/morpho/erosion.hh>
+#include <mln/morpho/closing/sum.hh>
+#include <mln/morpho/closing/structural.hh>
+#include <mln/morpho/opening/structural.hh>
+#include <mln/morpho/elementary/gradient.hh>
+#include <mln/morpho/watershed/flooding.hh>
+#include <mln/pw/all.hh>
+#include <mln/util/array.hh>
+#include <mln/win/segment1d.hh>
+
+#include <mln/world/inter_pixel/display_edge.hh>
+#include <mln/world/inter_pixel/compute.hh>
+#include <mln/world/inter_pixel/immerse.hh>
+#include <mln/world/inter_pixel/neighb2d.hh>
+#include <mln/world/inter_pixel/all.hh>
+
+#include <mln/labeling/colorize.hh>
+#include <mln/debug/println.hh>
+#include <mln/trace/quiet.hh>
+
+
+using namespace mln;
+using value::int_u8;
+using value::int_u12;
+using value::label_16;
+
+
+
+
+// Mean image.
+//------------
+
+template <typename V>
+inline
+image1d<float>
+mean_image(image1d<V>& input, unsigned seg_size)
+{
+ win::segment1d seg(seg_size);
+
+ image1d<V> closing_ima = morpho::closing::structural(input, seg);
+ image1d<V> opening_ima = morpho::opening::structural(input, seg);
+
+ image1d<accu::mean<float> > result;
+
+ initialize(result, input);
+
+ accu::image::init(result);
+ accu::image::take(result, closing_ima);
+ accu::image::take(result, opening_ima);
+
+ return accu::image::to_result(result);
+}
+
+
+
+// Distance function.
+//-------------------
+
+struct dist_t : Function_vv2v<dist_t>
+{
+ typedef int_u12 result;
+
+ template <typename V>
+ int_u12 operator()(util::array<V> v1, util::array<V> v2) const
+ {
+ float res = 0.f;
+
+ for (unsigned i = 0; i < v1.nelements(); ++i)
+ res += std::min(v1[i], v2[i]);
+
+ image1d<V> tmp_ima;
+ image1d<V> tmp_ima2;
+ accu::sum<V> accu_sum;
+
+ convert::from_to(v1, tmp_ima);
+ float sum_v1 = level::compute(accu_sum, tmp_ima);
+
+ convert::from_to(v2, tmp_ima2);
+ float sum_v2 = level::compute(accu_sum, tmp_ima2);
+
+ if (sum_v1 == 0 && sum_v2 == 0)
+ return 1;
+
+ res /= std::max(sum_v1, sum_v2);
+ res = 1 - res;
+ res = res * 4095;
+ if (res > 4095)
+ return 4095;
+
+ return (int) res;
+ }
+} dist;
+
+
+struct dist_morpho_t : Function_vv2v<dist_morpho_t>
+{
+ typedef int_u12 result;
+
+ template <typename V>
+ int_u12 operator()(util::array<V> v1, util::array<V> v2) const
+ {
+ float res = 0.f;
+
+ accu::sum<V> accu_sum;
+
+ image1d<V> tmp_ima;
+ convert::from_to(v1, tmp_ima);
+ image1d<float> morpho_ima = mean_image(tmp_ima, 15);
+ morpho_ima = mean_image(morpho_ima, 11);
+ morpho_ima = mean_image(morpho_ima, 7);
+ float sum_v1 = level::compute(accu_sum, morpho_ima);
+
+ image1d<V> tmp_ima2;
+ convert::from_to(v2, tmp_ima2);
+ image1d<float> morpho_ima2 = mean_image(tmp_ima2, 15);
+ morpho_ima2 = mean_image(tmp_ima2, 11);
+ morpho_ima2 = mean_image(tmp_ima2, 7);
+ float sum_v2 = level::compute(accu_sum, morpho_ima2);
+
+ mln_piter(image1d<float>) p(morpho_ima.domain());
+ for_all(p)
+ res += std::min(morpho_ima(p), morpho_ima2(p));
+
+ if (sum_v1 == 0 && sum_v2 == 0)
+ return 1;
+
+ res /= std::max(sum_v1, sum_v2);
+ res = 1 - res;
+ res = res * 4095;
+ if (res > 4095)
+ return 4095;
+
+ return res;
+ }
+} dist_morpho;
+
+
+
+
+
+
+int usage(const char* bin)
+{
+ std::cout << "Usage: " << bin << " input.dump output.dump" << std::endl;
+ return 1;
+}
+
+int main(int argc, char* argv[])
+{
+ if (argc != 3)
+ return usage(argv[0]);
+
+ // Initialization.
+ typedef int_u12 input_type;
+ image3d<input_type> input;
+ io::dump::load(input, argv[1]);
+ int min_slice = input.bbox().pmin().sli();
+ int max_slice = input.bbox().pmax().sli();
+ typedef image2d<util::array<input_type> > I;
+ I ima_arr;
+ initialize(ima_arr, slice(input, 0));
+ for (int i = min_slice; i <= max_slice; ++i)
+ {
+ image2d<input_type> tmp_slice = duplicate(slice(input, i));
+ mln_piter_(image2d<input_type>) p(tmp_slice.domain());
+ for_all(p)
+ ima_arr(p).append(tmp_slice(p));
+ }
+
+
+ image3d<float> output;
+ initialize(output, input);
+
+ mln_piter_(I) p(ima_arr.domain());
+ for_all(p)
+ {
+ image1d<input_type> tmp_ima;
+ convert::from_to(ima_arr(p), tmp_ima);
+ image1d<float> morpho_ima = mean_image(tmp_ima, 15);
+ morpho_ima = mean_image(morpho_ima, 11);
+ morpho_ima = mean_image(morpho_ima, 7);
+
+ for (int i = min_slice; i <= max_slice; ++i)
+ output.at_(i, p.row(), p.col()) = morpho_ima.at_(i - min_slice);
+ }
+
+
+ io::dump::save(output, argv[2]);
+
+ return 0;
+}
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Import functions value<->index from sandbox.
* sandbox/theo/experimental/histo_image.cc: Copy as...
* mln/fun/i2v/value_at_index.hh: ...this new file.
(value_at_index): Keep only this, layout, and cleanup.
* mln/fun/i2v/all.hh: Update.
* tests/fun/i2v/array.cc: New.
* tests/fun/i2v/value_at_index.cc: New.
* tests/fun/i2v/all_to.cc: New.
* tests/fun/i2v/Makefile.am: Update.
* mln/fun/v2i: New directory.
* sandbox/theo/experimental/histo_image.cc: Copy as...
* mln/fun/v2i/index_of_value.hh: ...this new file.
(index_of_value): Keep only this, layout, and cleanup.
* mln/fun/v2i/all.hh: New.
* mln/fun/all.hh: Update.
* tests/fun/v2i: New directory.
* tests/fun/v2i/Makefile.am: New.
* tests/fun/v2i/index_of_value.cc: New.
mln/fun/all.hh | 5
mln/fun/i2v/all.hh | 6
mln/fun/i2v/value_at_index.hh | 435 ++++------------------------------------
mln/fun/v2i/all.hh | 57 +++++
mln/fun/v2i/index_of_value.hh | 430 +++++----------------------------------
tests/fun/i2v/Makefile.am | 11 +
tests/fun/i2v/all_to.cc | 44 ++++
tests/fun/i2v/array.cc | 48 ++++
tests/fun/i2v/value_at_index.cc | 57 +++++
tests/fun/v2i/Makefile.am | 10
tests/fun/v2i/index_of_value.cc | 56 +++++
11 files changed, 396 insertions(+), 763 deletions(-)
Index: mln/fun/i2v/value_at_index.hh
--- mln/fun/i2v/value_at_index.hh (revision 3867)
+++ mln/fun/i2v/value_at_index.hh (working copy)
@@ -1,421 +1,90 @@
-#include <mln/value/int_u8.hh>
-#include <mln/value/int_s.hh>
-#include <mln/value/rgb8.hh>
-#include <mln/trait/value/comp.hh>
-
-#include <mln/core/alias/box1d.hh>
-#include <mln/core/image/image1d.hh>
-#include <mln/core/image/image3d.hh>
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library 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 this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library 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.
+
+#ifndef MLN_FUN_I2V_VALUE_AT_INDEX_HH
+# define MLN_FUN_I2V_VALUE_AT_INDEX_HH
+
+/// \file mln/fun/i2v/value_at_index.hh
+///
+/// \brief File that define a function that gives an index per value.
#include <mln/core/concept/function.hh>
-#include <mln/metal/ands.hh>
-
+#include <mln/trait/value_.hh>
namespace mln
{
-
- // -------------------------------------------------- fun
-
-
namespace fun
{
- // . . . . . . . . . . . . . . . v2v:: value <-> index
-
- // This is a revamp of mln/value/internal/convert.hh. It remains
- // to be updated with Fred's new function writting. Then we'll be
- // able to make it better, i.e., to handle the different cases
- // properly. Precisely a case for scalars with low quantization
- // (with a special encoding like quantized float, or not), a case
- // for vectors with low quant, etc.
-
- namespace v2v
- {
-
- // value -> index
-
- template <typename T>
- struct index_of_value : Function_v2v< index_of_value<T> >,
- private metal::bool_<(mln_dim(T) == 1)>::check_t
- {
- typedef unsigned result;
- unsigned operator()(const T& v) const
- {
- return unsigned( int(v) - int(mln_min(T)) );
- }
- };
-
- template <>
- struct index_of_value<bool> : Function_v2v< index_of_value<bool> >
- {
- typedef unsigned result;
- unsigned operator()(bool b) const
- {
- return b ? 1u : 0u;
- }
- };
-
- template <typename T>
- unsigned
- meta_index_of_value(const T& v)
+ namespace i2v
{
- index_of_value<T> f;
- return f(v);
- }
-
- // index -> value
template <typename T>
struct value_at_index : Function_v2v< value_at_index<T> >,
private metal::bool_<(mln_dim(T) == 1)>::check_t
{
typedef T result;
- T operator()(unsigned i) const
- {
- return T( int(mln_min(T)) + int(i) );
- }
+ T operator()(unsigned i) const;
};
template <>
struct value_at_index<bool> : Function_v2v< value_at_index<bool> >
{
typedef bool result;
- bool operator()(unsigned i) const
- {
- mln_precondition(i < 2);
- return i == 1u ? true : false;
- }
+ bool operator()(unsigned i) const;
};
- // . . . . . . . . . . . . . . . value -> point n-D
-
-
- namespace internal
- {
-
- // FIXME: It can be straightforwardly written using
- // fun::ith_component. Yet there is no test file for this
- // function.
-
- template <unsigned dim, typename T>
- struct point_from_value;
-
- template <typename T>
- struct point_from_value< 1, T >
- {
- static point1d run(const T& v)
- {
- return point1d(meta_index_of_value(v));
- }
- };
+# ifndef MLN_INCLUDE_ONLY
template <typename T>
- struct point_from_value< 2, T >
- {
- static point2d run(const T& v)
+ inline
+ T
+ value_at_index<T>::operator()(unsigned i) const
{
- return point2d(meta_index_of_value(v[0]),
- meta_index_of_value(v[1]));
- }
- };
-
- template <typename T>
- struct point_from_value< 3, T >
- {
- static point3d run(const T& v)
- {
- return point3d(meta_index_of_value(v[0]),
- meta_index_of_value(v[1]),
- meta_index_of_value(v[2]));
- }
- };
-
- } // mln::fun::v2v::internal
-
-
- template <typename T>
- struct point_from_value : Function_v2v< point_from_value<T> >
- {
- enum { d = mln_dim(T) };
- typedef mln_regular_grid_from_dim(d) G;
- typedef mln::point<G, def::coord> result;
-
- result operator()(const T& v) const
- {
- return internal::point_from_value<d,T>::run(v);
- }
-
- index_of_value<T> f_;
- };
-
- template <typename T>
- mln_result(point_from_value<T>)
- meta_point_from_value(const T& v)
- {
- point_from_value<T> f;
- return f(v);
- }
-
- } // mln::fun::v2v
-
-
-
-
- // . . . . . . . . . . . . . . . p2p::fold*
-
- namespace p2p
- {
-
- struct fold1d : Function_p2p< fold1d >
- {
- typedef point1d result;
- result operator()(const point1d& p) const
- {
- point1d tmp(p[0] % b.len(0));
- return tmp;
- }
- box1d b;
- };
-
- template <bool along_0, bool along_1>
- struct fold2d : Function_p2p< fold2d<along_0,along_1> >
- {
- typedef point2d result;
- result operator()(const point2d& p) const
- {
- point2d tmp(along_0 ? p[0] % b.len(0) : p[0],
- along_1 ? p[1] % b.len(1) : p[1]);
- return tmp;
- }
- box2d b;
- };
-
- template <bool along_0, bool along_1, bool along_2>
- struct fold3d : Function_p2p< fold3d<along_0,along_1,along_2> >
- {
- typedef point3d result;
- result operator()(const point3d& p) const
- {
- point3d tmp(along_0 ? p[0] % b.len(0) : p[0],
- along_1 ? p[1] % b.len(1) : p[1],
- along_2 ? p[2] % b.len(2) : p[2]);
- return tmp;
- }
- box3d b;
- };
-
- } // mln::fun::p2p
-
-
- } // mln::fun
-
-
- // -------------------------------------------------- value
-
-
- namespace value
- {
-
- template <unsigned n, int inf, int sup>
- struct circular
- {
- };
-
-
- namespace internal
- {
- template <typename T>
- struct is_circular_helper : metal::false_
- {};
-
- template <unsigned n, int inf, int sup>
- struct is_circular_helper< circular<n,inf,sup> > : metal::true_
- {};
-
- template <typename T>
- struct is_circular : is_circular_helper<T>::eval
- {
- };
-
- } // mln::value::internal
-
- } // mln::value
-
-
- namespace trait
- {
-
- template <unsigned n, int inf, int sup>
- struct value_< mln::value::circular<n, inf, sup> >
- {
- enum {
- dim = 1,
- nbits = n,
- card = mln_value_card_from_(n)
- };
- // ...
- };
-
- } // end of namespace trait
-
-
- // -------------------------------------------------- histo
-
-
- namespace histo
- {
-
- namespace internal
- {
-
- template <int dim, typename T>
- struct image_from_value_helper
- {
- };
-
- // dim = 1
-
- template <typename T, bool is_c>
- struct image_from_value_helper_1;
-
- template <typename T>
- struct image_from_value_helper_1< T, false >
- {
- typedef image1d<unsigned> ret;
-
- static ret get_image()
- {
- ret tmp(mln_card(T));
- return tmp;
- }
- };
-
- template <typename T>
- struct image_from_value_helper_1< T, true >
- {
- typedef void ret;
- };
-
- template <typename T>
- struct image_from_value_helper< 1, T >
- {
- enum { is_c = value::internal::is_circular<T>::value };
- typedef image_from_value_helper_1< T, is_c > helper;
- };
-
- // dim = 3
-
- template <typename C0, bool is_c0,
- typename C1, bool is_c1,
- typename C2, bool is_c2,
- typename T>
- struct image_from_value_helper_3;
-
- template <typename C0, typename C1, typename C2,
- typename T>
- struct image_from_value_helper_3< C0, false,
- C1, false,
- C2, false,
- T >
- {
- typedef image3d<unsigned> ret;
- static ret get_image()
- {
- ret tmp(mln_card(C0), mln_card(C1), mln_card(C2));
- return tmp;
+ return T( int(mln_min(T)) + int(i) );
}
- };
-
- template <typename C0, typename C1, typename C2,
- typename T>
- struct image_from_value_helper_3< C0, true,
- C1, false,
- C2, false,
- T >
- {
- typedef void ret;
- };
- template <typename T>
- struct image_from_value_helper< 3, T >
- {
- typedef mln_trait_value_comp(T, 0) C0;
- typedef mln_trait_value_comp(T, 1) C1;
- typedef mln_trait_value_comp(T, 2) C2;
- typedef image_from_value_helper_3< C0, value::internal::is_circular<C0>::value,
- C1, value::internal::is_circular<C1>::value,
- C2, value::internal::is_circular<C2>::value,
- T > helper;
- };
-
- template <typename T>
- struct image_from_value_ // Entry point.
- {
- typedef typename image_from_value_helper<mln_dim(T), T>::helper helper;
- };
-
-
- } // mln::histo::internal
-
- template <typename T>
- struct image_from_value : internal::image_from_value_<T>::helper
+ inline
+ bool
+ value_at_index<bool>::operator()(unsigned i) const
{
- };
-
-
-
- // First code: the result of this function shall be replaced by
- // an histo::image<T> where T is mln_value(I). As a consequence,
- // we will not have to call meta_point_from_value...
-
- template <typename I>
- typename image_from_value<mln_value(I)>::ret
- compute_image(const Image<I>& input_)
- {
- const I& input = exact(input_);
- typedef image_from_value<mln_value(I)> helper;
- typename helper::ret h = helper::get_image();
-
- mln_piter(I) p(input.domain());
- for_all(p)
- ++h( fun::v2v::meta_point_from_value(input(p)) );
-
- return h;
+ mln_precondition(i < 2);
+ return i == 1u ? true : false;
}
- } // mln::histo
-
-} // mln
+# endif // ! MLN_INCLUDE_ONLY
+ } // end of namespace mln::fun::i2v
-int main()
-{
- using namespace mln;
+ } // end of namespace mln::fun
- {
- typedef bool T;
- std::cout << histo::image_from_value<T>::get_image().domain() << std::endl;
- }
+} // end of namespace mln
- {
- typedef unsigned char T;
- std::cout << histo::image_from_value<T>::get_image().domain() << std::endl;
- }
-
- {
- typedef value::int_s<3> T;
- std::cout << histo::image_from_value<T>::get_image().domain() << std::endl;
- }
-
- {
- typedef value::rgb8 T;
- std::cout << histo::image_from_value<T>::get_image().domain() << std::endl;
- }
-
- {
- // typedef value::circular<8,0,9> T;
- }
-}
+#endif // ! MLN_FUN_I2V_VALUE_AT_INDEX_HH
Property changes on: mln/fun/i2v/value_at_index.hh
___________________________________________________________________
Added: svn:mergeinfo
Index: mln/fun/i2v/all.hh
--- mln/fun/i2v/all.hh (revision 3869)
+++ mln/fun/i2v/all.hh (working copy)
@@ -31,7 +31,7 @@
/// \file mln/fun/i2v/all.hh
///
-/// File that includes all functions from index to value.
+/// \brief File that includes all integer-to-value functions.
namespace mln
@@ -40,19 +40,19 @@
namespace fun
{
- /// \brief Functions from index to value.
+ /// \brief Namespace of integer-to-value functions.
///
/// \ingroup modfun
//
namespace i2v {}
}
-
}
# include <mln/fun/i2v/all_to.hh>
# include <mln/fun/i2v/array.hh>
+# include <mln/fun/i2v/value_at_index.hh>
Index: mln/fun/v2i/index_of_value.hh
--- mln/fun/v2i/index_of_value.hh (revision 0)
+++ mln/fun/v2i/index_of_value.hh (working copy)
@@ -1,421 +1,101 @@
-#include <mln/value/int_u8.hh>
-#include <mln/value/int_s.hh>
-#include <mln/value/rgb8.hh>
-#include <mln/trait/value/comp.hh>
-
-#include <mln/core/alias/box1d.hh>
-#include <mln/core/image/image1d.hh>
-#include <mln/core/image/image3d.hh>
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library 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 this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library 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.
+
+#ifndef MLN_FUN_V2I_INDEX_OF_VALUE_HH
+# define MLN_FUN_V2I_INDEX_OF_VALUE_HH
+
+/// \file mln/fun/v2i/index_of_value.hh
+///
+/// \brief File that define a function that gives an index per value.
#include <mln/core/concept/function.hh>
-#include <mln/metal/ands.hh>
-
+#include <mln/trait/value_.hh>
namespace mln
{
-
- // -------------------------------------------------- fun
-
-
namespace fun
{
- // . . . . . . . . . . . . . . . v2v:: value <-> index
-
- // This is a revamp of mln/value/internal/convert.hh. It remains
- // to be updated with Fred's new function writting. Then we'll be
- // able to make it better, i.e., to handle the different cases
- // properly. Precisely a case for scalars with low quantization
- // (with a special encoding like quantized float, or not), a case
- // for vectors with low quant, etc.
-
- namespace v2v
+ namespace v2i
{
- // value -> index
-
template <typename T>
struct index_of_value : Function_v2v< index_of_value<T> >,
private metal::bool_<(mln_dim(T) == 1)>::check_t
{
typedef unsigned result;
- unsigned operator()(const T& v) const
- {
- return unsigned( int(v) - int(mln_min(T)) );
- }
+ unsigned operator()(const T& v) const;
};
template <>
struct index_of_value<bool> : Function_v2v< index_of_value<bool> >
{
typedef unsigned result;
- unsigned operator()(bool b) const
- {
- return b ? 1u : 0u;
- }
+ unsigned operator()(bool b) const;
};
template <typename T>
unsigned
- meta_index_of_value(const T& v)
- {
- index_of_value<T> f;
- return f(v);
- }
+ meta_index_of_value(const T& v);
- // index -> value
- template <typename T>
- struct value_at_index : Function_v2v< value_at_index<T> >,
- private metal::bool_<(mln_dim(T) == 1)>::check_t
- {
- typedef T result;
- T operator()(unsigned i) const
- {
- return T( int(mln_min(T)) + int(i) );
- }
- };
-
- template <>
- struct value_at_index<bool> : Function_v2v< value_at_index<bool> >
- {
- typedef bool result;
- bool operator()(unsigned i) const
- {
- mln_precondition(i < 2);
- return i == 1u ? true : false;
- }
- };
-
-
- // . . . . . . . . . . . . . . . value -> point n-D
-
-
- namespace internal
- {
-
- // FIXME: It can be straightforwardly written using
- // fun::ith_component. Yet there is no test file for this
- // function.
-
- template <unsigned dim, typename T>
- struct point_from_value;
-
- template <typename T>
- struct point_from_value< 1, T >
- {
- static point1d run(const T& v)
- {
- return point1d(meta_index_of_value(v));
- }
- };
-
- template <typename T>
- struct point_from_value< 2, T >
- {
- static point2d run(const T& v)
- {
- return point2d(meta_index_of_value(v[0]),
- meta_index_of_value(v[1]));
- }
- };
+# ifndef MLN_INCLUDE_ONLY
template <typename T>
- struct point_from_value< 3, T >
- {
- static point3d run(const T& v)
+ inline
+ unsigned
+ index_of_value<T>::operator()(const T& v) const
{
- return point3d(meta_index_of_value(v[0]),
- meta_index_of_value(v[1]),
- meta_index_of_value(v[2]));
+ return unsigned( int(v) - int(mln_min(T)) );
}
- };
- } // mln::fun::v2v::internal
-
-
- template <typename T>
- struct point_from_value : Function_v2v< point_from_value<T> >
+ inline
+ unsigned index_of_value<bool>::operator()(bool b) const
{
- enum { d = mln_dim(T) };
- typedef mln_regular_grid_from_dim(d) G;
- typedef mln::point<G, def::coord> result;
-
- result operator()(const T& v) const
- {
- return internal::point_from_value<d,T>::run(v);
+ return b ? 1u : 0u;
}
- index_of_value<T> f_;
- };
-
template <typename T>
- mln_result(point_from_value<T>)
- meta_point_from_value(const T& v)
+ inline
+ unsigned
+ meta_index_of_value(const T& v)
{
- point_from_value<T> f;
+ index_of_value<T> f;
return f(v);
}
- } // mln::fun::v2v
-
-
-
-
- // . . . . . . . . . . . . . . . p2p::fold*
-
- namespace p2p
- {
-
- struct fold1d : Function_p2p< fold1d >
- {
- typedef point1d result;
- result operator()(const point1d& p) const
- {
- point1d tmp(p[0] % b.len(0));
- return tmp;
- }
- box1d b;
- };
-
- template <bool along_0, bool along_1>
- struct fold2d : Function_p2p< fold2d<along_0,along_1> >
- {
- typedef point2d result;
- result operator()(const point2d& p) const
- {
- point2d tmp(along_0 ? p[0] % b.len(0) : p[0],
- along_1 ? p[1] % b.len(1) : p[1]);
- return tmp;
- }
- box2d b;
- };
-
- template <bool along_0, bool along_1, bool along_2>
- struct fold3d : Function_p2p< fold3d<along_0,along_1,along_2> >
- {
- typedef point3d result;
- result operator()(const point3d& p) const
- {
- point3d tmp(along_0 ? p[0] % b.len(0) : p[0],
- along_1 ? p[1] % b.len(1) : p[1],
- along_2 ? p[2] % b.len(2) : p[2]);
- return tmp;
- }
- box3d b;
- };
-
- } // mln::fun::p2p
-
-
- } // mln::fun
-
-
- // -------------------------------------------------- value
-
-
- namespace value
- {
-
- template <unsigned n, int inf, int sup>
- struct circular
- {
- };
-
-
- namespace internal
- {
- template <typename T>
- struct is_circular_helper : metal::false_
- {};
-
- template <unsigned n, int inf, int sup>
- struct is_circular_helper< circular<n,inf,sup> > : metal::true_
- {};
-
- template <typename T>
- struct is_circular : is_circular_helper<T>::eval
- {
- };
-
- } // mln::value::internal
-
- } // mln::value
-
-
- namespace trait
- {
-
- template <unsigned n, int inf, int sup>
- struct value_< mln::value::circular<n, inf, sup> >
- {
- enum {
- dim = 1,
- nbits = n,
- card = mln_value_card_from_(n)
- };
- // ...
- };
-
- } // end of namespace trait
-
-
- // -------------------------------------------------- histo
-
-
- namespace histo
- {
-
- namespace internal
- {
-
- template <int dim, typename T>
- struct image_from_value_helper
- {
- };
-
- // dim = 1
-
- template <typename T, bool is_c>
- struct image_from_value_helper_1;
-
- template <typename T>
- struct image_from_value_helper_1< T, false >
- {
- typedef image1d<unsigned> ret;
-
- static ret get_image()
- {
- ret tmp(mln_card(T));
- return tmp;
- }
- };
-
- template <typename T>
- struct image_from_value_helper_1< T, true >
- {
- typedef void ret;
- };
-
- template <typename T>
- struct image_from_value_helper< 1, T >
- {
- enum { is_c = value::internal::is_circular<T>::value };
- typedef image_from_value_helper_1< T, is_c > helper;
- };
-
- // dim = 3
-
- template <typename C0, bool is_c0,
- typename C1, bool is_c1,
- typename C2, bool is_c2,
- typename T>
- struct image_from_value_helper_3;
-
- template <typename C0, typename C1, typename C2,
- typename T>
- struct image_from_value_helper_3< C0, false,
- C1, false,
- C2, false,
- T >
- {
- typedef image3d<unsigned> ret;
- static ret get_image()
- {
- ret tmp(mln_card(C0), mln_card(C1), mln_card(C2));
- return tmp;
- }
- };
-
- template <typename C0, typename C1, typename C2,
- typename T>
- struct image_from_value_helper_3< C0, true,
- C1, false,
- C2, false,
- T >
- {
- typedef void ret;
- };
-
- template <typename T>
- struct image_from_value_helper< 3, T >
- {
- typedef mln_trait_value_comp(T, 0) C0;
- typedef mln_trait_value_comp(T, 1) C1;
- typedef mln_trait_value_comp(T, 2) C2;
- typedef image_from_value_helper_3< C0, value::internal::is_circular<C0>::value,
- C1, value::internal::is_circular<C1>::value,
- C2, value::internal::is_circular<C2>::value,
- T > helper;
- };
-
- template <typename T>
- struct image_from_value_ // Entry point.
- {
- typedef typename image_from_value_helper<mln_dim(T), T>::helper helper;
- };
-
-
- } // mln::histo::internal
+# endif // ! MLN_INCLUDE_ONLY
- template <typename T>
- struct image_from_value : internal::image_from_value_<T>::helper
- {
- };
+ } // end of namespace mln::fun::v2i
+ } // end of namespace mln::fun
+} // end of namespace mln
- // First code: the result of this function shall be replaced by
- // an histo::image<T> where T is mln_value(I). As a consequence,
- // we will not have to call meta_point_from_value...
-
- template <typename I>
- typename image_from_value<mln_value(I)>::ret
- compute_image(const Image<I>& input_)
- {
- const I& input = exact(input_);
- typedef image_from_value<mln_value(I)> helper;
- typename helper::ret h = helper::get_image();
-
- mln_piter(I) p(input.domain());
- for_all(p)
- ++h( fun::v2v::meta_point_from_value(input(p)) );
-
- return h;
- }
-
- } // mln::histo
-
-} // mln
-
-
-int main()
-{
- using namespace mln;
-
- {
- typedef bool T;
- std::cout << histo::image_from_value<T>::get_image().domain() << std::endl;
- }
-
- {
- typedef unsigned char T;
- std::cout << histo::image_from_value<T>::get_image().domain() << std::endl;
- }
-
- {
- typedef value::int_s<3> T;
- std::cout << histo::image_from_value<T>::get_image().domain() << std::endl;
- }
-
- {
- typedef value::rgb8 T;
- std::cout << histo::image_from_value<T>::get_image().domain() << std::endl;
- }
-
- {
- // typedef value::circular<8,0,9> T;
- }
-}
+#endif // ! MLN_FUN_V2I_INDEX_OF_VALUE_HH
Property changes on: mln/fun/v2i/index_of_value.hh
___________________________________________________________________
Added: svn:mergeinfo
Index: mln/fun/v2i/all.hh
--- mln/fun/v2i/all.hh (revision 0)
+++ mln/fun/v2i/all.hh (revision 0)
@@ -0,0 +1,57 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library 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 this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library 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.
+
+#ifndef MLN_FUN_V2I_ALL_HH
+# define MLN_FUN_V2I_ALL_HH
+
+/// \file mln/fun/v2i/all.hh
+///
+/// \brief File that includes all value-to-integer functions.
+
+
+namespace mln
+{
+
+ /// Namespace of functions.
+ namespace fun
+ {
+
+ /// \brief Namespace of value-to-integer functions.
+ ///
+ /// \ingroup modfun
+ //
+ namespace v2i
+ {}
+
+ }
+}
+
+
+# include <mln/fun/v2i/index_of_value.hh>
+
+
+#endif // ! MLN_FUN_V2I_ALL_HH
Index: mln/fun/all.hh
--- mln/fun/all.hh (revision 3869)
+++ mln/fun/all.hh (working copy)
@@ -31,13 +31,13 @@
/// \file mln/fun/all.hh
///
-/// File that includes all fun-related routines.
+/// File that includes all functions.
namespace mln
{
- /// Namespace of image processing routines related to functions.
+ /// Namespace of functions.
namespace fun
{
@@ -57,6 +57,7 @@
# include <mln/fun/p2v/all.hh>
# include <mln/fun/stat/all.hh>
# include <mln/fun/v2b/all.hh>
+# include <mln/fun/v2i/all.hh>
# include <mln/fun/v2v/all.hh>
# include <mln/fun/vv2v/all.hh>
# include <mln/fun/x2p/all.hh>
Index: tests/fun/i2v/array.cc
--- tests/fun/i2v/array.cc (revision 0)
+++ tests/fun/i2v/array.cc (revision 0)
@@ -0,0 +1,48 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library 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 this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library 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.
+
+/// \file tests/fun/i2v/array.cc
+///
+/// Test on mln::fun::i2v::array.
+
+#include <mln/fun/i2v/array.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ fun::i2v::array<int> f;
+ mln_assertion(f.size() == 0u);
+
+ f.append(0);
+ mln_assertion(f(0) == 0);
+
+ f.append(1);
+ mln_assertion(f(1) == 1);
+ mln_assertion(f.size() == 2u);
+}
Index: tests/fun/i2v/Makefile.am
--- tests/fun/i2v/Makefile.am (revision 3869)
+++ tests/fun/i2v/Makefile.am (working copy)
@@ -1,3 +1,14 @@
## Process this file through Automake to create Makefile.in.
include $(top_srcdir)/milena/tests/tests.mk
+
+check_PROGRAMS = \
+ all_to \
+ array \
+ value_at_index
+
+all_to_SOURCES = all_to.cc
+array_SOURCES = array.cc
+value_at_index_SOURCES = value_at_index.cc
+
+TESTS = $(check_PROGRAMS)
Index: tests/fun/i2v/value_at_index.cc
--- tests/fun/i2v/value_at_index.cc (revision 0)
+++ tests/fun/i2v/value_at_index.cc (revision 0)
@@ -0,0 +1,57 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library 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 this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library 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.
+
+/// \file tests/fun/i2v/value_at_index.cc
+///
+/// Test on mln::fun::i2v::value_at_index.
+
+#include <mln/fun/i2v/value_at_index.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/value/int_s8.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ {
+ fun::i2v::value_at_index<bool> f;
+ mln_assertion(f(0) == false);
+ mln_assertion(f(1) == true);
+ }
+ {
+ fun::i2v::value_at_index< value::int_u8 > f;
+ mln_assertion(f( 0) == 0);
+ mln_assertion(f(255) == 255);
+ }
+ {
+ fun::i2v::value_at_index< value::int_s8 > f;
+ mln_assertion(f( 0) == -127);
+ mln_assertion(f(254) == +127);
+ }
+
+}
Index: tests/fun/i2v/all_to.cc
--- tests/fun/i2v/all_to.cc (revision 0)
+++ tests/fun/i2v/all_to.cc (revision 0)
@@ -0,0 +1,44 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library 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 this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library 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.
+
+/// \file tests/fun/i2v/all_to.cc
+///
+/// Test on mln::fun::i2v::all_to.
+
+#include <mln/fun/i2v/all_to.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ fun::i2v::all_to<int> f(51);
+
+ mln_assertion(f( 0) == 51);
+ mln_assertion(f( 1) == 51);
+ mln_assertion(f(51) == 51);
+}
Index: tests/fun/v2i/Makefile.am
--- tests/fun/v2i/Makefile.am (revision 0)
+++ tests/fun/v2i/Makefile.am (revision 0)
@@ -0,0 +1,10 @@
+## Process this file through Automake to create Makefile.in.
+
+include $(top_srcdir)/milena/tests/tests.mk
+
+check_PROGRAMS = \
+ index_of_value
+
+index_of_value_SOURCES = index_of_value.cc
+
+TESTS = $(check_PROGRAMS)
Index: tests/fun/v2i/index_of_value.cc
--- tests/fun/v2i/index_of_value.cc (revision 0)
+++ tests/fun/v2i/index_of_value.cc (revision 0)
@@ -0,0 +1,56 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library 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 this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library 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.
+
+/// \file tests/fun/v2i/index_of_value.cc
+///
+/// Test on mln::fun::v2i::index_of_value.
+
+#include <mln/fun/v2i/index_of_value.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/value/int_s8.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ {
+ fun::v2i::index_of_value<bool> f;
+ mln_assertion(f(false) == 0);
+ mln_assertion(f(true) == 1);
+ }
+ {
+ fun::v2i::index_of_value< value::int_u8 > f;
+ mln_assertion(f( 0) == 0);
+ mln_assertion(f(255) == 255);
+ }
+ {
+ fun::v2i::index_of_value< value::int_s8 > f;
+ mln_assertion(f(-127) == 0);
+ mln_assertion(f(+127) == 254);
+ }
+}
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2009-05-25 Edwin Carlinet <carlinet(a)lrde.epita.fr>
Reconstruction by erosion.
* mln/morpho/reconstruction/by_erosion/all.hh,
* mln/morpho/reconstruction/by_erosion/union_find.hh,
* mln/morpho/reconstruction/by_erosion:
Reconstruction by erosion.
* tests/morpho/reconstruction/Makefile.am,
* tests/morpho/reconstruction/by_erosion/union_find.cc,
* tests/morpho/reconstruction/by_erosion,
* tests/unit_test/unit-tests.mk:
Reconstruction by erosion test files.
---
mln/morpho/reconstruction/by_erosion/all.hh | 59 ++++
mln/morpho/reconstruction/by_erosion/union_find.hh | 280 +++++++++++++++++++
tests/morpho/reconstruction/Makefile.am | 3
tests/morpho/reconstruction/by_erosion/Makefile.am | 15 +
tests/morpho/reconstruction/by_erosion/union_find.cc | 64 ++++
tests/unit_test/unit-tests.mk | 20 +
6 files changed, 438 insertions(+), 3 deletions(-)
Index: trunk/milena/tests/morpho/reconstruction/by_erosion/Makefile.am
===================================================================
--- trunk/milena/tests/morpho/reconstruction/by_erosion/Makefile.am (revision 0)
+++ trunk/milena/tests/morpho/reconstruction/by_erosion/Makefile.am (revision 3869)
@@ -0,0 +1,15 @@
+## Process this file through Automake to create Makefile.in -*- Makefile -*-
+
+include $(top_srcdir)/milena/tests/tests.mk
+
+
+check_PROGRAMS = \
+ union_find
+
+
+union_find_SOURCES = union_find.cc
+
+
+TESTS = $(check_PROGRAMS)
+
+
Index: trunk/milena/tests/morpho/reconstruction/by_erosion/union_find.cc
===================================================================
--- trunk/milena/tests/morpho/reconstruction/by_erosion/union_find.cc (revision 0)
+++ trunk/milena/tests/morpho/reconstruction/by_erosion/union_find.cc (revision 3869)
@@ -0,0 +1,64 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library 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 this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library 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.
+
+/// \file tests/morpho/reconstruction/by_erosion/union_find.cc
+///
+/// Test on mln::morpho::reconstruction::by_erosion::union_find
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/neighb2d.hh>
+#include <mln/pw/all.hh>
+
+#include <mln/io/pgm/load.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/level/compare.hh>
+
+#include <mln/morpho/reconstruction/by_erosion/union_find.hh>
+
+#include "tests/data.hh"
+
+
+
+int main()
+{
+ using namespace mln;
+ using namespace morpho::reconstruction::by_erosion;
+
+ image2d<value::int_u8> lena, lena_2, out;
+ io::pgm::load(lena, MLN_IMG_DIR "/tiny.pgm");
+
+ {
+ out = union_find(lena, lena, c4());
+ mln_assertion(out == lena);
+ }
+
+ {
+ initialize(lena_2, lena);
+ data::fill(lena_2, lena);
+ out = union_find(lena_2, lena, c4());
+ }
+}
Property changes on: trunk/milena/tests/morpho/reconstruction/by_erosion
___________________________________________________________________
Added: svn:mergeinfo
Index: trunk/milena/tests/morpho/reconstruction/Makefile.am
===================================================================
--- trunk/milena/tests/morpho/reconstruction/Makefile.am (revision 3868)
+++ trunk/milena/tests/morpho/reconstruction/Makefile.am (revision 3869)
@@ -3,7 +3,8 @@
include $(top_srcdir)/milena/tests/tests.mk
SUBDIRS = \
- by_dilation
+ by_dilation \
+ by_erosion
TESTS = $(check_PROGRAMS)
Index: trunk/milena/tests/unit_test/unit-tests.mk
===================================================================
--- trunk/milena/tests/unit_test/unit-tests.mk (revision 3868)
+++ trunk/milena/tests/unit_test/unit-tests.mk (revision 3869)
@@ -239,6 +239,8 @@
mln_core_image_complex_window_piter \
mln_core_image_complex_windows \
mln_core_image_decorated_image \
+mln_core_image_dmorph_all \
+mln_core_image_dmorph_transformed_image \
mln_core_image_edge_image \
mln_core_image_essential \
mln_core_image_extended \
@@ -376,6 +378,8 @@
mln_core_site_set_p_run_piter \
mln_core_site_set_p_set \
mln_core_site_set_p_set_of \
+mln_core_site_set_p_transformed \
+mln_core_site_set_p_transformed_piter \
mln_core_site_set_p_vaccess \
mln_core_site_set_p_vertices \
mln_core_site_set_p_vertices_psite \
@@ -635,6 +639,8 @@
mln_io_pgm_all \
mln_io_pgm_load \
mln_io_pgm_save \
+mln_io_plot_all \
+mln_io_plot_load \
mln_io_plot_save \
mln_io_pnm_all \
mln_io_pnm_load_header \
@@ -648,7 +654,6 @@
mln_io_ppm_save \
mln_io_tiff_all \
mln_io_tiff_load \
-mln_io_tiff_save \
mln_io_txt_all \
mln_io_txt_save \
mln_labeling_all \
@@ -900,6 +905,8 @@
mln_morpho_reconstruction_all \
mln_morpho_reconstruction_by_dilation_all \
mln_morpho_reconstruction_by_dilation_union_find \
+mln_morpho_reconstruction_by_erosion_all \
+mln_morpho_reconstruction_by_erosion_union_find \
mln_morpho_skeleton_constrained \
mln_morpho_thickening \
mln_morpho_thick_miss \
@@ -1211,6 +1218,7 @@
mln_value_stack \
mln_value_super_value \
mln_value_viter \
+mln_version \
mln_win_all \
mln_win_backdiag2d \
mln_win_ball \
@@ -1490,6 +1498,8 @@
mln_core_image_complex_window_piter_SOURCES = mln_core_image_complex_window_piter.cc
mln_core_image_complex_windows_SOURCES = mln_core_image_complex_windows.cc
mln_core_image_decorated_image_SOURCES = mln_core_image_decorated_image.cc
+mln_core_image_dmorph_all_SOURCES = mln_core_image_dmorph_all.cc
+mln_core_image_dmorph_transformed_image_SOURCES = mln_core_image_dmorph_transformed_image.cc
mln_core_image_edge_image_SOURCES = mln_core_image_edge_image.cc
mln_core_image_essential_SOURCES = mln_core_image_essential.cc
mln_core_image_extended_SOURCES = mln_core_image_extended.cc
@@ -1627,6 +1637,8 @@
mln_core_site_set_p_run_piter_SOURCES = mln_core_site_set_p_run_piter.cc
mln_core_site_set_p_set_SOURCES = mln_core_site_set_p_set.cc
mln_core_site_set_p_set_of_SOURCES = mln_core_site_set_p_set_of.cc
+mln_core_site_set_p_transformed_SOURCES = mln_core_site_set_p_transformed.cc
+mln_core_site_set_p_transformed_piter_SOURCES = mln_core_site_set_p_transformed_piter.cc
mln_core_site_set_p_vaccess_SOURCES = mln_core_site_set_p_vaccess.cc
mln_core_site_set_p_vertices_SOURCES = mln_core_site_set_p_vertices.cc
mln_core_site_set_p_vertices_psite_SOURCES = mln_core_site_set_p_vertices_psite.cc
@@ -1886,6 +1898,8 @@
mln_io_pgm_all_SOURCES = mln_io_pgm_all.cc
mln_io_pgm_load_SOURCES = mln_io_pgm_load.cc
mln_io_pgm_save_SOURCES = mln_io_pgm_save.cc
+mln_io_plot_all_SOURCES = mln_io_plot_all.cc
+mln_io_plot_load_SOURCES = mln_io_plot_load.cc
mln_io_plot_save_SOURCES = mln_io_plot_save.cc
mln_io_pnm_all_SOURCES = mln_io_pnm_all.cc
mln_io_pnm_load_header_SOURCES = mln_io_pnm_load_header.cc
@@ -1899,7 +1913,6 @@
mln_io_ppm_save_SOURCES = mln_io_ppm_save.cc
mln_io_tiff_all_SOURCES = mln_io_tiff_all.cc
mln_io_tiff_load_SOURCES = mln_io_tiff_load.cc
-mln_io_tiff_save_SOURCES = mln_io_tiff_save.cc
mln_io_txt_all_SOURCES = mln_io_txt_all.cc
mln_io_txt_save_SOURCES = mln_io_txt_save.cc
mln_labeling_all_SOURCES = mln_labeling_all.cc
@@ -2151,6 +2164,8 @@
mln_morpho_reconstruction_all_SOURCES = mln_morpho_reconstruction_all.cc
mln_morpho_reconstruction_by_dilation_all_SOURCES = mln_morpho_reconstruction_by_dilation_all.cc
mln_morpho_reconstruction_by_dilation_union_find_SOURCES = mln_morpho_reconstruction_by_dilation_union_find.cc
+mln_morpho_reconstruction_by_erosion_all_SOURCES = mln_morpho_reconstruction_by_erosion_all.cc
+mln_morpho_reconstruction_by_erosion_union_find_SOURCES = mln_morpho_reconstruction_by_erosion_union_find.cc
mln_morpho_skeleton_constrained_SOURCES = mln_morpho_skeleton_constrained.cc
mln_morpho_thickening_SOURCES = mln_morpho_thickening.cc
mln_morpho_thick_miss_SOURCES = mln_morpho_thick_miss.cc
@@ -2462,6 +2477,7 @@
mln_value_stack_SOURCES = mln_value_stack.cc
mln_value_super_value_SOURCES = mln_value_super_value.cc
mln_value_viter_SOURCES = mln_value_viter.cc
+mln_version_SOURCES = mln_version.cc
mln_win_all_SOURCES = mln_win_all.cc
mln_win_backdiag2d_SOURCES = mln_win_backdiag2d.cc
mln_win_ball_SOURCES = mln_win_ball.cc
Index: trunk/milena/mln/morpho/reconstruction/by_erosion/all.hh
===================================================================
--- trunk/milena/mln/morpho/reconstruction/by_erosion/all.hh (revision 0)
+++ trunk/milena/mln/morpho/reconstruction/by_erosion/all.hh (revision 3869)
@@ -0,0 +1,59 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library 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 this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library 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.
+
+#ifndef MLN_MORPHO_RECONSTRUCTION_BY_EROSION_ALL_HH
+# define MLN_MORPHO_RECONSTRUCTION_BY_EROSION_ALL_HH
+
+
+/// \file mln/morpho/reconstruction by erosion/all.hh
+///
+/// File that includes all morphological reconstruction by erosion routines.
+
+
+namespace mln
+{
+
+ namespace morpho
+ {
+
+ namespace reconstruction
+ {
+
+ /// Namespace of morphological reconstruction by erosion routines.
+ namespace by_erosion
+ {}
+
+ }
+ }
+}
+
+
+# include <mln/morpho/reconstruction/by_erosion/union_find.hh>
+// ...
+
+
+#endif // ! MLN_MORPHO_RECONSTRUCTION_BY_EROSION_ALL_HH
Property changes on: trunk/milena/mln/morpho/reconstruction/by_erosion/all.hh
___________________________________________________________________
Added: svn:mergeinfo
Index: trunk/milena/mln/morpho/reconstruction/by_erosion/union_find.hh
===================================================================
--- trunk/milena/mln/morpho/reconstruction/by_erosion/union_find.hh (revision 0)
+++ trunk/milena/mln/morpho/reconstruction/by_erosion/union_find.hh (revision 3869)
@@ -0,0 +1,280 @@
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library 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 this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library 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.
+
+#ifndef MLN_MORPHO_RECONSTRUCTION_BY_EROSION_UNION_FIND_HH
+# define MLN_MORPHO_RECONSTRUCTION_BY_EROSION_UNION_FIND_HH
+
+# include <vector>
+# include <mln/core/concept/image.hh>
+# include <mln/core/concept/neighborhood.hh>
+# include <mln/data/fill.hh>
+# include <mln/level/compare.hh>
+# include <mln/level/sort_psites.hh>
+
+
+namespace mln
+{
+
+ namespace morpho
+ {
+
+ namespace reconstruction
+ {
+
+ namespace by_erosion
+ {
+
+
+ template <typename I, typename J, typename N>
+ mln_concrete(I)
+ union_find(const Image<I>& f, const Image<J>& g,
+ const Neighborhood<N>& nbh);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ // Tests.
+
+ namespace internal
+ {
+
+ template <typename I, typename J, typename N>
+ inline
+ void
+ union_find_tests(const Image<I>& f_, const Image<J>& g_,
+ const Neighborhood<N>& nbh_)
+ {
+ const I& f = exact(f_);
+ const J& g = exact(g_);
+ const N& nbh = exact(nbh_);
+
+ mln_precondition(f.is_valid());
+ mln_precondition(g.is_valid());
+ mln_precondition(nbh.is_valid());
+
+ mln_precondition(f.domain() == g.domain()); // FIXME: Relax?
+ mln_precondition(f >= g);
+
+ // mlc_equal(mln_value(I), mln_value(J))::check(); // FIXME: Too strong!
+ // FIXME: Also check that we have a total ordering for values.
+
+ (void) f;
+ (void) g;
+ (void) nbh;
+ }
+
+
+
+ template <typename Par>
+ inline
+ mln_site(Par) find_root(Par& parent, mln_site(Par) x)
+ {
+ if (parent(x) == x)
+ return x;
+ else
+ return parent(x) = find_root(parent, parent(x));
+ }
+
+
+ } // end of namespace mln::morpho::reconstruction::by_erosion::internal
+
+
+ // Implementations.
+
+ namespace impl
+ {
+
+ namespace generic
+ {
+
+ template <typename I, typename J, typename N>
+ inline
+ mln_concrete(I)
+ union_find(const Image<I>& f_, const Image<J>& g_,
+ const Neighborhood<N>& nbh_)
+ {
+ trace::entering("morpho::reconstruction::by_erosion::impl::generic::union_find");
+
+ const I& f = exact(f_);
+ const J& g = exact(g_);
+ const N& nbh = exact(nbh_);
+
+ internal::union_find_tests(f, g, nbh);
+
+ typedef mln_site(I) P;
+ typedef mln_value(I) V;
+
+ // Auxiliary data.
+ p_array<P> s;
+ mln_ch_value(I, bool) deja_vu;
+ mln_ch_value(I, P) parent;
+ mln_concrete(I) output;
+
+ // Initialization.
+ {
+ initialize(output, f);
+ data::fill(output, f);
+ initialize(parent, f);
+ initialize(deja_vu, f);
+ data::fill(deja_vu, false);
+
+ s = level::sort_psites_increasing(g);
+ }
+
+ // First pass.
+ {
+ for (unsigned i = 0; i < s.nsites(); ++i)
+ {
+ P p = s[i];
+ parent(p) = p; // Make-Set.
+ mln_niter(N) n(nbh, p);
+ for_all(n)
+ {
+// if (f.domain().has(n))
+// mln_invariant(deja_vu(n)
+// ==
+// (g(n) > g(p) || (g(n) == g(p)
+// && util::ord_strict(n, p))));
+ if (f.domain().has(n) && deja_vu(n))
+ {
+ // Do-Union.
+ P r = internal::find_root(parent, n);
+ if (r != p)
+ {
+ if (g(r) == g(p) || g(p) <= output(r)) // Equivalence test.
+ {
+ parent(r) = p;
+ if (output(r) < output(p))
+ output(p) = output(r); // Increasing criterion.
+ }
+ else
+ output(p) = mln_min(V);
+ }
+ }
+ }
+ deja_vu(p) = true;
+ }
+ }
+
+ // Second pass.
+ {
+ for (int i = s.nsites() - 1; i >= 0; --i)
+ {
+ P p = s[i];
+ if (parent(p) == p)
+ {
+ if (output(p) == mln_min(V))
+ output(p) = g(p);
+ }
+ else
+ output(p) = output(parent(p));
+ }
+ }
+
+ mln_postcondition(output >= f);
+ mln_postcondition(output >= g);
+
+ trace::exiting("morpho::reconstruction::by_erosion::impl::generic::union_find");
+ return output;
+ }
+
+ } // end of namespace mln::morpho::reconstruction::by_erosion::impl::generic
+
+ } // end of namespace mln::morpho::reconstruction::by_erosion::impl
+
+
+ // Dispatch.
+
+ namespace internal
+ {
+
+ template <typename I, typename J, typename N>
+ inline
+ mln_concrete(I)
+ union_find_dispatch(trait::image::kind::logic,
+ const Image<I>& f, const Image<J>& g,
+ const Neighborhood<N>& nbh)
+ {
+ // FIXME: Not yet implemented.
+ }
+
+ template <typename I, typename J, typename N>
+ inline
+ mln_concrete(I)
+ union_find_dispatch(trait::image::kind::any,
+ const Image<I>& f, const Image<J>& g,
+ const Neighborhood<N>& nbh)
+ {
+ return impl::generic::union_find(f, g, nbh);
+ }
+
+ template <typename I, typename J, typename N>
+ inline
+ mln_concrete(I)
+ union_find_dispatch(const Image<I>& f, const Image<J>& g,
+ const Neighborhood<N>& nbh)
+ {
+ return union_find_dispatch(mln_trait_image_kind(I)(),
+ f, g, nbh);
+ }
+
+ } // end of namespace mln::morpho::reconstruction::by_erosion::internal
+
+
+ // Facade.
+
+ template <typename I, typename J, typename N>
+ inline
+ mln_concrete(I)
+ union_find(const Image<I>& f, const Image<J>& g,
+ const Neighborhood<N>& nbh)
+ {
+ trace::entering("morpho::reconstruction::by_erosion::union_find");
+
+ internal::union_find_tests(f, g, nbh);
+
+ mln_concrete(I) output;
+ output = internal::union_find_dispatch(f, g, nbh);
+
+ trace::exiting("morpho::reconstruction::by_erosion::union_find");
+ return output;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::morpho::reconstruction::by_erosion
+
+ } // end of namespace mln::morpho::reconstruction
+
+ } // end of namespace mln::morpho
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MORPHO_RECONSTRUCTION_BY_EROSION_UNION_FIND_HH
Property changes on: trunk/milena/mln/morpho/reconstruction/by_erosion/union_find.hh
___________________________________________________________________
Added: svn:mergeinfo
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2009-05-25 Edwin Carlinet <carlinet(a)lrde.epita.fr>
Improve tests about tree interface.
* tests/morpho/tree/data.cc: Add tests about tree traversal.
---
data.cc | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
Index: trunk/milena/tests/morpho/tree/data.cc
===================================================================
--- trunk/milena/tests/morpho/tree/data.cc (revision 3867)
+++ trunk/milena/tests/morpho/tree/data.cc (revision 3868)
@@ -45,21 +45,27 @@
using namespace mln;
typedef image2d<unsigned char> I;
- unsigned char vals[] = { 3, 2, 1,
- 3, 2, 3,
- 3, 4, 1 };
+// unsigned char vals[] = { 3, 2, 1,
+// 3, 2, 3,
+// 3, 4, 1 };
+
+ unsigned char vals[] = { 3, 3, 3,
+ 3, 4, 4,
+ 3, 4, 4 };
+
I ima = make::image2d(vals);
debug::println("ima = ", ima);
typedef p_array<point2d> S;
- S s = level::sort_psites_increasing(ima);
+ S s = level::sort_psites_decreasing(ima);
typedef morpho::tree::data<I,S> tree_t;
tree_t t(ima, s, c4());
debug::println( "parent = ", t.parent_image() | t.domain() );
debug::println( "on node = ", t.parent_image() | t.nodes() );
+ debug::println( "on leaves = ", t.parent_image() | t.leaves() );
{
/* Check site and node up order */
@@ -79,7 +85,7 @@
}
n.next();
}
- mln_assertion(!n.is_valid());
+ mln_assertion(!n.is_valid() && !s.is_valid() && !l.is_valid());
}
{
@@ -100,7 +106,7 @@
}
n.next();
}
- mln_assertion(!n.is_valid());
+ mln_assertion(!n.is_valid() && !s.is_valid() && !l.is_valid());
}
1
0
* Makefile.am,
* src/Makefile.am,
* src/binarization/Makefile.am,
* tests/Makefile.am,
* tests/preprocessing/Makefile.am,
* tests/unit_test/Makefile.am: new.
---
scribo/ChangeLog | 11 ++++++++++
scribo/Makefile.am | 2 +-
scribo/src/Makefile.am | 35 +++++++++++++++++++------------
scribo/src/binarization/Makefile.am | 2 +-
scribo/tests/Makefile.am | 4 ++-
scribo/tests/preprocessing/Makefile.am | 10 +++++++++
scribo/tests/unit_test/Makefile.am | 22 ++++++++++++++++++++
7 files changed, 69 insertions(+), 17 deletions(-)
create mode 100644 scribo/tests/preprocessing/Makefile.am
create mode 100644 scribo/tests/unit_test/Makefile.am
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index a6a798b..82c4648 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,16 @@
2009-05-25 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+ Add missing Makefile.am in Scribo.
+
+ * Makefile.am,
+ * src/Makefile.am,
+ * src/binarization/Makefile.am,
+ * tests/Makefile.am,
+ * tests/preprocessing/Makefile.am,
+ * tests/unit_test/Makefile.am: new.
+
+2009-05-25 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
Add a script to generate unit tests for scribo.
* tests/unit_test/build_unit_test.sh: new.
diff --git a/scribo/Makefile.am b/scribo/Makefile.am
index bf33f79..98a71f3 100644
--- a/scribo/Makefile.am
+++ b/scribo/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = tests
+SUBDIRS = tests src
.PHONY: bin
diff --git a/scribo/src/Makefile.am b/scribo/src/Makefile.am
index 8511787..72b202d 100644
--- a/scribo/src/Makefile.am
+++ b/scribo/src/Makefile.am
@@ -1,36 +1,43 @@
## Process this file through Automake to create Makefile.in.
-include $(top_srcdir)/milena/sandbox/scribo/scribo.mk
+include $(top_srcdir)/scribo/scribo.mk
+
+recognition_CXXFLAGS = -I$(HOME)/local/include $(HOME)/local/lib/libtesseract_full.a
+recognition_LDFLAGS = -lpthread
SUBDIRS = \
binarization
bin_PROGRAMS = \
dmap \
- extract_text_single_link \
- table_erase \
extract_text_double_link \
- table_extract \
extract_text_double_several_links \
- morpho \
extract_text_graph \
- table_rebuild_opening \
extract_text_several_graph \
- table_rebuild_rank \
extract_text_several_left_links \
- thin_bboxes
+ extract_text_single_link \
+ morpho \
+ recognition \
+ table_erase \
+ table_extract \
+ table_rebuild_opening \
+ table_rebuild_rank \
+ thin_bboxes \
+ unskew
dmap_SOURCES = dmap.cc
-extract_text_single_link_SOURCES = extract_text_single_link.cc
-table_erase_SOURCES = table_erase.cc
extract_text_double_link_SOURCES = extract_text_double_link.cc
-table_extract_SOURCES = table_extract.cc
extract_text_double_several_links_SOURCES = extract_text_double_several_links.cc
-morpho_SOURCES = morpho.cc
extract_text_graph_SOURCES = extract_text_graph.cc
-table_rebuild_opening_SOURCES = table_rebuild_opening.cc
extract_text_several_graph_SOURCES = extract_text_several_graph.cc
-table_rebuild_rank_SOURCES = table_rebuild_rank.cc
extract_text_several_left_links_SOURCES = extract_text_several_left_links.cc
+extract_text_single_link_SOURCES = extract_text_single_link.cc
+morpho_SOURCES = morpho.cc
+recognition_SOURCES = recognition.cc
+table_erase_SOURCES = table_erase.cc
+table_extract_SOURCES = table_extract.cc
+table_rebuild_opening_SOURCES = table_rebuild_opening.cc
+table_rebuild_rank_SOURCES = table_rebuild_rank.cc
thin_bboxes_SOURCES = thin_bboxes.cc
+unskew_SOURCES = unskew.cc
diff --git a/scribo/src/binarization/Makefile.am b/scribo/src/binarization/Makefile.am
index 9f149c7..63eeee7 100644
--- a/scribo/src/binarization/Makefile.am
+++ b/scribo/src/binarization/Makefile.am
@@ -1,6 +1,6 @@
## Process this file through Automake to create Makefile.in.
-include $(top_srcdir)/milena/sandbox/scribo/scribo.mk
+include $(top_srcdir)/scribo/scribo.mk
bin_PROGRAMS = \
simple
diff --git a/scribo/tests/Makefile.am b/scribo/tests/Makefile.am
index 4f6e663..8646e68 100644
--- a/scribo/tests/Makefile.am
+++ b/scribo/tests/Makefile.am
@@ -2,6 +2,8 @@
SUBDIRS = \
filter \
+ preprocessing \
table \
- text
+ text \
+ unit_test
diff --git a/scribo/tests/preprocessing/Makefile.am b/scribo/tests/preprocessing/Makefile.am
new file mode 100644
index 0000000..eea4429
--- /dev/null
+++ b/scribo/tests/preprocessing/Makefile.am
@@ -0,0 +1,10 @@
+## Process this file through Automake to create Makefile.in.
+
+include $(top_srcdir)/scribo/scribo.mk
+
+check_PROGRAMS = \
+ unskew
+
+unskew_SOURCES = unskew.cc
+
+TESTS = $(check_PROGRAMS)
diff --git a/scribo/tests/unit_test/Makefile.am b/scribo/tests/unit_test/Makefile.am
new file mode 100644
index 0000000..c0be7d6
--- /dev/null
+++ b/scribo/tests/unit_test/Makefile.am
@@ -0,0 +1,22 @@
+## Process this file through Automake to create Makefile.in.
+
+include $(top_srcdir)/scribo/scribo.mk
+
+.PHONY: regen-tests
+regen-tests: $(srcdir)/unit-tests.mk
+# FIXME: Change build_unit_test.sh so that the action looks like this:
+#
+# $< $@.tmp && mv -f $@.tmp $@ && chmod -w $@
+#
+# `$(abs_top_srcdir)' is required because of the change of directory
+# at the beginning og the action.
+$(srcdir)/unit-tests.mk: $(srcdir)/build_unit_test.sh
+ cd $(srcdir) \
+ && ./build_unit_test.sh $(abs_top_srcdir)/scribo \
+ && chmod a-w unit-tests.mk
+
+include $(srcdir)/unit-tests.mk
+
+MAINTAINERCLEANFILES = $(srcdir)/scribo_*.cc
+
+TESTS = $(check_PROGRAMS)
--
1.5.6.5
1
0
* tests/unit_test/build_unit_test.sh: new.
---
scribo/ChangeLog | 15 +++++++
scribo/tests/unit_test/build_unit_test.sh | 59 +++++++++++++++++++++++++++++
2 files changed, 74 insertions(+), 0 deletions(-)
create mode 100644 scribo/ChangeLog
create mode 100755 scribo/tests/unit_test/build_unit_test.sh
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
new file mode 100644
index 0000000..a6a798b
--- /dev/null
+++ b/scribo/ChangeLog
@@ -0,0 +1,15 @@
+2009-05-25 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
+ Add a script to generate unit tests for scribo.
+
+ * tests/unit_test/build_unit_test.sh: new.
+
+
+$Rev$
+$Id$
+$Date$
+
+Local Variables:
+ispell-local-dictionary: "american"
+coding: iso-latin-1
+End:
diff --git a/scribo/tests/unit_test/build_unit_test.sh b/scribo/tests/unit_test/build_unit_test.sh
new file mode 100755
index 0000000..7c80671
--- /dev/null
+++ b/scribo/tests/unit_test/build_unit_test.sh
@@ -0,0 +1,59 @@
+#! /bin/sh
+
+## FIXME: Don't use `echo -n', as echo's options are not portable.
+##
+## http://www.gnu.org/software/autoconf/manual/html_node/Limitations-of-Builti…
+##
+## As an ugly workaround, use `printf' instead. The right approach
+## would be to only emit lines ended with newlines.
+ECHO_N=printf
+
+
+test $# -eq 1 || { echo "Usage: $0 <scribo path>" && exit 1; }
+
+## FIXME: Ouch! Using `find' properly can probably save us some pipes,
+## forks and characters here.
+HEADERS=`find $1 -name "*.hh" | grep -vE "*.spe.hh" | sort | sed -e 's/.*\/scribo\/\(.*\)/scribo\/\1/g' | sed 's/\.\.\/\.\.\///g'`
+
+output=unit-tests.mk
+
+rm -f "$output"
+rm -f scribo_*.cc
+
+# Build unit-tests.mk.
+echo "## Generated by $0, do not modify." >"$output"
+echo >>"$output"
+$ECHO_N "check_PROGRAMS = " >>"$output"
+
+for i in $HEADERS; do
+ FILE_CC=`echo $i | sed 's/[/.]/_/g' | sed 's/_hh/\.cc/g'`
+
+ # Build .cc.
+ cat > $FILE_CC << EOF
+// Unit test for $i.
+// Generated by $0, do not modify.
+
+// Include the file twice, so we detect missing inclusion guards.
+#include <$i>
+#include <$i>
+
+int main()
+{
+ // Nothing.
+}
+EOF
+
+ # Build unit-tests.mk.
+ TARGET=`echo "${FILE_CC}" | sed 's/\.cc//'`
+ echo " \\" >>"$output"
+ $ECHO_N "${TARGET}" >>"$output"
+done
+
+# Build "$output".
+echo "" >>"$output"
+echo "" >>"$output"
+for i in $HEADERS; do
+ FILE_CC=`echo $i | sed 's/[/.]/_/g' | sed 's/_hh/\.cc/g'`
+ NAME=`echo $FILE_CC | sed 's/\.cc//g'`
+ echo "${NAME}_SOURCES = $FILE_CC" >>"$output"
+done
--
1.5.6.5
1
0
22 May '09
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2009-05-22 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Implement load() for filling an array from a plot.
* mln/io/plot/load.hh: Load a plot into an float array.
* tests/io/plot/load.cc: New test file for plot loading.
---
mln/io/plot/load.hh | 33 +++++++++++++++++++++++++--------
tests/io/plot/load.cc | 17 +++++++++++++++++
2 files changed, 42 insertions(+), 8 deletions(-)
Index: trunk/milena/tests/io/plot/load.cc
===================================================================
--- trunk/milena/tests/io/plot/load.cc (revision 0)
+++ trunk/milena/tests/io/plot/load.cc (revision 3865)
@@ -0,0 +1,17 @@
+#include <mln/io/plot/load.hh>
+#include <mln/util/array.hh>
+
+
+using namespace mln;
+
+int main(int argc, char* argv[])
+{
+ util::array<float> arr;
+
+ io::plot::load(arr, argv[1]);
+
+ for (unsigned i = 0; i < arr.nelements(); ++i)
+ std::cout << arr[i] << std::endl;
+
+ return 0;
+}
Index: trunk/milena/mln/io/plot/load.hh
===================================================================
--- trunk/milena/mln/io/plot/load.hh (revision 3864)
+++ trunk/milena/mln/io/plot/load.hh (revision 3865)
@@ -35,6 +35,7 @@
# include <iostream>
# include <fstream>
+# include <cstring>
# include <mln/core/image/image1d.hh>
# include <mln/metal/equal.hh>
# include <mln/util/array.hh>
@@ -58,9 +59,9 @@
* \param[in] start_value The start index value of the plot
* (optional).
*/
- template <typename I>
+ /*template <typename I>
void load(image1d<I>& ima,
- const std::string& filename);
+ const std::string& filename);*/
/*! Load a Milena array from a plot file.
*
@@ -77,7 +78,7 @@
# ifndef MLN_INCLUDE_ONLY
- template <typename I>
+ /*template <typename I>
inline
void load(image1d<I>& ima, const std::string& filename)
{
@@ -88,7 +89,7 @@
file_out << start_value + i << ", " << ima.at_(i) << std::endl;
trace::exiting("mln::io::plot::load");
- }
+ }*/
template <typename I>
inline
@@ -96,11 +97,27 @@
{
trace::entering("mln::io::plot::load");
- std::ifstream file_out(filename.c_str());
- while (!oef)
+ arr.clear();
+ std::ifstream file_in(filename.c_str());
+
+ int MAX_LENGTH = 100;
+ char line[MAX_LENGTH];
+ char delims[] = " ";
+ char *result = NULL;
+ char *tmp_str = NULL;
+
+ while (file_in.getline(line, MAX_LENGTH))
+ {
+ if (strlen(line) > 0 && line[0] != '#')
+ {
+ tmp_str = strtok(line, delims);
+ while (tmp_str != NULL)
{
- if (line is comment)
- continue;
+ result = tmp_str;
+ tmp_str = strtok(NULL, delims);
+ }
+ arr.append(atof(result)); // FIXME: type
+ }
}
trace::exiting("mln::io::plot::load");
1
0