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
- 9625 discussions
11 Feb '09
From: Maxime van Noppen <yabo(a)lrde.epita.fr>
To: transformers-patches(a)lrde.epita.fr, olena-patches(a)lrde.epita.fr
Subject: scool r131: Update tests and add those used in van-noppen.09.dslwc
URL: https://svn.lrde.epita.fr/svn/scool/branches/scool-ng
ChangeLog:
2009-02-11 Maxime van Noppen <yabo(a)lrde.epita.fr>
Update tests and add those used in van-noppen.09.dslwc.
* concept/scool_src/concept_1.scl,
* concept/scool_src/concept_2.scl,
* concept/scool_src/concept_3.scl,
* concept/scool_src/concept_4.scl,
* concept/scool_src/concept_use_1.scl,
* concept/scool_src/concept_use_2.scl: Here.
* concept/scool_src/concept_use_3.scl: New.
* examples/c++_ast/animal_hierarchy.aterm: New.
* examples/c++_ast/point1d_simple.aterm: Remove.
* examples/c++_build/point1d_simple.g++: Remove.
* examples/c++_src/animal_hierarchy.cc: New.
* examples/c++_src/point1d_simple.cc: Remove.
* examples/scool_ast/animal_hierarchy.aterm: New.
* examples/scool_ast/point1d_simple.aterm: Remove.
* examples/scool_ast/sample_animal_hierarchy.aterm: Remove.
* examples/scool_src/animal_hierarchy.scl: New.
* examples/scool_src/container_1.scl: New.
* examples/scool_src/container_2.scl: New.
* examples/scool_src/embeded_c++.scl: New.
* examples/scool_src/fact.scl: New.
* examples/scool_src/meta_identity.scl: New.
* examples/scool_src/meta_type_equality.scl: New.
* examples/scool_src/point1d.scl: New.
* examples/scool_src/point1d_simple.scl: Remove.
* examples/scool_src/sample_animal_hierarchy.scl: Remove.
* examples/scool_src/sample_container.scl: Remove.
---
branches/scool-ng/tests/concept/scool_src/concept_1.scl | 2
branches/scool-ng/tests/concept/scool_src/concept_2.scl | 2
branches/scool-ng/tests/concept/scool_src/concept_3.scl | 4
branches/scool-ng/tests/concept/scool_src/concept_4.scl | 6 -
branches/scool-ng/tests/concept/scool_src/concept_use_1.scl | 2
branches/scool-ng/tests/concept/scool_src/concept_use_2.scl | 2
branches/scool-ng/tests/concept/scool_src/concept_use_3.scl | 30 +++++++
branches/scool-ng/tests/examples/c++_ast/animal_hierarchy.aterm | 1
branches/scool-ng/tests/examples/c++_src/animal_hierarchy.cc | 28 ++++++
branches/scool-ng/tests/examples/scool_ast/animal_hierarchy.aterm | 1
branches/scool-ng/tests/examples/scool_src/animal_hierarchy.scl | 41 ++++++++++
branches/scool-ng/tests/examples/scool_src/container_1.scl | 16 +++
branches/scool-ng/tests/examples/scool_src/container_2.scl | 28 ++++++
branches/scool-ng/tests/examples/scool_src/embeded_c++.scl | 8 +
branches/scool-ng/tests/examples/scool_src/fact.scl | 7 +
branches/scool-ng/tests/examples/scool_src/meta_identity.scl | 4
branches/scool-ng/tests/examples/scool_src/meta_type_equality.scl | 17 ++++
branches/scool-ng/tests/examples/scool_src/point1d.scl | 18 ++++
18 files changed, 208 insertions(+), 9 deletions(-)
Index: branches/scool-ng/tests/concept/scool_src/concept_use_1.scl
===================================================================
--- branches/scool-ng/tests/concept/scool_src/concept_use_1.scl (revision 130)
+++ branches/scool-ng/tests/concept/scool_src/concept_use_1.scl (revision 131)
@@ -2,7 +2,7 @@
{
value : type;
- decl get_value : () -> value;
+ get_value : () -> value;
}
foo : [ T : type where (T models box) ] (pbox : T) -> void =
Index: branches/scool-ng/tests/concept/scool_src/concept_use_2.scl
===================================================================
--- branches/scool-ng/tests/concept/scool_src/concept_use_2.scl (revision 130)
+++ branches/scool-ng/tests/concept/scool_src/concept_use_2.scl (revision 131)
@@ -2,7 +2,7 @@
{
value : type;
- decl get_value : () -> value;
+ get_value : () -> value;
}
foo : [ T : type where T models box ] (pbox : T) -> void =
Index: branches/scool-ng/tests/concept/scool_src/concept_use_3.scl
===================================================================
--- branches/scool-ng/tests/concept/scool_src/concept_use_3.scl (revision 0)
+++ branches/scool-ng/tests/concept/scool_src/concept_use_3.scl (revision 131)
@@ -0,0 +1,30 @@
+// Example found in van-noppen.09.dslwc
+
+// Concept declaration
+Box : concept =
+{
+ value_type : type;
+ get_value : () -> value_type;
+ mutable set_value : (value : value_type) -> void;
+}
+
+// Declaration of a class modeling this concept
+Element : class models Box =
+{
+ public
+ {
+ value_type : type = int;
+ get_value : () -> value_type = { -> value_; }
+ mutable set_value : (value : value_type) -> void = { value_ = value; }
+ }
+ private
+ {
+ value_ : value_type;
+ }
+}
+
+// Usage of the concept to restrain a static parameter
+f : [ T : type where T models Box] (val : T) -> void =
+{
+ point : T::value_type = val.get_value();
+}
Index: branches/scool-ng/tests/concept/scool_src/concept_1.scl
===================================================================
--- branches/scool-ng/tests/concept/scool_src/concept_1.scl (revision 130)
+++ branches/scool-ng/tests/concept/scool_src/concept_1.scl (revision 131)
@@ -2,5 +2,5 @@
{
value : type;
- decl get_value : () -> value;
+ get_value : () -> value;
}
Index: branches/scool-ng/tests/concept/scool_src/concept_2.scl
===================================================================
--- branches/scool-ng/tests/concept/scool_src/concept_2.scl (revision 130)
+++ branches/scool-ng/tests/concept/scool_src/concept_2.scl (revision 131)
@@ -2,5 +2,5 @@
{
value : type;
- decl set_value : (val : value) -> value;
+ mutable set_value : (val : value) -> value;
}
Index: branches/scool-ng/tests/concept/scool_src/concept_3.scl
===================================================================
--- branches/scool-ng/tests/concept/scool_src/concept_3.scl (revision 130)
+++ branches/scool-ng/tests/concept/scool_src/concept_3.scl (revision 131)
@@ -2,6 +2,6 @@
{
value : type;
- decl set_value : (val : value) -> value;
- decl get_value : () -> value;
+ mutable set_value : (val : value) -> value;
+ get_value : () -> value;
}
Index: branches/scool-ng/tests/concept/scool_src/concept_4.scl
===================================================================
--- branches/scool-ng/tests/concept/scool_src/concept_4.scl (revision 130)
+++ branches/scool-ng/tests/concept/scool_src/concept_4.scl (revision 131)
@@ -2,7 +2,7 @@
{
value : type;
- decl set_value : (val : value) -> value;
- decl get_value : () -> value;
- decl print_value : () -> void;
+ mutable set_value : (val : value) -> value;
+ get_value : () -> value;
+ print_value : () -> void;
}
Index: branches/scool-ng/tests/examples/c++_ast/point1d_simple.aterm (deleted)
===================================================================
Index: branches/scool-ng/tests/examples/c++_ast/animal_hierarchy.aterm
===================================================================
--- branches/scool-ng/tests/examples/c++_ast/animal_hierarchy.aterm (revision 0)
+++ branches/scool-ng/tests/examples/c++_ast/animal_hierarchy.aterm (revision 131)
@@ -0,0 +1 @@
+CxxProgram([CxxProgram("#include <iostream>"),CxxClassDecl([(CxxType("typename"),"Exact")],CxxId("Animal"),[],[CxxPublic([CxxFun([],CxxType("void"),CxxId("scream"),Const,[])])]),CxxClassDecl([(CxxType("typename"),"Exact")],CxxId("Cat"),[("public",CxxType(CxxId("Animal"),[CxxId("Exact")]))],[CxxPublic([CxxFun([],CxxType("void"),CxxId("scream"),[],Const,[CxxProgram("std::cout << \"Meow!\" << std::endl; ")])])]),CxxClassDecl([],CxxId("Dog"),[("public",CxxType(CxxId("Animal"),[CxxId("Dog")]))],[CxxPublic([CxxFun([],CxxType("void"),CxxId("scream"),[],Const,[CxxProgram("std::cout << \"Woof!\" << std::endl; ")])])]),CxxFun([],CxxType("void"),CxxId("scream"),[(CxxConstType(CxxRefType(CxxType("Animal"))),CxxId("animal"))],None,[CxxProgram("std::cout << animal.scream(); << std::endl; ")])])
Index: branches/scool-ng/tests/examples/c++_src/point1d_simple.cc (deleted)
===================================================================
Index: branches/scool-ng/tests/examples/c++_src/animal_hierarchy.cc
===================================================================
--- branches/scool-ng/tests/examples/c++_src/animal_hierarchy.cc (revision 0)
+++ branches/scool-ng/tests/examples/c++_src/animal_hierarchy.cc (revision 131)
@@ -0,0 +1,28 @@
+#include <iostream>
+template < typename Exact >
+class Animal
+{
+ public:
+ void scream() const;
+};
+template < typename Exact >
+class Cat : public Animal< Exact >
+{
+ public:
+ void scream() const
+ {
+ std::cout << "Meow!" << std::endl;
+ }
+};
+class Dog : public Animal< Dog >
+{
+ public:
+ void scream() const
+ {
+ std::cout << "Woof!" << std::endl;
+ }
+};
+void scream(const Animal& animal)
+{
+ std::cout << animal.scream(); << std::endl;
+}
Index: branches/scool-ng/tests/examples/scool_ast/sample_animal_hierarchy.aterm (deleted)
===================================================================
Index: branches/scool-ng/tests/examples/scool_ast/point1d_simple.aterm (deleted)
===================================================================
Index: branches/scool-ng/tests/examples/scool_ast/animal_hierarchy.aterm
===================================================================
--- branches/scool-ng/tests/examples/scool_ast/animal_hierarchy.aterm (revision 0)
+++ branches/scool-ng/tests/examples/scool_ast/animal_hierarchy.aterm (revision 131)
@@ -0,0 +1 @@
+Program([CxxStatement(Cxx("#include <iostream>")),ClassDefinition(Identifier("Animal"),None,None,ClassBlock([AccessBlock(Public,[FunctionDeclaration(None,Identifier("scream"),FunctionType(None,ArgumentsDeclaration([]),SimpleType("void")))])])),ClassDefinition(Identifier("Cat"),None,Some(ClassWhereClause([Inherits("Cat",SimpleType("Animal"))])),ClassBlock([AccessBlock(Public,[FunctionDefinition(None,Identifier("scream"),FunctionType(None,ArgumentsDeclaration([]),SimpleType("void")),FunctionBlock([CxxStatement(Cxx("std::cout << \"Meow!\" << std::endl; "))]))])])),ClassDefinition(Identifier("Dog"),Some("final"),Some(ClassWhereClause([Inherits("Dog",SimpleType("Animal"))])),ClassBlock([AccessBlock(Public,[FunctionDefinition(None,Identifier("scream"),FunctionType(None,ArgumentsDeclaration([]),SimpleType("void")),FunctionBlock([CxxStatement(Cxx("std::cout << \"Woof!\" << std::endl; "))]))])])),FunctionDefinition(None,Identifier("scream"),FunctionType(None,ArgumentsDeclaration([TypedId(Identifier("animal"),SimpleType("Animal"))]),SimpleType("void")),FunctionBlock([CxxStatement(Cxx("std::cout << animal.scream(); << std::endl; "))]))])
Index: branches/scool-ng/tests/examples/scool_src/sample_animal_hierarchy.scl (deleted)
===================================================================
Index: branches/scool-ng/tests/examples/scool_src/sample_container.scl (deleted)
===================================================================
Index: branches/scool-ng/tests/examples/scool_src/point1d_simple.scl (deleted)
===================================================================
Index: branches/scool-ng/tests/examples/scool_src/animal_hierarchy.scl
===================================================================
--- branches/scool-ng/tests/examples/scool_src/animal_hierarchy.scl (revision 0)
+++ branches/scool-ng/tests/examples/scool_src/animal_hierarchy.scl (revision 131)
@@ -0,0 +1,41 @@
+|[#include <iostream>]|;
+
+Animal : class =
+{
+ public
+ {
+ scream : () -> void;
+ }
+}
+Cat : class where Cat -> Animal =
+{
+ public
+ {
+ scream : () -> void = { |[ std::cout << "Meow!" << std::endl; ]|; }
+ }
+}
+
+Dog : final class where Dog -> Animal =
+{
+ public
+ {
+ scream : () -> void = { |[ std::cout << "Woof!" << std::endl; ]|; }
+ }
+}
+
+scream : (animal : Animal) -> void =
+{
+ |[ std::cout << animal.scream(); << std::endl; ]|;
+}
+
+/*
+main : () -> int =
+{
+ var cat : Cat;
+ var dog : Dog;
+
+ scream(cat);
+ scream(dog);
+ -> 0;
+}
+*/
Property changes on: branches/scool-ng/tests/examples/scool_src/animal_hierarchy.scl
___________________________________________________________________
Added: svn:mergeinfo
Index: branches/scool-ng/tests/examples/scool_src/meta_identity.scl
===================================================================
--- branches/scool-ng/tests/examples/scool_src/meta_identity.scl (revision 0)
+++ branches/scool-ng/tests/examples/scool_src/meta_identity.scl (revision 131)
@@ -0,0 +1,4 @@
+identity : [T : type] -> type =
+{
+ -> T;
+}
Index: branches/scool-ng/tests/examples/scool_src/container_1.scl
===================================================================
--- branches/scool-ng/tests/examples/scool_src/container_1.scl (revision 0)
+++ branches/scool-ng/tests/examples/scool_src/container_1.scl (revision 131)
@@ -0,0 +1,16 @@
+Container : [T : type] -> class =
+{
+ public
+ {
+ value_type : type = T;
+
+ get : () -> value_type = { -> value; }
+ mutable set : (value : value_type) = { value_ = value; }
+ }
+
+ private
+ {
+ var value_ : value_type;
+ }
+}
+
Property changes on: branches/scool-ng/tests/examples/scool_src/container_1.scl
___________________________________________________________________
Added: svn:mergeinfo
Index: branches/scool-ng/tests/examples/scool_src/container_2.scl
===================================================================
--- branches/scool-ng/tests/examples/scool_src/container_2.scl (revision 0)
+++ branches/scool-ng/tests/examples/scool_src/container_2.scl (revision 131)
@@ -0,0 +1,28 @@
+container : [T : type] -> class =
+{
+ public
+ {
+ value type : type = T;
+ }
+
+ if [ T == int ]
+ {
+ public
+ {
+ var value : value_type;
+ }
+ }
+ else
+ {
+ public
+ {
+ get : () -> value_type = { -> value_ ; }
+ mutable set : (value : value_type) = { value_ = value; }
+ }
+ private
+ {
+ var value_ : value_type;
+ }
+ }
+}
+
Index: branches/scool-ng/tests/examples/scool_src/meta_type_equality.scl
===================================================================
--- branches/scool-ng/tests/examples/scool_src/meta_type_equality.scl (revision 0)
+++ branches/scool-ng/tests/examples/scool_src/meta_type_equality.scl (revision 131)
@@ -0,0 +1,17 @@
+equal : [T : type] -> class =
+{
+ public
+ {
+ res : type = T;
+ }
+}
+
+not_equal : class = { }
+
+are_equal : [T : type, U : type] -> type =
+{
+ if [ T = U ]
+ -> equal[T];
+ else
+ -> not_equal;
+}
Index: branches/scool-ng/tests/examples/scool_src/embeded_c++.scl
===================================================================
--- branches/scool-ng/tests/examples/scool_src/embeded_c++.scl (revision 0)
+++ branches/scool-ng/tests/examples/scool_src/embeded_c++.scl (revision 131)
@@ -0,0 +1,8 @@
+// Example found in van-noppen.09.dslwc
+|[ #include <iostream> ]|
+f : (arg: int) -> int =
+{
+ |[ std::cout << arg << std::endl; ]|;
+
+ -> |[ arg + 42 ]|;
+}
Index: branches/scool-ng/tests/examples/scool_src/fact.scl
===================================================================
--- branches/scool-ng/tests/examples/scool_src/fact.scl (revision 0)
+++ branches/scool-ng/tests/examples/scool_src/fact.scl (revision 131)
@@ -0,0 +1,7 @@
+// Example found in van-noppen.09.dslwc
+fact : [N : unsigned] -> unsigned =
+{
+ if [ N == 0 ]
+ -> 1;
+ -> N + fact[N - 1];
+}
Index: branches/scool-ng/tests/examples/scool_src/point1d.scl
===================================================================
--- branches/scool-ng/tests/examples/scool_src/point1d.scl (revision 0)
+++ branches/scool-ng/tests/examples/scool_src/point1d.scl (revision 131)
@@ -0,0 +1,18 @@
+// Example found in van-noppen.09.dslwc
+point1d : class =
+{
+ public
+ {
+ point_type: type = int;
+
+ make : () = { x_ = 0; }
+ make(x : point_type) = { x_ = x; }
+
+ get_x : () -> point_type = { -> x; }
+ mutable set_x : (x : point_type) -> point_type = { x_ = x; }
+ }
+ private
+ {
+ var x_ : point_type;
+ }
+}
Index: branches/scool-ng/tests/examples/c++_build/point1d_simple.g++ (deleted)
===================================================================
1
0
* mln/debug/histo.hh: add missing includes and a wrong precondition.
---
milena/ChangeLog | 6 ++++++
milena/mln/debug/histo.hh | 15 +++++++++------
2 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 011ba13..36b3251 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,9 @@
+2009-02-11 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Fix debug::histo.
+
+ * mln/debug/histo.hh: add missing includes and a wrong precondition.
+
2009-02-10 Roland Levillain <roland(a)lrde.epita.fr>
s/alignement/alignment/g.
diff --git a/milena/mln/debug/histo.hh b/milena/mln/debug/histo.hh
index 1b0bbeb..e16d0b7 100644
--- a/milena/mln/debug/histo.hh
+++ b/milena/mln/debug/histo.hh
@@ -33,7 +33,11 @@
///
/// save a histogram to a plot data file.
+# include <iostream>
+# include <fstream>
# include <vector>
+# include <string>
+# include <mln/histo/array.hh>
# include <mln/core/image/image2d.hh>
# include <mln/draw/line.hh>
@@ -45,22 +49,21 @@ namespace mln
void
- histo_plot(const histo::array<unsigned>& h, const std::string& filename);
+ histo(const histo::array<unsigned>& h, const std::string& filename);
void
- histo_plot(const std::vector<unsigned>& h, const std::string& filename);
+ histo(const std::vector<unsigned>& h, const std::string& filename);
# ifndef MLN_INCLUDE_ONLY
void
- histo_plot(const histo::array<unsigned>& h, const std::string& filename)
+ histo(const histo::array<unsigned>& h, const std::string& filename)
{
- mln_precondition(h.is_valid());
- histo_plot(h.vect(), filename);
+ histo(h.vect(), filename);
}
void
- histo_plot(const std::vector<unsigned>& h, const std::string& filename)
+ histo(const std::vector<unsigned>& h, const std::string& filename)
{
std::ofstream file(filename.c_str());
if (! file)
--
1.5.6.5
1
0
10 Feb '09
---
milena/sandbox/ChangeLog | 4 ++++
milena/sandbox/abraham/mln/trait/images.hh | 6 +++---
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog
index 84842e9..a223445 100644
--- a/milena/sandbox/ChangeLog
+++ b/milena/sandbox/ChangeLog
@@ -15,6 +15,10 @@
2009-02-10 Roland Levillain <roland(a)lrde.epita.fr>
+ * abraham/mln/trait/images.hh: s/alignement/alignment/g.
+
+2009-02-10 Roland Levillain <roland(a)lrde.epita.fr>
+
Add programs for Camille Couprie.
* camille/: New directory.
diff --git a/milena/sandbox/abraham/mln/trait/images.hh b/milena/sandbox/abraham/mln/trait/images.hh
index 104a717..3d2c6f5 100644
--- a/milena/sandbox/abraham/mln/trait/images.hh
+++ b/milena/sandbox/abraham/mln/trait/images.hh
@@ -62,7 +62,7 @@
# define mln_trait_image_pw_io(I) typename mln::trait::image_< I >::pw_io
# define mln_trait_image_vw_io(I) typename mln::trait::image_< I >::vw_io
# define mln_trait_image_vw_set(I) typename mln::trait::image_< I >::vw_set
-# define mln_trait_image_value_alignement(I) typename mln::trait::image_< I>::value_alignement
+# define mln_trait_image_value_alignment(I) typename mln::trait::image_< I>::value_alignment
# define mln_trait_image_localization(I) typename mln::trait::image_< I >::localization
# define mln_trait_image_dimension(I) typename mln::trait::image_< I >::dimension
@@ -128,7 +128,7 @@ namespace mln
// value
typedef undef vw_io;
typedef undef vw_set;
- typedef undef value_alignement;
+ typedef undef value_alignment;
typedef undef value_access;
typedef undef value_storage;
typedef undef value_browsing;
@@ -192,7 +192,7 @@ namespace mln
// value => delegation
typedef typename image_<D>::vw_io vw_io;
typedef typename image_<D>::vw_set vw_set;
- typedef typename image_<D>::value_alignement value_alignement;
+ typedef typename image_<D>::value_alignment value_alignment;
typedef typename image_<D>::value_access value_access;
typedef typename image_<D>::value_storage value_storage;
typedef typename image_<D>::value_browsing value_browsing;
--
1.6.1.2
1
0
* mln/core/image/complex_image.hh,
* mln/core/image/flat_image.hh,
* mln/core/image/image1d.hh,
* mln/core/image/image2d.hh,
* mln/core/image/image3d.hh,
* mln/core/image/image_if.hh,
* mln/core/image/p2p_image.hh,
* mln/core/image/slice_image.hh,
* mln/core/image/sub_image.hh,
* mln/data/fill_with_image.spe.hh,
* mln/data/paste.spe.hh,
* mln/level/transform.spe.hh,
* mln/level/transform_inplace.hh,
* mln/pw/image.hh,
* mln/trait/image/props.hh,
* mln/trait/images.hh:
Here.
---
milena/ChangeLog | 22 ++++++++++++++++++++++
milena/mln/core/image/complex_image.hh | 2 +-
milena/mln/core/image/flat_image.hh | 2 +-
milena/mln/core/image/image1d.hh | 2 +-
milena/mln/core/image/image2d.hh | 2 +-
milena/mln/core/image/image3d.hh | 2 +-
milena/mln/core/image/image_if.hh | 2 +-
milena/mln/core/image/p2p_image.hh | 2 +-
milena/mln/core/image/slice_image.hh | 2 +-
milena/mln/core/image/sub_image.hh | 2 +-
milena/mln/data/fill_with_image.spe.hh | 8 ++++----
milena/mln/data/paste.spe.hh | 8 ++++----
milena/mln/level/transform.spe.hh | 18 +++++++++---------
milena/mln/level/transform_inplace.hh | 12 ++++++------
milena/mln/pw/image.hh | 2 +-
milena/mln/trait/image/props.hh | 12 ++++++------
milena/mln/trait/images.hh | 6 +++---
17 files changed, 64 insertions(+), 42 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index a010992..011ba13 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,25 @@
+2009-02-10 Roland Levillain <roland(a)lrde.epita.fr>
+
+ s/alignement/alignment/g.
+
+ * mln/core/image/complex_image.hh,
+ * mln/core/image/flat_image.hh,
+ * mln/core/image/image1d.hh,
+ * mln/core/image/image2d.hh,
+ * mln/core/image/image3d.hh,
+ * mln/core/image/image_if.hh,
+ * mln/core/image/p2p_image.hh,
+ * mln/core/image/slice_image.hh,
+ * mln/core/image/sub_image.hh,
+ * mln/data/fill_with_image.spe.hh,
+ * mln/data/paste.spe.hh,
+ * mln/level/transform.spe.hh,
+ * mln/level/transform_inplace.hh,
+ * mln/pw/image.hh,
+ * mln/trait/image/props.hh,
+ * mln/trait/images.hh:
+ Here.
+
2009-02-10 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Fix save function for cloud.
diff --git a/milena/mln/core/image/complex_image.hh b/milena/mln/core/image/complex_image.hh
index b5303a4..152c10e 100644
--- a/milena/mln/core/image/complex_image.hh
+++ b/milena/mln/core/image/complex_image.hh
@@ -93,7 +93,7 @@ namespace mln
typedef trait::image::vw_set::none vw_set;
typedef trait::image::value_storage::disrupted value_storage;
typedef trait::image::value_browsing::site_wise_only value_browsing;
- typedef trait::image::value_alignement::irrelevant value_alignement;
+ typedef trait::image::value_alignment::irrelevant value_alignment;
typedef trait::image::value_io::read_write value_io;
// Site / domain.
diff --git a/milena/mln/core/image/flat_image.hh b/milena/mln/core/image/flat_image.hh
index 39331b3..c5470fb 100644
--- a/milena/mln/core/image/flat_image.hh
+++ b/milena/mln/core/image/flat_image.hh
@@ -83,7 +83,7 @@ namespace mln
typedef trait::image::value_access::direct value_access;
typedef trait::image::value_storage::singleton value_storage;
typedef mln::trait::image::value_browsing::value_wise value_browsing;
- typedef trait::image::value_alignement::with_grid value_alignement;
+ typedef trait::image::value_alignment::with_grid value_alignment;
typedef trait::image::value_io::read_only value_io;
// site / domain
diff --git a/milena/mln/core/image/image1d.hh b/milena/mln/core/image/image1d.hh
index f6915be..6b0ac15 100644
--- a/milena/mln/core/image/image1d.hh
+++ b/milena/mln/core/image/image1d.hh
@@ -100,7 +100,7 @@ namespace mln
typedef trait::image::value_access::direct value_access;
typedef trait::image::value_storage::one_block value_storage;
typedef trait::image::value_browsing::site_wise_only value_browsing;
- typedef trait::image::value_alignement::with_grid value_alignement;
+ typedef trait::image::value_alignment::with_grid value_alignment;
typedef trait::image::value_io::read_write value_io;
// site / domain
diff --git a/milena/mln/core/image/image2d.hh b/milena/mln/core/image/image2d.hh
index 0c44ef3..937b451 100644
--- a/milena/mln/core/image/image2d.hh
+++ b/milena/mln/core/image/image2d.hh
@@ -108,7 +108,7 @@ namespace mln
typedef trait::image::value_access::direct value_access;
typedef trait::image::value_storage::one_block value_storage;
typedef trait::image::value_browsing::site_wise_only value_browsing;
- typedef trait::image::value_alignement::with_grid value_alignement;
+ typedef trait::image::value_alignment::with_grid value_alignment;
typedef trait::image::value_io::read_write value_io;
// site / domain
diff --git a/milena/mln/core/image/image3d.hh b/milena/mln/core/image/image3d.hh
index 856b859..dcf266f 100644
--- a/milena/mln/core/image/image3d.hh
+++ b/milena/mln/core/image/image3d.hh
@@ -102,7 +102,7 @@ namespace mln
typedef trait::image::value_access::direct value_access;
typedef trait::image::value_storage::one_block value_storage;
typedef trait::image::value_browsing::site_wise_only value_browsing;
- typedef trait::image::value_alignement::with_grid value_alignement;
+ typedef trait::image::value_alignment::with_grid value_alignment;
typedef trait::image::value_io::read_write value_io;
// site / domain
diff --git a/milena/mln/core/image/image_if.hh b/milena/mln/core/image/image_if.hh
index 377e426..0102e7c 100644
--- a/milena/mln/core/image/image_if.hh
+++ b/milena/mln/core/image/image_if.hh
@@ -81,7 +81,7 @@ namespace mln
typedef trait::image::vw_io::none vw_io;
typedef trait::image::vw_set::none vw_set;
- typedef trait::image::value_alignement::not_aligned value_alignement;
+ typedef trait::image::value_alignment::not_aligned value_alignment;
typedef trait::image::value_storage::disrupted value_storage;
};
diff --git a/milena/mln/core/image/p2p_image.hh b/milena/mln/core/image/p2p_image.hh
index 26e154a..f0b17ba 100644
--- a/milena/mln/core/image/p2p_image.hh
+++ b/milena/mln/core/image/p2p_image.hh
@@ -77,7 +77,7 @@ namespace mln
typedef trait::image::vw_io::none vw_io;
typedef trait::image::vw_set::none vw_set;
- typedef trait::image::value_alignement::not_aligned value_alignement;
+ typedef trait::image::value_alignment::not_aligned value_alignment;
typedef trait::image::value_storage::disrupted value_storage;
};
diff --git a/milena/mln/core/image/slice_image.hh b/milena/mln/core/image/slice_image.hh
index b96c34b..66e7b94 100644
--- a/milena/mln/core/image/slice_image.hh
+++ b/milena/mln/core/image/slice_image.hh
@@ -81,7 +81,7 @@ namespace mln
typedef trait::image::vw_io::none vw_io;
typedef trait::image::vw_set::none vw_set;
- typedef trait::image::value_alignement::not_aligned value_alignement;
+ typedef trait::image::value_alignment::not_aligned value_alignment;
typedef trait::image::value_storage::disrupted value_storage;
};
diff --git a/milena/mln/core/image/sub_image.hh b/milena/mln/core/image/sub_image.hh
index 025d9d9..d5f2bf5 100644
--- a/milena/mln/core/image/sub_image.hh
+++ b/milena/mln/core/image/sub_image.hh
@@ -88,7 +88,7 @@ namespace mln
typedef trait::image::vw_io::none vw_io;
typedef trait::image::vw_set::none vw_set;
- typedef trait::image::value_alignement::not_aligned value_alignement;
+ typedef trait::image::value_alignment::not_aligned value_alignment;
typedef trait::image::value_storage::disrupted value_storage;
// HOT FIXME: except if S is a Box
};
diff --git a/milena/mln/data/fill_with_image.spe.hh b/milena/mln/data/fill_with_image.spe.hh
index 8c31f75..27a888b 100644
--- a/milena/mln/data/fill_with_image.spe.hh
+++ b/milena/mln/data/fill_with_image.spe.hh
@@ -252,10 +252,10 @@ namespace mln
/// Check basic properties
- if (mlc_is(mln_trait_image_value_alignement(I),
- trait::image::value_alignement::with_grid)::value &&
- mlc_is(mln_trait_image_value_alignement(J),
- trait::image::value_alignement::with_grid)::value)
+ if (mlc_is(mln_trait_image_value_alignment(I),
+ trait::image::value_alignment::with_grid)::value &&
+ mlc_is(mln_trait_image_value_alignment(J),
+ trait::image::value_alignment::with_grid)::value)
{
fill_with_image_(mln_trait_image_value_access(I)(),
mln_trait_image_value_access(J)(),
diff --git a/milena/mln/data/paste.spe.hh b/milena/mln/data/paste.spe.hh
index 2036d2e..dc526b3 100644
--- a/milena/mln/data/paste.spe.hh
+++ b/milena/mln/data/paste.spe.hh
@@ -295,10 +295,10 @@ namespace mln
const Image<I>& input,
Image<J>& output)
{
- enum { alignments = mlc_is(mln_trait_image_value_alignement(I),
- trait::image::value_alignement::with_grid)::value
- && mlc_is(mln_trait_image_value_alignement(J),
- trait::image::value_alignement::with_grid)::value };
+ enum { alignments = mlc_is(mln_trait_image_value_alignment(I),
+ trait::image::value_alignment::with_grid)::value
+ && mlc_is(mln_trait_image_value_alignment(J),
+ trait::image::value_alignment::with_grid)::value };
paste_one_block_dispatch(metal::bool_<alignments>(), input, output);
}
diff --git a/milena/mln/level/transform.spe.hh b/milena/mln/level/transform.spe.hh
index 50abfeb..78b2e8d 100644
--- a/milena/mln/level/transform.spe.hh
+++ b/milena/mln/level/transform.spe.hh
@@ -443,9 +443,9 @@ namespace mln
{
const I& input = exact(input_);
- /// Check alignement property
- if (mlc_is(mln_trait_image_value_alignement(I),
- trait::image::value_alignement::with_grid)::value)
+ /// Check alignment property
+ if (mlc_is(mln_trait_image_value_alignment(I),
+ trait::image::value_alignment::with_grid)::value)
return transform_dispatch(mln_trait_image_quant(I)(),
mln_trait_image_value_access(I)(),
input, exact(f_));
@@ -461,8 +461,8 @@ namespace mln
template <typename I1, typename I2, typename F>
mln_ch_value(I1, mln_result(F))
- transform_dispatch_2(trait::image::value_alignement::any,
- trait::image::value_alignement::any,
+ transform_dispatch_2(trait::image::value_alignment::any,
+ trait::image::value_alignment::any,
trait::image::speed::any,
trait::image::speed::any,
const Image<I1>& input1, const Image<I2>& input2,
@@ -473,8 +473,8 @@ namespace mln
template <typename I1, typename I2, typename F>
mln_ch_value(I1, mln_result(F))
- transform_dispatch_2(trait::image::value_alignement::with_grid,
- trait::image::value_alignement::with_grid,
+ transform_dispatch_2(trait::image::value_alignment::with_grid,
+ trait::image::value_alignment::with_grid,
trait::image::speed::fastest,
trait::image::speed::fastest,
const Image<I1>& input1, const Image<I2>& input2,
@@ -502,8 +502,8 @@ namespace mln
transform_dispatch(const Image<I1>& input1, const Image<I2>& input2,
const Function_vv2v<F>& f)
{
- return transform_dispatch_2(mln_trait_image_value_alignement(I1)(),
- mln_trait_image_value_alignement(I2)(),
+ return transform_dispatch_2(mln_trait_image_value_alignment(I1)(),
+ mln_trait_image_value_alignment(I2)(),
mln_trait_image_speed(I1)(),
mln_trait_image_speed(I2)(),
input1, input2, f);
diff --git a/milena/mln/level/transform_inplace.hh b/milena/mln/level/transform_inplace.hh
index b3ad319..ca85b28 100644
--- a/milena/mln/level/transform_inplace.hh
+++ b/milena/mln/level/transform_inplace.hh
@@ -436,8 +436,8 @@ namespace mln
template <typename I1, typename I2, typename F>
void
- transform_inplace_dispatch(trait::image::value_alignement::any,
- trait::image::value_alignement::any,
+ transform_inplace_dispatch(trait::image::value_alignment::any,
+ trait::image::value_alignment::any,
trait::image::speed::any,
trait::image::speed::any,
Image<I1>& ima, const Image<I2>& aux,
@@ -448,8 +448,8 @@ namespace mln
template <typename I1, typename I2, typename F>
void
- transform_inplace_dispatch(trait::image::value_alignement::with_grid,
- trait::image::value_alignement::with_grid,
+ transform_inplace_dispatch(trait::image::value_alignment::with_grid,
+ trait::image::value_alignment::with_grid,
trait::image::speed::fastest,
trait::image::speed::fastest,
Image<I1>& ima, const Image<I2>& aux,
@@ -463,8 +463,8 @@ namespace mln
transform_inplace_dispatch(Image<I1>& ima, const Image<I2>& aux,
const Function_vv2v<F>& f)
{
- transform_inplace_dispatch(mln_trait_image_value_alignement(I1)(),
- mln_trait_image_value_alignement(I2)(),
+ transform_inplace_dispatch(mln_trait_image_value_alignment(I1)(),
+ mln_trait_image_value_alignment(I2)(),
mln_trait_image_speed(I1)(),
mln_trait_image_speed(I2)(),
ima, aux, f);
diff --git a/milena/mln/pw/image.hh b/milena/mln/pw/image.hh
index 75696e6..49a0afa 100644
--- a/milena/mln/pw/image.hh
+++ b/milena/mln/pw/image.hh
@@ -98,7 +98,7 @@ namespace mln
typedef trait::image::value_access::computed value_access;
typedef trait::image::value_storage::disrupted value_storage;
typedef trait::image::value_browsing::site_wise_only value_browsing;
- typedef trait::image::value_alignement::irrelevant value_alignement;
+ typedef trait::image::value_alignment::irrelevant value_alignment;
typedef mlc_if(is_mutable,
trait::image::value_io::read_write,
trait::image::value_io::read_only) value_io;
diff --git a/milena/mln/trait/image/props.hh b/milena/mln/trait/image/props.hh
index fbd5d43..971f815 100644
--- a/milena/mln/trait/image/props.hh
+++ b/milena/mln/trait/image/props.hh
@@ -183,7 +183,7 @@
// * image geometry
-// value_alignement:/any/
+// value_alignment:/any/
// |
// +-- with_grid
// |
@@ -458,22 +458,22 @@ namespace mln
struct disrupted : any { std::string name() const { return "value_storage::disrupted"; } };
};
-// value_alignement:/any/
+// value_alignment:/any/
// |
// +-- with_grid
// |
// +-- not_aligned
// |
// +-- irrelevant
- struct value_alignement
+ struct value_alignment
{
struct any { protected: any() {} };
struct with_grid
- : any { std::string name() const { return "value_alignement::with_grid"; } };
+ : any { std::string name() const { return "value_alignment::with_grid"; } };
struct not_aligned
- : any { std::string name() const { return "value_alignement::not_aligned"; } };
+ : any { std::string name() const { return "value_alignment::not_aligned"; } };
struct irrelevant
- : any { std::string name() const { return "value_alignement::irrelevant"; } };
+ : any { std::string name() const { return "value_alignment::irrelevant"; } };
};
// pw_io: /any/
diff --git a/milena/mln/trait/images.hh b/milena/mln/trait/images.hh
index c4b7721..d5da6df 100644
--- a/milena/mln/trait/images.hh
+++ b/milena/mln/trait/images.hh
@@ -62,7 +62,7 @@
# define mln_trait_image_pw_io(I) typename mln::trait::image_< I >::pw_io
# define mln_trait_image_vw_io(I) typename mln::trait::image_< I >::vw_io
# define mln_trait_image_vw_set(I) typename mln::trait::image_< I >::vw_set
-# define mln_trait_image_value_alignement(I) typename mln::trait::image_< I>::value_alignement
+# define mln_trait_image_value_alignment(I) typename mln::trait::image_< I>::value_alignment
# define mln_trait_image_localization(I) typename mln::trait::image_< I >::localization
# define mln_trait_image_dimension(I) typename mln::trait::image_< I >::dimension
@@ -141,7 +141,7 @@ namespace mln
// value
typedef undef vw_io;
typedef undef vw_set;
- typedef undef value_alignement;
+ typedef undef value_alignment;
typedef undef value_access;
typedef undef value_storage;
typedef undef value_browsing;
@@ -207,7 +207,7 @@ namespace mln
typedef typename image_<D>::dimension dimension;
// Memory organization
- typedef typename image_<D>::value_alignement value_alignement;
+ typedef typename image_<D>::value_alignment value_alignment;
typedef typename image_<D>::value_access value_access;
typedef typename image_<D>::value_storage value_storage;
typedef typename image_<D>::value_browsing value_browsing;
--
1.6.1.2
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog:
2009-02-10 Edwin Carlinet <carlinet(a)lrde.epita.fr>
Make leveling filter and mean accumulator clean.
* edwin/Makefile: Correct some errors.
* edwin/accu_trait.hh: Correct some errors.
* fred/leveling.cc: Main file to test leveling.
* fred/leveling_filter.hh: The leveling filter.
* fred/mean.hh: Accumulator to perform mean calculus.
---
edwin/Makefile | 10 -
edwin/accu_trait.hh | 2
fred/leveling.cc | 375 ------------------------------------------------
fred/leveling_filter.hh | 375 ++++++++++++++++++++++++++++++++++++++++++++++++
fred/mean.hh | 66 +++++---
5 files changed, 431 insertions(+), 397 deletions(-)
Index: trunk/milena/sandbox/fred/leveling_filter.hh
===================================================================
--- trunk/milena/sandbox/fred/leveling_filter.hh (revision 0)
+++ trunk/milena/sandbox/fred/leveling_filter.hh (revision 3340)
@@ -0,0 +1,375 @@
+// 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_CANVAS_MORPHO_LEVELING_FILTER_HH
+# define MLN_CANVAS_MORPHO_LEVELING_FILTER_HH
+
+/// \file mln/canvas/morpho/leveling_filter.hh
+///
+/// Apply leveling connected filter to images.
+///
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/concept/neighborhood.hh>
+# include <mln/core/concept/accumulator.hh>
+
+# include <mln/data/fill.hh>
+# include <mln/extension/adjust_fill.hh>
+
+# include <mln/level/sort_psites.hh>
+# include <mln/level/sort_offsets.hh>
+
+
+
+
+/*# include <mln/data/fill.hh>
+# include <mln/literal/zero.hh>
+# include <mln/convert/to_upper_window.hh>
+# include <mln/extension/adjust_fill.hh>
+# include <mln/util/pix.hh>
+*/
+
+namespace mln {
+ namespace canvas {
+ namespace morpho {
+
+ // Facade Fwd Declaration
+ template < typename I, typename N, typename A, typename L>
+ mln_concrete(I)
+ leveling_filter(const Image<I>& input, const Neighborhood<N>& nbh,
+ const Accumulator<A>& a, L lambda, bool increasing);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ // Implementations.
+
+ namespace impl {
+
+ namespace generic {
+
+ // Generic Version
+
+ template <typename I>
+ static inline
+ mln_psite(I)
+ find_root(I& parent, const mln_psite(I) & x)
+ {
+ if (parent(x) == x)
+ return x;
+ else
+ return parent(x) = find_root(parent, parent(x));
+ }
+
+ template < typename I, typename N, typename S, typename A, typename L>
+ mln_concrete(I)
+ leveling_filter(const Image<I>& input_, const Neighborhood<N>& nbh_,
+ const Site_Set<S>& s_, const Accumulator<A>& a_, L lambda)
+ {
+ trace::entering("canvas::morpho::impl::generic::leveling_filter");
+ // FIXME: Test?!
+
+ const I& input = exact(input_);
+ const N& nbh = exact(nbh_);
+ const S& s = exact(s_);
+ (void)a_; // To avoid warning at compilation
+
+ mln_concrete(I) output;
+ initialize(output, input);
+
+ // Local type.
+ typedef mln_psite(I) P;
+
+
+ // Auxiliary data.
+ mln_ch_value(I, bool) deja_vu;
+ mln_ch_value(I, bool) activity;
+ mln_ch_value(I, P) parent;
+ mln_ch_value(I, A) data;
+
+ // Initialization.
+ {
+ initialize(deja_vu, input);
+ mln::data::fill(deja_vu, false);
+ initialize(activity, input);
+ mln::data::fill(activity, true);
+ initialize(parent, input);
+ initialize(data, input);
+ //a.init(); // init required.
+ }
+
+ // First pass.
+ {
+ mln_fwd_piter(S) p(s); // s required.
+ mln_niter(N) n(nbh, p);
+
+ for_all(p)
+ {
+ // Make set.
+ {
+ parent(p) = p;
+ data(p).take_as_init(make::pix(input, p));
+ }
+
+ for_all(n)
+ if (input.domain().has(n) && deja_vu(n))
+ {
+ //do_union(n, p);
+ P r = find_root(parent, n);
+ if (r != p)
+ {
+ if (input(r) == input(p) || (activity(r) && (data(r) < lambda))) // Equiv(r, p)
+ // Either a flat zone or the component of r is still growing.
+ {
+ /* FIXME: Same remark as above concerning the
+ initialization of data(p); instead of
+
+ data(p).take(data(r));
+
+ we should (or could) have
+
+ unite_data(p, r);
+
+ so as to keep the generic aspect of this canvas
+ (as long as the set of acceptable types for the
+ template parameter A is not bound). */
+ data(p).take(data(r));
+ parent(r) = p;
+ if (activity(r) == false)
+ activity(p) = false;
+ }
+ else
+ {
+ activity(p) = false;
+ }
+ }
+ }
+ deja_vu(p) = true;
+ }
+ }
+
+ // Second pass.
+ {
+ mln_bkd_piter(S) p(s);
+ for_all(p)
+ if (parent(p) == p) // p is root.
+ output(p) = input(p);
+ else
+ output(p) = output(parent(p));
+ }
+
+ trace::exiting("canvas::morpho::impl::generic::leveling_filter");
+ return output;
+ }
+
+ } // end of namespace mln::canvas::morpho::impl::generic
+
+
+ // Fastest version.
+
+
+ template <typename I>
+ inline
+ unsigned
+ find_root_fastest(I& parent, unsigned x)
+ {
+ if (parent.element(x) == x)
+ return x;
+ else
+ return parent.element(x) = find_root_fastest(parent, parent.element(x));
+ }
+
+ template < typename I, typename N, typename A, typename L>
+ mln_concrete(I)
+ leveling_filter_fastest(const Image<I>& input_, const Neighborhood<N>& nbh_,
+ const util::array<unsigned>& s, const Accumulator<A>& a_, L lambda)
+ {
+ trace::entering("canvas::morpho::impl::leveling_fastest");
+
+ // FIXME: Tests?
+
+ const I& input = exact(input_);
+ const N& nbh = exact(nbh_);
+
+ mln_concrete(I) output;
+ initialize(output, input);
+
+ // Local type.
+ typedef mln_psite(I) P;
+
+ // Auxiliary data.
+ mln_ch_value(I, bool) deja_vu;
+ mln_ch_value(I, bool) activity;
+ mln_ch_value(I, unsigned) parent;
+ mln_ch_value(I, A) data;
+
+ // Initialization.
+ {
+ initialize(deja_vu, input);
+ mln::data::fill(deja_vu, false);
+ initialize(activity, input);
+ mln::data::fill(activity, true);
+ initialize(parent, input);
+ mln::data::fill(parent, 0);
+ initialize(data, input);
+ }
+
+ util::array<int> dp = offsets_wrt(input, nbh);
+ const unsigned n_nbhs = dp.nelements();
+ const unsigned n_points = s.nelements();
+
+ // First pass.
+ {
+
+ for (unsigned i = 0; i < n_points; ++i)
+ {
+ unsigned p = s[i]; // An offset.
+
+ // Make set.
+ parent.element(p) = p;
+ data.element(p).take_as_init(input.element(p));
+
+ for (unsigned j = 0; j < n_nbhs; ++j)
+ {
+ unsigned n = p + dp[j];
+ if (!deja_vu.element(n))
+ continue;
+
+ unsigned r = find_root_fastest(parent, n);
+ if (r != p)
+ {
+ if (input.element(r) == input.element(p)
+ || (activity.element(r)
+ && (data.element(r) < lambda)))
+ {
+ data.element(p).take(data.element(r));
+ parent.element(r) = p;
+ if (activity.element(r) == false)
+ activity.element(p) = false;
+ }
+ else
+ activity.element(p) = false;
+ }
+ }
+
+ deja_vu.element(p) = true;
+ }
+
+ }
+
+ // Second pass.
+ {
+ for (int i = n_points - 1; i >= 0 ; --i)
+ {
+ unsigned p = s[i];
+ if (parent.element(p) == p) // p is root.
+ output.element(p) = input.element(p);
+ else
+ output.element(p) = output.element(parent.element(p));
+ }
+ }
+
+ trace::exiting("canvas::morpho::impl::leveling_fastest");
+ return output;
+ }
+
+ } // end of namespace mln::canvas::morpho::impl
+
+ // Dispatch.
+ namespace internal
+ {
+
+ // Leveling
+ template < typename I, typename N, typename A, typename L>
+ mln_concrete(I)
+ leveling_filter_dispatch(metal::false_,
+ const Image<I>& input, const Neighborhood<N>& nbh,
+ const Accumulator<A>& a, L lambda, bool increasing)
+ {
+ p_array < mln_psite(I) > s =
+ increasing ?
+ level::sort_psites_increasing(input) :
+ level::sort_psites_decreasing(input);
+ return impl::generic::leveling_filter(input, nbh, s, a, lambda);
+ }
+
+ template < typename I, typename N, typename A, typename L>
+ mln_concrete(I)
+ leveling_filter_dispatch(metal::true_,
+ const Image<I>& input, const Neighborhood<N>& nbh,
+ const Accumulator<A>& a, L lambda, bool increasing)
+ {
+ util::array<unsigned> s =
+ increasing ?
+ level::sort_offsets_increasing(input) :
+ level::sort_offsets_decreasing(input);
+ return impl::leveling_filter_fastest(input, nbh, s, a, lambda);
+ }
+
+ template < typename I, typename N, typename A, typename L>
+ inline
+ mln_concrete(I)
+ leveling_filter_dispatch(const Image<I>& input, const Neighborhood<N>& nbh,
+ const Accumulator<A>& a, L lambda, bool increasing)
+ {
+ enum
+ {
+ test = mlc_equal(mln_trait_image_speed(I),
+ trait::image::speed::fastest)::value
+ && mlc_equal(mln_trait_accumulator_when_pix(A),
+ trait::accumulator::when_pix::use_v)::value
+ && mln_is_simple_neighborhood(N)::value
+ };
+ return leveling_filter_dispatch(metal::bool_<test>(),
+ input, nbh, a, lambda, increasing);
+ }
+
+ } // end of namespace mln::canvas::morpho::internal
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+
+ // Facade.
+
+ template < typename I, typename N, typename A, typename L>
+ inline
+ mln_concrete(I)
+ leveling_filter(const Image<I>& input, const Neighborhood<N>& nbh,
+ const Accumulator<A>& a, L lambda, bool increasing)
+ {
+ //FIXME: Do we need to check input validity ?
+ return internal::leveling_filter_dispatch(input, nbh, a, lambda, increasing);
+ }
+
+ } // end of namespace mln::canvas::morpho
+ } // end of namespace mln::canvas
+} // end of namespace mln
+
+
+#endif // ! MLN_CANVAS_MORPHO_LEVELING_FILTER_HH
Index: trunk/milena/sandbox/fred/leveling.cc
===================================================================
--- trunk/milena/sandbox/fred/leveling.cc (revision 3339)
+++ trunk/milena/sandbox/fred/leveling.cc (revision 3340)
@@ -1,372 +1,11 @@
-// 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_CANVAS_LEVELING_HH
-# define MLN_CANVAS_LEVELING_HH
-
-/// \file mln/canvas/leveling.hh
-///
-/// Apply leveling connected filter to images.
-///
-/// \todo Debug, add input validity check.
-
-# include <mln/core/concept/image.hh>
-# include <mln/data/fill.hh>
-# include <mln/literal/zero.hh>
-# include <mln/convert/to_upper_window.hh>
-# include <mln/extension/adjust_fill.hh>
-# include <mln/level/sort_psites.hh>
-# include <mln/level/sort_offsets.hh>
-# include <mln/core/alias/neighb2d.hh>
-# include <mln/util/pix.hh>
-
-# include "accu_trait.hh"
-# include "mean.hh"
-
-namespace mln
-{
-
- namespace canvas
- {
-
- template < typename I, typename N, typename A, typename L>
- mln_concrete(I)
- leveling(const Image<I>& input, const Neighborhood<N>& nbh,
- const Accumulator<A>& a, L lambda, bool increasing);
-
-# ifndef MLN_INCLUDE_ONLY
-
- // Implementations.
-
- namespace impl
- {
-
- namespace generic
- {
-
- template <typename I>
- static inline
- mln_psite(I)
- find_root(I& parent, const mln_psite(I) & x)
- {
- if (parent(x) == x)
- return x;
- else
- return parent(x) = find_root(parent, parent(x));
- }
-
- template < typename I, typename N, typename S, typename A, typename L>
- mln_concrete(I)
- leveling(const Image<I>& input_, const Neighborhood<N>& nbh_,
- const Site_Set<S>& s_, const Accumulator<A>& a_, L lambda)
- {
- trace::entering("canvas::impl::generic::leveling");
-
- // FIXME: Test?!
-
- const I& input = exact(input_);
- const N& nbh = exact(nbh_);
- const S& s = exact(s_);
- //const A& a = exact(a_);
- (void)a_;
- // Local type.
- typedef mln_psite(I) P;
-
- mln_concrete(I) output;
- initialize(output, input);
-
- // Auxiliary data.
- mln_ch_value(I, bool) deja_vu;
- mln_ch_value(I, bool) activity;
- mln_ch_value(I, P) parent;
- mln_ch_value(I, A) data;
-
- // Initialization.
- {
- initialize(deja_vu, input);
- mln::data::fill(deja_vu, false);
- initialize(activity, input);
- mln::data::fill(activity, true);
- initialize(parent, input);
- initialize(data, input);
-// a.init(); // init required.
- }
-
- // First pass.
- {
- mln_fwd_piter(S) p(s); // s required.
- mln_niter(N) n(nbh, p);
-
- for_all(p)
- {
- // Make set.
- {
- parent(p) = p;
- data(p).take_as_init(make::pix(input, p));
- }
-
- for_all(n)
- if (input.domain().has(n) && deja_vu(n))
- {
- //do_union(n, p);
- P r = find_root(parent, n);
- if (r != p)
- {
- if (input(r) == input(p) || (activity(r) && (data(r) < lambda))) // Equiv(r, p)
- // Either a flat zone or the component of r is still growing.
- {
- /* FIXME: Same remark as above concerning the
- initialization of data(p); instead of
-
- data(p).take(data(r));
-
- we should (or could) have
-
- unite_data(p, r);
-
- so as to keep the generic aspect of this canvas
- (as long as the set of acceptable types for the
- template parameter A is not bound). */
- data(p).take(data(r));
- parent(r) = p;
- if (activity(r) == false)
- activity(p) = false;
- }
- else
- {
- activity(p) = false;
- }
- }
- }
- deja_vu(p) = true;
- }
- }
-
- // Second pass.
- {
- mln_bkd_piter(S) p(s);
- for_all(p)
- if (parent(p) == p) // p is root.
- output(p) = input(p);
- else
- output(p) = output(parent(p));
- }
-
- trace::exiting("canvas::morpho::impl::generic::leveling");
- return output;
- }
-
- } // end of namespace mln::canvas::impl::generic
-
- // Fastest version.
- template <typename I>
- inline
- unsigned
- find_root_fastest(I& parent, unsigned x)
- {
- if (parent.element(x) == x)
- return x;
- else
- return parent.element(x) = find_root_fastest(parent, parent.element(x));
- }
-
- template < typename I, typename N, typename A, typename L>
- mln_concrete(I)
- leveling_fastest(const Image<I>& input_, const Neighborhood<N>& nbh_,
- const util::array<unsigned>& s, const Accumulator<A>& a_, L lambda)
- {
- trace::entering("canvas::impl::leveling_fastest");
-
- // FIXME: Tests?
- const I& input = exact(input_);
- const N& nbh = exact(nbh_);
-
- mln_concrete(I) output;
- initialize(output, input);
-
- // Local type.
- typedef mln_psite(I) P;
-
- // Auxiliary data.
- mln_ch_value(I, bool) deja_vu;
- mln_ch_value(I, bool) activity;
- mln_ch_value(I, unsigned) parent;
- mln_ch_value(I, A) data;
-
- // Initialization.
- {
- initialize(deja_vu, input);
- mln::data::fill(deja_vu, false);
- initialize(activity, input);
- mln::data::fill(activity, true);
- initialize(parent, input);
- mln::data::fill(parent, 0);
- initialize(data, input);
- }
-
- util::array<int> dp = offsets_wrt(input, nbh);
- const unsigned n_nbhs = dp.nelements();
- const unsigned n_points = s.nelements();
-
- // First pass.
- {
-
- for (unsigned i = 0; i < n_points; ++i)
- {
- unsigned p = s[i]; // An offset.
-
- // Make set.
- parent.element(p) = p;
- data.element(p).take_as_init(input.element(p));
-
- for (unsigned j = 0; j < n_nbhs; ++j)
- {
- unsigned n = p + dp[j];
- if (!deja_vu.element(n))
- continue;
-
- unsigned r = find_root_fastest(parent, n);
- if (r != p)
- {
- if (input.element(r) == input.element(p)
- || (activity.element(r)
- && (data.element(r) < lambda)))
- {
- data.element(p).take(data.element(r));
- parent.element(r) = p;
- if (activity.element(r) == false)
- activity.element(p) = false;
- }
- else
- activity.element(p) = false;
- }
- }
-
- deja_vu.element(p) = true;
- }
-
- }
-
- // Second pass.
- {
- for (int i = n_points - 1; i >= 0 ; --i)
- {
- unsigned p = s[i];
- if (parent.element(p) == p) // p is root.
- output.element(p) = input.element(p);
- else
- output.element(p) = output.element(parent.element(p));
- }
- }
-
- trace::exiting("canvas::impl::leveling_fastest");
- return output;
- }
-
- } // end of namespace mln::canvas::impl
-
- // Dispatch.
- namespace internal
- {
-
- // Leveling
- template < typename I, typename N, typename A, typename L>
- mln_concrete(I)
- leveling_dispatch(metal::false_,
- const Image<I>& input, const Neighborhood<N>& nbh,
- const Accumulator<A>& a, L lambda, bool increasing)
- {
- p_array < mln_psite(I) > s =
- increasing ?
- level::sort_psites_increasing(input) :
- level::sort_psites_decreasing(input);
- return impl::generic::leveling(input, nbh, s, a, lambda);
- }
-
- template < typename I, typename N, typename A, typename L>
- mln_concrete(I)
- leveling_dispatch(metal::true_,
- const Image<I>& input, const Neighborhood<N>& nbh,
- const Accumulator<A>& a, L lambda, bool increasing)
- {
- util::array<unsigned> s =
- increasing ?
- level::sort_offsets_increasing(input) :
- level::sort_offsets_decreasing(input);
- return impl::leveling_fastest(input, nbh, s, a, lambda);
- }
-
- template < typename I, typename N, typename A, typename L>
- inline
- mln_concrete(I)
- leveling_dispatch(const Image<I>& input, const Neighborhood<N>& nbh,
- const Accumulator<A>& a, L lambda, bool increasing)
- {
- enum
- {
- test = mlc_equal(mln_trait_image_speed(I),
- trait::image::speed::fastest)::value
- && mlc_equal(mln_trait_accu_when_pix(A),
- trait::accu::when_pix::use_only_v)::value
- && mln_is_simple_neighborhood(N)::value
- };
- return leveling_dispatch(metal::bool_<test>(),
- input, nbh, a, lambda, increasing);
- }
-
-
- } // end of namespace mln::canvas::internal
-
- // Facades.
- template < typename I, typename N, typename A, typename L>
- inline
- mln_concrete(I)
- leveling(const Image<I>& input, const Neighborhood<N>& nbh,
- const Accumulator<A>& a, L lambda, bool increasing)
- {
-// FIXME: Do we need to check input validity ?
- return internal::leveling_dispatch(input, nbh, a, lambda, increasing);
- }
-
-# endif // ! MLN_INCLUDE_ONLY
-
- } // end of namespace mln::canvas
-
-} // end of namespace mln
-
-
-#endif // ! MLN_CANVAS_LEVELING_HH
#include <mln/core/image/image2d.hh>
#include <mln/io/pgm/all.hh>
#include <mln/util/timer.hh>
-#include "../edwin/card.hh"
+#include <mln/core/alias/neighb2d.hh>
+#include "mean.hh"
+#include "leveling_filter.hh"
int main(int argc, char** argv)
{
@@ -380,27 +19,27 @@
float elapsed;
mln::util::timer chrono;
- mln::morpho::accu::mean<I> c;
+ mln::morpho::attribute::mean<I> c;
int lambda = atoi(argv[1]);
mln::io::pgm::load(lena, "../../img/lena.pgm");
I out;
chrono.start();
- out = mln::canvas::leveling(lena, c4(), c, lambda, true);
+ out = mln::canvas::morpho::leveling_filter(lena, c4(), c, lambda, true);
elapsed = chrono.stop();
std::cout << "(auto) " << elapsed << "s" << std::endl;
mln::io::pgm::save(out, "auto.pgm");
chrono.start();
- out = mln::canvas::internal::leveling_dispatch(mln::metal::true_(), lena, c4(), c, lambda, true);
+ out = mln::canvas::morpho::internal::leveling_filter_dispatch(mln::metal::true_(), lena, c4(), c, lambda, true);
elapsed = chrono.stop();
std::cout << "(fast) " << elapsed << "s" << std::endl;
mln::io::pgm::save(out, "fast.pgm");
chrono.start();
- out = mln::canvas::internal::leveling_dispatch(mln::metal::false_(), lena, c4(), c, lambda, true);
+ out = mln::canvas::morpho::internal::leveling_filter_dispatch(mln::metal::false_(), lena, c4(), c, lambda, true);
elapsed = chrono.stop();
std::cout << "(slow) " << elapsed << "s" << std::endl;
Index: trunk/milena/sandbox/fred/mean.hh
===================================================================
--- trunk/milena/sandbox/fred/mean.hh (revision 3339)
+++ trunk/milena/sandbox/fred/mean.hh (revision 3340)
@@ -26,32 +26,51 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_MORPHO_ACCU_MEAN_HH
-# define MLN_MORPHO_ACCU_MEAN_HH
+#ifndef MLN_MORPHO_ATTRIBUTE_MEAN_HH
+# define MLN_MORPHO_ATTRIBUTE_MEAN_HH
-/// \file mln/morpho/accu/mean.hh
+/// \file mln/morpho/attribute/mean.hh
///
-/// Mean leveling accumulator.
+/// Define an accumulator that computes the mean of a
+/// component.
///
-/// \todo Debug.
-# include <mln/core/macros.hh>
-# include <mln/core/concept/accumulator.hh>
-# include <mln/util/pix.hh>
+# include <mln/accu/internal/base.hh>
# include <mln/accu/mean.hh>
-
-# include "accu_trait.hh"
+# include <mln/util/pix.hh>
namespace mln {
+ // Forward declaration.
+
namespace morpho {
+ namespace attribute {
+ template <typename I> class mean;
+ }
+ }
- namespace accu {
+ // Traits
+ namespace trait {
template <typename I>
+ struct accumulator_< morpho::attribute::mean<I> >
+ {
+ typedef accumulator::has_untake::no has_untake;
+ typedef accumulator::has_set_value::no has_set_value;
+ typedef accumulator::has_stop::no has_stop;
+ typedef accumulator::when_pix::use_v when_pix;
+ };
+ }
+
+
+ namespace morpho {
+
+ namespace attribute {
+
/// Morphological (i.e. for pixel and pixel values) accumulator calculating mean.
/// Valid for leveling algorithm.
/// FIXME: is inclusion polyphormism really appliable ?
+ template <typename I>
class mean: public mln::accu::internal::base<typename mln::accu::mean<mln_value(I)>::result, mean<I> >
{
public:
@@ -61,20 +80,29 @@
mean();
+
+ /// Manipulators.
+ /// \{
void init();
void take(const mln_value(I)& v);
void take(const argument& t);
void take(const mean<I>& m);
+ /// \}
+ /// Get the value of the accumulator.
result to_result() const;
+ /// Check whether this accu is able to return a result.
bool is_valid() const;
- private:
+ protected:
+ /// The mean
mln::accu::mean<mln_value(I)> accu_;
};
+
+
# ifndef MLN_INCLUDE_ONLY
template <typename I>
@@ -135,21 +163,10 @@
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace mln::morpho::accu
+ } // end of namespace mln::morpho::attribute
} // end of namespace mln::morpho
- namespace trait {
-
- template <typename I>
- struct accu_< morpho::accu::mean<I> > :
- public undefined_accu_ < morpho::accu::mean<I> >
- {
- typedef accu::when_pix::use_only_v when_pix;
- };
-
- } // end of namespace mln::trait
-
} // end of namespace mln
-#endif /* ! MLN_MORPHO_ACCU_MEAN_HH */
\ No newline at end of file
+#endif /* ! MLN_MORPHO_ATTRIBUTE_MEAN_HH */
Index: trunk/milena/sandbox/edwin/accu_trait.hh
===================================================================
--- trunk/milena/sandbox/edwin/accu_trait.hh (revision 3339)
+++ trunk/milena/sandbox/edwin/accu_trait.hh (revision 3340)
@@ -23,7 +23,7 @@
namespace morpho {
namespace accu
{
- template <typename T>
+ template <typename I>
struct card;
}
}
Index: trunk/milena/sandbox/edwin/Makefile
===================================================================
--- trunk/milena/sandbox/edwin/Makefile (revision 3339)
+++ trunk/milena/sandbox/edwin/Makefile (revision 3340)
@@ -1,10 +1,11 @@
-TARGET=accu
-OBJS=accu.o
+TARGET=algebraic
+SRC=algebraic.cc
+OBJS=${SRC:.cc=.o}
OLENADIR=../../..
MILENADIR=$(OLENADIR)/milena
-CXXFLAGS=-I$(MILENADIR) -I./ -DNDEBUG -O2 -ffast-math
+CXXFLAGS=-I$(MILENADIR) -I./ -DNDEBUG -O3 -ffast-math
CXX=g++
LD=g++
LDFLAGS=
@@ -14,3 +15,6 @@
%.o: %.cc
$(CXX) $(CXXFLAGS) -c $<
+
+%.o: %.hh
+ $(CXX) $(CXXFLAGS) -c $<
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2009-02-10 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Fix save function for cloud.
* mln/io/cloud/save.hh: Fix (save_data).
---
save.hh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: trunk/milena/mln/io/cloud/save.hh
===================================================================
--- trunk/milena/mln/io/cloud/save.hh (revision 3338)
+++ trunk/milena/mln/io/cloud/save.hh (revision 3339)
@@ -64,10 +64,10 @@
inline
void save_data(const p_array<P>& arr, std::ofstream& file)
{
- std::ostringstream sline;
mln_piter(p_array<P>) p(arr);
for_all(p)
{
+ std::ostringstream sline;
algebra::vec<P::dim,float> v = p.to_site().to_vec();
sline << v[0];
for (unsigned i = 1; i < P::dim; ++i)
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog:
2009-02-10 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Add test file for IGR.
* fabien/igr/dump2ppm.cc: New tool to convert dump file to ppm.
* fabien/igr/igr.cc: New test file for IRM dump.
---
dump2ppm.cc | 35 +++++++++++++
igr.cc | 153 ++++++++++++++++++++++++++++++++++++++++++++++--------------
2 files changed, 153 insertions(+), 35 deletions(-)
Index: trunk/milena/sandbox/fabien/igr/igr.cc
===================================================================
--- trunk/milena/sandbox/fabien/igr/igr.cc (revision 3337)
+++ trunk/milena/sandbox/fabien/igr/igr.cc (revision 3338)
@@ -26,12 +26,27 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
+#include <mln/core/concept/image.hh>
+#include <mln/core/concept/neighborhood.hh>
+
#include <mln/core/image/image2d.hh>
+#include <mln/core/image/image3d.hh>
+
#include <mln/value/int_u8.hh>
+#include <mln/value/rgb8.hh>
+
#include <mln/io/pgm/all.hh>
#include <mln/io/pbm/all.hh>
+#include <mln/io/ppm/all.hh>
+#include <mln/io/cloud/all.hh>
+
#include <mln/core/alias/neighb2d.hh>
+#include <mln/core/alias/neighb3d.hh>
#include <mln/labeling/flat_zones.hh>
+#include <mln/literal/colors.hh>
+#include <mln/norm/l1.hh>
+
+#include <mln/io/dump/all.hh>
#include <mln/labeling/blobs.hh>
#include <mln/labeling/compute.hh>
@@ -39,64 +54,132 @@
#include <mln/fun/v2b/threshold.hh>
#include <mln/level/transform.hh>
#include <mln/accu/count.hh>
-#include <mln/value/label_8.hh>
+#include <mln/accu/center.hh>
+#include <mln/set/compute.hh>
+#include <mln/value/label_16.hh>
#include <mln/data/fill.hh>
#include <mln/pw/all.hh>
+#include <mln/morpho/elementary/gradient_internal.hh>
//FIXME: remove
#include <mln/essential/2d.hh>
+#include <iostream>
+#include <mln/debug/println.hh>
-//struct threshold : Function_v2v<threshold>
-//{
-// typedef bool result;
-// bool operator() (int_u8 val) const {if (val < 25) return false; return true;}
-//};
-int main()
+template <typename I, typename N, typename L>
+mln_ch_value(I, mln::value::rgb8)
+igr(const mln::Image<I>& input_, const mln::Neighborhood<N>& nbh_, L& nlabels)
{
using namespace mln;
using value::int_u8;
- using value::label_8;
+ using value::rgb8;
- trace::quiet = false;
+ const I& input = exact(input_);
+ const N& nbh = exact(nbh_);
- image2d<int_u8> src;
- io::pgm::load(src, "img/slice_7.pgm");
+ // Threshold.
- image2d<bool> threshold = level::transform(src, fun::v2b::threshold<int_u8>(25));
+ mln_ch_value(I, bool) threshold = level::transform(input, fun::v2b::threshold<int_u8>(25));
- label_8 n;
- image2d<label_8> labels = labeling::flat_zones(threshold, c4(), n);
+ // Labeling.
+
+ mln_ch_value(I, L) labels = labeling::flat_zones(threshold, nbh, nlabels);
accu::count<int_u8> a_;
- util::array<unsigned> a = labeling::compute(a_, src, labels, n);
+ util::array<unsigned> a = labeling::compute(a_, threshold, labels, nlabels);
+
+ // We keep the third and second biggest object.
- mln_ch_value_(image2d<int_u8>, bool) biggest;
- initialize(biggest, src);
- data::fill(biggest, false);
- unsigned x = 0;
- unsigned y = 0;
- unsigned z = 0;
+ mln_ch_value(I, bool) big_second;
+ initialize(big_second, input);
+ data::fill(big_second, false);
+ unsigned big_third_count = 0;
+ unsigned big_third_lbl = 0;
+ unsigned big_second_count = 0;
+ unsigned big_second_lbl = 0;
+ unsigned big_first_count = 0;
+ unsigned big_first_lbl = 0;
for (int i = 0; i < a.nelements(); ++i)
{
- if (a[i] > x)
- x = a[i];
- if (x > y)
+ if (a[i] > big_third_count)
{
- int swap = y;
- y = x;
- x = swap;
+ big_third_count = a[i];
+ big_third_lbl = i;
}
- if (y > z)
+ if (big_third_count > big_second_count)
+ {
+ int swap = big_second_count;
+ int swap_lbl = big_second_lbl;
+ big_second_count = big_third_count;
+ big_second_lbl = big_third_lbl;
+ big_third_count = swap;
+ big_third_lbl = swap_lbl;
+ }
+ if (big_second_count > big_first_count)
+ {
+ int swap = big_first_count;
+ int swap_lbl = big_first_lbl;
+ big_first_count = big_second_count;
+ big_first_lbl = big_second_lbl;
+ big_second_count = swap;
+ big_second_lbl = swap_lbl;
+ }
+ }
+ mln_VAR(big_third, threshold | pw::value(labels) == big_third_lbl);
+
+ data::fill((big_second | pw::value(labels) == big_second_lbl).rw(), true);
+
+ // Gradient.
+
+ mln_ch_value(I, bool) gradient = morpho::elementary::gradient_internal(big_second, nbh);
+ mln_VAR(gradient_map, gradient | pw::value(gradient) == true);
+
+ mln_ch_value(I, rgb8) result = level::convert(rgb8(), input);
+ data::fill((result | gradient_map.domain()).rw(), literal::red);
+
+ // Center.
+
+ accu::center<mln_site(I)> center_;
+ mln_site(I) center = set::compute(center_, big_third.domain());
+ result(center) = literal::red;
+
+ // Distance.
+
+ mln_fwd_piter(gradient_map_t) p(gradient_map.domain());
+ p_array<mln_site(I)> arr;
+ for_all(p)
+ {
+ if (mln::norm::l1_distance(p.to_site().to_vec(), center.to_vec()) < 200)
{
- int swap = z;
- z = y;
- y = swap;
+ result(p) = literal::green;
+
+ arr.append(p);
+ }
}
+
+ // Save the cloud in a file.
+
+ std::cout << "Nbr sites = " << arr.nsites() << std::endl;
+ io::cloud::save(arr, "cloud.txt");
+
+ return result;
}
- data::fill((biggest | pw::value(labels) == x).rw(), true);
- data::fill((biggest | pw::value(labels) == y).rw(), true);
- // gradient_internal, center
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+ using value::label_16;
+
+ trace::quiet = false;
+
+// image2d<int_u8> src;
+// io::pgm::load(src, "img/slice_7.pgm");
+ image3d<int_u8> vol;
+ io::dump::load(vol, "img/IRM.dump");
+
+ label_16 nlabels;
- io::pbm::save(biggest, "out.pgm");
+// io::ppm::save(igr(src, c4(), nlabels), "out.ppm");
+ io::dump::save(igr(vol, c6(), nlabels), "out.raw");
}
Index: trunk/milena/sandbox/fabien/igr/dump2ppm.cc
===================================================================
--- trunk/milena/sandbox/fabien/igr/dump2ppm.cc (revision 0)
+++ trunk/milena/sandbox/fabien/igr/dump2ppm.cc (revision 3338)
@@ -0,0 +1,35 @@
+
+#include <mln/core/image/image2d.hh>
+#include <mln/make/image3d.hh>
+#include <mln/debug/slices_2d.hh>
+
+#include <mln/value/rgb8.hh>
+#include <mln/io/dump/load.hh>
+#include <mln/io/ppm/save.hh>
+
+#include <mln/literal/colors.hh>
+
+
+void usage(char* argv[])
+{
+ std::cerr << "usage: " << argv[0] << " input.dump output.ppm" << std::endl;
+ abort();
+}
+
+
+
+int main(int argc, char* argv[])
+{
+ using namespace mln;
+ using value::rgb8;
+
+ if (argc != 3)
+ usage(argv);
+
+ image3d<rgb8> vol;
+ io::dump::load(vol, argv[1]);
+
+ rgb8 bg = literal::black;
+ image2d<rgb8> ima = debug::slices_2d(vol, 1.f, bg);
+ io::ppm::save(ima, argv[2]);
+}
1
0
---
.gitignore | 1 +
ChangeLog | 4 ++++
2 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/.gitignore b/.gitignore
index eaa60f0..b130779 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
# Global.
*~
+*.dSYM
.deps
Makefile.in
Makefile
diff --git a/ChangeLog b/ChangeLog
index d4c4716..e8a5431 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2009-02-10 Roland Levillain <roland(a)lrde.epita.fr>
+
+ * .gitignore: Ignore pattern `*.dSYM'.
+
2009-02-04 Roland Levillain <roland(a)lrde.epita.fr>
Move M4 files into m4/.
--
1.6.1.2
1
0
---
ChangeLog | 16 ----------------
milena/ChangeLog | 8 ++++----
milena/sandbox/ChangeLog | 26 +++++++++++++++++++++-----
3 files changed, 25 insertions(+), 25 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 0986d0a..d4c4716 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,19 +1,3 @@
-2009-02-10 Frederic Bour <bour(a)lrde.epita.fr>
-
- [sandbox][bour] ~Working algebraic, wip leveling.
- * milena/sandbox/fred/Makefile: .
- * milena/sandbox/fred/accu_trait.hh: New.
- * milena/sandbox/fred/algebraic.cc: .
- * milena/sandbox/fred/closing_area.cc: New.
- * milena/sandbox/fred/leveling.cc: New.
- * milena/sandbox/fred/mean.hh: New.
-
-2009-02-09 Frederic Bour <bour(a)epita.lrde.epita.fr>
-
- [sandbox][bour] Added Makefile to sandbox/edwin for algebraic/lvl.
- * milena/sandbox/edwin/Makefile: New.
- * milena/sandbox/edwin/leveling.hh: .
-
2009-02-04 Roland Levillain <roland(a)lrde.epita.fr>
Move M4 files into m4/.
diff --git a/milena/ChangeLog b/milena/ChangeLog
index e36c337..224ccad 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -191,7 +191,7 @@
* mln/registration/icp2.hh: Add two new variants.
2009-02-05 Guillaume Lazzara <z(a)lrde.epita.fr>
-
+
Small changes in transformation related classes.
* mln/algebra/quat.hh: use mln_precondition instead of assert.
@@ -212,7 +212,7 @@
* tests/make/Makefile.am,
* tests/make/h_mat.cc: add a missing test.
-
+
2009-02-05 Guillaume Lazzara <z(a)lrde.epita.fr>
Fix wrong comments in fun::x2x:composed.
@@ -264,7 +264,7 @@
* mln/win/sym.hh: enable preconditions.
2009-02-05 Guillaume Lazzara <z(a)lrde.epita.fr>
-
+
Cleanup accu::rms.
* mln/accu/rms.hh: rename attributes and add a hook to the underlying
@@ -6723,7 +6723,7 @@
Rename target "internal" to "complete.
* doc/tutorial/todoxygen.sh: script to convert .tex files to .html
- files. It uses Hevea.
+ files. It uses Hevea.
* doc/tutorial/samples/borderthickness.cc,
* doc/tutorial/samples/extension-ignore2.cc,
diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog
index 448a251..93eee52 100644
--- a/milena/sandbox/ChangeLog
+++ b/milena/sandbox/ChangeLog
@@ -10,11 +10,21 @@
2009-02-10 Frederic Bour <bour(a)lrde.epita.fr>
- [sandbox][bour] Leveling filter with test.
+ Leveling filter with test.
* fred/Makefile: Modified to test leveling.
* fred/leveling.cc: Working leveling filter.
* fred/mean.hh: Corrected bugs.
+2009-02-10 Frederic Bour <bour(a)lrde.epita.fr>
+
+ Working algebraic, wip leveling.
+ * milena/sandbox/fred/Makefile: .
+ * milena/sandbox/fred/accu_trait.hh: New.
+ * milena/sandbox/fred/algebraic.cc: .
+ * milena/sandbox/fred/closing_area.cc: New.
+ * milena/sandbox/fred/leveling.cc: New.
+ * milena/sandbox/fred/mean.hh: New.
+
2009-02-09 Edwin Carlinet <carlinet(a)lrde.epita.fr>
Try to make algebraic_union_find filter work with new accus.
@@ -24,7 +34,7 @@
2009-02-09 Frederic Bour <bour(a)lrde.epita.fr>
- [sandbox][bour] Wip of algebraic filter implementation.
+ Wip of algebraic filter implementation.
* fred/Makefile: New.
* fred/algebraic.cc: New.
@@ -36,7 +46,13 @@
2009-02-09 Frederic Bour <bour(a)epita.lrde.epita.fr>
- [sandbox][bour][carlinet] Work on properties and accumulators.
+ Added Makefile to sandbox/edwin for algebraic/lvl.
+ * milena/sandbox/edwin/Makefile: New.
+ * milena/sandbox/edwin/leveling.hh: .
+
+2009-02-09 Frederic Bour <bour(a)epita.lrde.epita.fr>
+
+ Work on properties and accumulators.
* ChangeLog: .
* edwin/accu.cc: .
* edwin/accu_trait.hh: .
@@ -50,7 +66,7 @@
Update igr's code.
- * lazzara/igr.cc: update code. More debug.
+ * lazzara/igr.cc: update code. More debug.
* lazzara/igr-cloud.cc: new. Register clouds of points.
@@ -2571,7 +2587,7 @@
* abraham/mln/math/cos.hh: New
templated mln::math::cos function.
* abraham/mln/math/acos.hh: New
- templated mln::math::acos function.
+ templated mln::math::acos function.
2008-10-06 Alexandre Abraham <abraham(a)lrde.epita.fr>
--
1.6.1.2
1
0
* camille/: New directory.
* camille/graph-line-gradient-closing.cc,
* camille/graph-wst.cc: New.
* camille/Makefile: New.
* camille/.gitignore: New.
---
milena/sandbox/ChangeLog | 10 +
milena/sandbox/camille/.gitignore | 4 +
milena/sandbox/camille/Makefile | 9 +
.../sandbox/camille/graph-line-gradient-closing.cc | 149 +++++++++++++
milena/sandbox/camille/graph-wst.cc | 219 ++++++++++++++++++++
5 files changed, 391 insertions(+), 0 deletions(-)
create mode 100644 milena/sandbox/camille/.gitignore
create mode 100644 milena/sandbox/camille/Makefile
create mode 100644 milena/sandbox/camille/graph-line-gradient-closing.cc
create mode 100644 milena/sandbox/camille/graph-wst.cc
diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog
index 6fca8e7..448a251 100644
--- a/milena/sandbox/ChangeLog
+++ b/milena/sandbox/ChangeLog
@@ -1,3 +1,13 @@
+2009-02-10 Roland Levillain <roland(a)lrde.epita.fr>
+
+ Add programs for Camille Couprie.
+
+ * camille/: New directory.
+ * camille/graph-line-gradient-closing.cc,
+ * camille/graph-wst.cc: New.
+ * camille/Makefile: New.
+ * camille/.gitignore: New.
+
2009-02-10 Frederic Bour <bour(a)lrde.epita.fr>
[sandbox][bour] Leveling filter with test.
diff --git a/milena/sandbox/camille/.gitignore b/milena/sandbox/camille/.gitignore
new file mode 100644
index 0000000..299cd39
--- /dev/null
+++ b/milena/sandbox/camille/.gitignore
@@ -0,0 +1,4 @@
+/graph-line-gradient-closing
+/graph-wst
+/out.pgm
+/out.ppm
diff --git a/milena/sandbox/camille/Makefile b/milena/sandbox/camille/Makefile
new file mode 100644
index 0000000..a95fb63
--- /dev/null
+++ b/milena/sandbox/camille/Makefile
@@ -0,0 +1,9 @@
+CXXFLAGS = -ggdb -DNDEBUG -O2 -I../..
+
+all: graph-line-gradient-closing graph-wst
+
+test-graph-wst: graph-wst
+ ./graph-wst ../../img/small.pgm 20 out.ppm
+
+test-graph-line-gradient-closing: graph-line-gradient-closing
+ ./graph-line-gradient-closing ../../img/small.pgm 20 out.pgm
diff --git a/milena/sandbox/camille/graph-line-gradient-closing.cc b/milena/sandbox/camille/graph-line-gradient-closing.cc
new file mode 100644
index 0000000..a9eaa4e
--- /dev/null
+++ b/milena/sandbox/camille/graph-line-gradient-closing.cc
@@ -0,0 +1,149 @@
+// Copyright (C) 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.
+
+// FIXME: Update.
+/** \brief More tests on the Watershed Transform (WST) on a
+ mln::line_graph_image.
+
+ The scenario is as follows:
+ \li load a 2-D, gray-level image from a PGM file;
+ \li convert this 2-D image into a line graph-based one, where values
+ on edges are computed as the absolute value of the difference
+ between the values on the vertices adjacent to the edge, so as to
+ create a (norm of the) gradient ``between the pixels'' of the
+ input image;
+ \li reduce the number of minima using an area opening (counting the
+ vertices to compute the area, not the edges);
+ \li perform a WST on this simplified line graph image;
+ \li create a 2-D, color output image with height and width double
+ the size the original one, and copy the data of the input image
+ in it, interpolating inter-pixel points;
+ \li print the watershed on lines into that same image, and save it. */
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/point2d.hh>
+#include <mln/core/alias/window2d.hh>
+#include <mln/core/alias/neighb2d.hh>
+
+/// Required for line graph images.
+#include <mln/core/site_set/p_edges.hh>
+#include <mln/core/image/line_graph_elt_neighborhood.hh>
+#include <mln/core/var.hh>
+#include <mln/pw/all.hh>
+#include <mln/fun/i2v/array.hh>
+#include <mln/util/graph.hh>
+
+#include <mln/morpho/line_gradient.hh>
+#include <mln/morpho/closing_area_on_vertices.hh>
+#include <mln/morpho/meyer_wst.hh>
+#include <mln/level/stretch.hh>
+
+#include <mln/value/int_u8.hh>
+#include <mln/value/int_u16.hh>
+#include <mln/value/rgb8.hh>
+#include <mln/literal/black.hh>
+#include <mln/literal/colors.hh>
+
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+#include <mln/math/max.hh>
+#include <mln/math/abs.hh>
+
+
+int main(int argc, char* argv[])
+{
+ if (argc != 4)
+ {
+ std::cerr << "usage: " << argv[0] << " input.pgm lambda output.pgm"
+ << std::endl;
+ std::exit(1);
+ }
+ std::string input_filename = argv[1];
+ unsigned lambda = atoi(argv[2]);
+ std::string output_filename = argv[3];
+
+
+ using namespace mln;
+ using value::int_u8;
+ using value::int_u16;
+ using value::rgb8;
+
+ /*--------.
+ | Input. |
+ `--------*/
+
+ typedef int_u8 input_val_t;
+ image2d<input_val_t> input;
+ io::pgm::load(input, input_filename);
+
+ /*----------------.
+ | Line gradient. |
+ `----------------*/
+
+ // Line graph image.
+ mln_VAR(lg_ima, morpho::line_gradient(input));
+
+ /*-----------------.
+ | Simplification. |
+ `-----------------*/
+
+ typedef line_graph_elt_neighborhood<util::graph, lg_ima_t::pset::fun_t> nbh_t;
+ nbh_t nbh;
+
+ mln_VAR(closed_lg_ima, morpho::closing_area_on_vertices(lg_ima, nbh, lambda));
+
+ /*---------.
+ | Output. |
+ `---------*/
+
+ // FIXME: Inlined conversion, to be reifed into a routine.
+
+ // Data.
+ typedef int_u8 output_val_t;
+ typedef image2d<output_val_t> output_t;
+ point2d output_pmin = input.domain().pmin();
+ point2d output_pmax(input.domain().pmax()[0] * 2,
+ input.domain().pmax()[1] * 2);
+ output_t output(box2d(output_pmin, output_pmax));
+ data::fill(output, 0);
+ // Draw the filtered gradient.
+ mln_piter_(closed_lg_ima_t) p(closed_lg_ima.domain());
+ for_all(p)
+ {
+ mln_psite_(lg_ima_t) pp(p);
+ // Equivalent of the line (edge) PP in OUTPUT.
+ int row1 = pp.first()[0] * 2;
+ int col1 = pp.first()[1] * 2;
+ int row2 = pp.second()[0] * 2;
+ int col2 = pp.second()[1] * 2;
+ point2d q((row1 + row2) / 2, (col1 + col2) / 2);
+ // Print the watershed in red.
+ output(q) = closed_lg_ima(p);
+ }
+ io::pgm::save(output, output_filename);
+}
diff --git a/milena/sandbox/camille/graph-wst.cc b/milena/sandbox/camille/graph-wst.cc
new file mode 100644
index 0000000..aafdc85
--- /dev/null
+++ b/milena/sandbox/camille/graph-wst.cc
@@ -0,0 +1,219 @@
+// Copyright (C) 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.
+
+// FIXME: Update.
+/** \brief More tests on the Watershed Transform (WST) on a
+ mln::line_graph_image.
+
+ The scenario is as follows:
+ \li load a 2-D, gray-level image from a PGM file;
+ \li convert this 2-D image into a line graph-based one, where values
+ on edges are computed as the absolute value of the difference
+ between the values on the vertices adjacent to the edge, so as to
+ create a (norm of the) gradient ``between the pixels'' of the
+ input image;
+ \li reduce the number of minima using an area opening (counting the
+ vertices to compute the area, not the edges);
+ \li perform a WST on this simplified line graph image;
+ \li create a 2-D, color output image with height and width double
+ the size the original one, and copy the data of the input image
+ in it, interpolating inter-pixel points;
+ \li print the watershed on lines into that same image, and save it. */
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/point2d.hh>
+#include <mln/core/alias/window2d.hh>
+#include <mln/core/alias/neighb2d.hh>
+
+/// Required for line graph images.
+#include <mln/core/site_set/p_edges.hh>
+#include <mln/core/image/line_graph_elt_neighborhood.hh>
+#include <mln/core/var.hh>
+#include <mln/pw/all.hh>
+#include <mln/fun/i2v/array.hh>
+#include <mln/util/graph.hh>
+
+#include <mln/morpho/line_gradient.hh>
+#include <mln/morpho/closing_area_on_vertices.hh>
+#include <mln/morpho/meyer_wst.hh>
+#include <mln/level/stretch.hh>
+
+#include <mln/value/int_u8.hh>
+#include <mln/value/int_u16.hh>
+#include <mln/value/rgb8.hh>
+#include <mln/literal/black.hh>
+#include <mln/literal/colors.hh>
+
+#include <mln/io/pgm/load.hh>
+#include <mln/io/ppm/save.hh>
+
+#include <mln/math/max.hh>
+#include <mln/math/abs.hh>
+
+
+int main(int argc, char* argv[])
+{
+ if (argc != 4)
+ {
+ std::cerr << "usage: " << argv[0] << " input.pgm lambda output.ppm"
+ << std::endl;
+ std::exit(1);
+ }
+ std::string input_filename = argv[1];
+ unsigned lambda = atoi(argv[2]);
+ std::string output_filename = argv[3];
+
+
+ using namespace mln;
+ using value::int_u8;
+ using value::int_u16;
+ using value::rgb8;
+
+ /*--------.
+ | Input. |
+ `--------*/
+
+ typedef int_u8 input_val_t;
+ image2d<input_val_t> input;
+ io::pgm::load(input, input_filename);
+
+ /*----------------.
+ | Line gradient. |
+ `----------------*/
+
+ // Line graph image.
+ mln_VAR(lg_ima, morpho::line_gradient(input));
+
+ /*-----------------.
+ | Simplification. |
+ `-----------------*/
+
+ typedef line_graph_elt_neighborhood<util::graph, lg_ima_t::pset::fun_t> nbh_t;
+ nbh_t nbh;
+
+ mln_VAR(closed_lg_ima, morpho::closing_area_on_vertices(lg_ima, nbh, lambda));
+
+ /*------.
+ | WST. |
+ `------*/
+
+ // Perform a Watershed Transform.
+ unsigned nbasins;
+ mln_VAR(wshed, morpho::meyer_wst(closed_lg_ima, nbh, nbasins));
+ std::cout << "nbasins = " << nbasins << std::endl;
+
+ /*---------.
+ | Output. |
+ `---------*/
+
+ // FIXME: Inlined conversion, to be reifed into a routine.
+
+ // Save the result in gray levels (data) + color (wshed).
+
+ // Data.
+ typedef rgb8 output_val_t;
+ typedef image2d<output_val_t> output_t;
+ point2d output_pmin = input.domain().pmin();
+ point2d output_pmax(input.domain().pmax()[0] * 2,
+ input.domain().pmax()[1] * 2);
+ output_t output(box2d(output_pmin, output_pmax));
+ data::fill(output, literal::black);
+ mln_fwd_piter_(image2d<input_val_t>) p(input.domain());
+ for_all(p)
+ {
+ // Equivalent of P in OUTPUT.
+ point2d q(p[0] * 2, p[1] * 2);
+ input_val_t v = input(p);
+ /* FIXME: Use a conversion function from input_val_t to
+ output_val_t instead of an explicit construction. */
+ output(q) = output_val_t(v, v, v);
+ }
+ // Interpolate missing points in OUTPUT.
+ mln_piter_(output_t) p_out(output.domain());
+ for_all(p_out)
+ {
+ // Process points on even rows and odd columns
+ if (p_out[0] % 2 == 0 && p_out[1] % 2 == 1)
+ output(p_out) = (output(p_out + left) + output(p_out + right)) / 2;
+ // Process points on odd rows and even columns
+ if (p_out[0] % 2 == 1 && p_out[1] % 2 == 0)
+ output(p_out) = (output(p_out + up) + output(p_out + down)) / 2;
+ // Process points on odd rows and odd columns
+ if (p_out[0] % 2 == 1 && p_out[1] % 2 == 1)
+ output(p_out) =
+ (output(p_out + dpoint2d(-1, -1)) +
+ output(p_out + dpoint2d(-1, +1)) +
+ output(p_out + dpoint2d(+1, -1)) +
+ output(p_out + dpoint2d(+1, +1))) / 4;
+ }
+ // Draw the watershed.
+ /* FIXME: We should draw the watershed on another image and
+ superimpose it on OUTPUT instead of drawing it directly into
+ OUTPUT. */
+ mln_piter_(wshed_t) pw(wshed.domain());
+ for_all(pw)
+ {
+ if (wshed(pw) == 0)
+ {
+ mln_psite_(lg_ima_t) pp(pw);
+ // Equivalent of the line (edge) PP in OUTPUT.
+ int row1 = pp.first()[0] * 2;
+ int col1 = pp.first()[1] * 2;
+ int row2 = pp.second()[0] * 2;
+ int col2 = pp.second()[1] * 2;
+ point2d q((row1 + row2) / 2, (col1 + col2) / 2);
+ // Print the watershed in red.
+ output(q) = literal::red;
+ }
+ }
+ // Fill the holes, so that the watershed looks connected.
+ /* FIXME: This approach is bad: it creates thick lines of watershed.
+ We should probably solve this when we ``paint'' the watershed
+ over the ``doubled'' image.
+
+ A better approach is probably to iterate over the set of vertices,
+ and ``connect'' edges according to patterns (vertically or
+ horizontally connected egdes member of the watershed, etc.). */
+ // Reuse the piter on OUTPUT.
+ for_all (p_out)
+ // Only handle points on odd rows and columns.
+ if (p_out[0] % 2 == 1 && p_out[1] % 2 == 1)
+ {
+ // Count the number of adjacent watershed points. If there are
+ // two or more, consider, create a watershed point.
+ /* FIXME: Iterating over a c4 window would be more elegant, of
+ course. */
+ unsigned nwsheds =
+ (output.has(p_out + up ) && output(p_out + up ) == literal::red) +
+ (output.has(p_out + down ) && output(p_out + down ) == literal::red) +
+ (output.has(p_out + left ) && output(p_out + right) == literal::red) +
+ (output.has(p_out + right) && output(p_out + left ) == literal::red);
+ if (nwsheds >= 2)
+ output(p_out) = literal::red;
+ }
+ io::ppm::save(output, output_filename);
+}
--
1.6.1.2
1
0