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
* Makefile.am: Here.
* python/Makefile.am: Likewise.
(python_PYTHON): Move data.py...
(EXTRA_DIST): ...here.
---
swilena/ChangeLog | 9 +++++++++
swilena/Makefile.am | 3 ---
swilena/python/Makefile.am | 13 ++++++-------
3 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/swilena/ChangeLog b/swilena/ChangeLog
index efa4e9b..3232f15 100644
--- a/swilena/ChangeLog
+++ b/swilena/ChangeLog
@@ -1,3 +1,12 @@
+2009-10-27 Roland Levillain <roland(a)lrde.epita.fr>
+
+ Clean up Swilena Makefiles.
+
+ * Makefile.am: Here.
+ * python/Makefile.am: Likewise.
+ (python_PYTHON): Move data.py...
+ (EXTRA_DIST): ...here.
+
2009-09-12 Roland Levillain <roland(a)lrde.epita.fr>
* neighb2d.i: Aesthetic changes.
diff --git a/swilena/Makefile.am b/swilena/Makefile.am
index c6fd023..109fb2e 100644
--- a/swilena/Makefile.am
+++ b/swilena/Makefile.am
@@ -14,9 +14,6 @@
# You should have received a copy of the GNU General Public License
# along with Olena. If not, see <http://www.gnu.org/licenses/>.
-
-## Process this file through Automake to produce Makefile.in.
-
SUBDIRS = python
# Meta-wrappers (templates), not generating a module, but factoring
diff --git a/swilena/python/Makefile.am b/swilena/python/Makefile.am
index aec8a05..0ad96da 100644
--- a/swilena/python/Makefile.am
+++ b/swilena/python/Makefile.am
@@ -13,9 +13,7 @@
#
# You should have received a copy of the GNU General Public License
# along with Olena. If not, see <http://www.gnu.org/licenses/>.
-#
-## Process this file through Automake to produce Makefile.in.
## ------------------ ##
## Generic material. ##
@@ -28,11 +26,11 @@ AM_CPPFLAGS = -I$(PYTHONINC) -I$(top_srcdir)/milena
TOOLS_CXXFLAGS = @TOOLS_CXXFLAGS@
AM_CXXFLAGS = $(TOOLS_CXXFLAGS)
AM_SWIGFLAGS = -Wall -c++ -python -I$(top_srcdir)/milena
-## We build modules, not plain libs.
+# We build modules, not plain libs.
AM_LDFLAGS = -avoid-version -module -shared
-## Run Swig to create the C++ wrapper files, the Python interface
-## files, and the dependency Makefile snippets.
+# Run Swig to create the C++ wrapper files, the Python interface
+# files, and the dependency Makefile snippets.
%-wrap.cc %.py: $(top_srcdir)/swilena/%.i
if $(SWIG) $(AM_SWIGFLAGS) $(SWIGFLAGS) -MD -MF "$(DEPDIR)/$*-wrap.Tcc" -o $@ $<; then \
mv -f "$(DEPDIR)/$*-wrap.Tcc" "$(DEPDIR)/$*-wrap.Pcc";\
@@ -45,8 +43,9 @@ AM_LDFLAGS = -avoid-version -module -shared
python_PYTHON = ltihooks.py
# swilena.py: The whole Swilena suite.
python_PYTHON += swilena.py
+
# data.py: Access to the data of the distribution (images, meshes, etc.)
-python_PYTHON += data.py
+EXTRA_DIST = data.py
## ----------------- ##
@@ -218,7 +217,7 @@ $(TESTS): $(srcdir)/run.stamp
# The dependency is on `run.in' and not `run', since `run' is
# regenerated at distribution time, and voids the time stamps (which
# we don't want!).
-EXTRA_DIST = $(srcdir)/run.stamp
+EXTRA_DIST += $(srcdir)/run.stamp
$(srcdir)/run.stamp: $(RUN_IN)
@rm -f $@
@rm -f $@.tmp
--
1.5.6.5
1
0
10 Feb '10
* green/mln/display/display_histo.cc: Add new vizualisations.
* green/mln/display/project_histo.cc: Add new color projections.
---
milena/sandbox/ChangeLog | 7 +
milena/sandbox/green/mln/display/display_histo.hh | 75 ++++--
milena/sandbox/green/mln/display/project_histo.hh | 341 +++++++++++++--------
3 files changed, 279 insertions(+), 144 deletions(-)
diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog
index 097ea5c..d53313f 100644
--- a/milena/sandbox/ChangeLog
+++ b/milena/sandbox/ChangeLog
@@ -1,5 +1,12 @@
2010-02-10 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+ Fix bugs in the histogram visualization tools.
+
+ * green/mln/display/display_histo.cc: Add new vizualisations.
+ * green/mln/display/project_histo.cc: Add new color projections.
+
+2010-02-10 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+
Fix last details in the image processing chain.
* green/tools/annotating/histo/histo.cc: Manage new inputs/outputs.
diff --git a/milena/sandbox/green/mln/display/display_histo.hh b/milena/sandbox/green/mln/display/display_histo.hh
index 2ba0b61..ef47182 100644
--- a/milena/sandbox/green/mln/display/display_histo.hh
+++ b/milena/sandbox/green/mln/display/display_histo.hh
@@ -29,12 +29,14 @@
# define MLN_DISPLAY_DISPLAY_HISTO_HH
# include <mln/accu/math/sum.hh>
+# include <mln/algebra/vec.hh>
# include <mln/data/stretch.hh>
# include <mln/display/project_histo.hh>
# include <mln/fun/v2v/log.hh>
# include <mln/value/int_u8.hh>
# include <mln/value/rgb8.hh>
# include <mln/value/label_8.hh>
+# include <mln/util/array.hh>
/// \file
@@ -57,19 +59,28 @@ namespace mln
image2d<value::int_u8>
display_histo3d_unsigned(const image3d<unsigned>& histo);
- image2d<value::int_u8>
- display2_histo3d_unsigned(const image3d<unsigned>& histo);
+ template <unsigned n>
+ image2d< value::int_u<n> >
+ display2_histo3d_unsigned(const image3d<unsigned>& histo,
+ const value::int_u<n> ambiguous_color);
+ template <unsigned n>
image2d<value::label_8>
display2_histo3d_unsigned(const image3d<unsigned>& histo,
- const image3d<value::label_8>& label);
+ const image3d<value::label_8>& label,
+ const value::label_8 ambiguous_label);
- image2d<value::rgb8>
- display3_histo3d_unsigned(const image3d<unsigned>& histo);
+ template <unsigned n>
+ image2d< value::rgb<n> >
+ display3_histo3d_unsigned(const image3d<unsigned>& histo,
+ const value::rgb<n> ambiguous_color);
- image2d<value::rgb8>
- display3_histo3d_unsigned(const image3d<unsigned>& histo,
- const image3d<value::label_8>& label);
+ template <unsigned n>
+ image2d< value::rgb8 >
+ display3_histo3d_unsigned(const image3d<unsigned>& histo,
+ const image3d<value::label_8>& label,
+ const util::array< algebra::vec<3,float> >& pal,
+ const value::rgb8 ambiguous_color);
#ifndef MLN_INCLUDE_ONLY
@@ -87,7 +98,7 @@ namespace mln
/// \parameter[in] histo the histogram in 3d.
/// \result return a equivalent 2d image.
-
+ // FIXME : display_shape [in int_u8]
image2d<value::int_u8>
display_histo3d_unsigned(const image3d<unsigned>& histo)
{
@@ -102,40 +113,62 @@ namespace mln
return proj_int;
}
- image2d<value::int_u8>
- display2_histo3d_unsigned(const image3d<unsigned>& histo)
+ // FIXME : display_color [in int_un]
+ template <unsigned n>
+ image2d< value::int_u<n> >
+ display2_histo3d_unsigned(const image3d<unsigned>& histo,
+ const value::int_u<n> ambiguous_color)
{
- image2d<value::int_u8> proj = project2_histo<0>(histo);
+ image2d< value::int_u<n> > proj = project2_histo<n,0>(histo,
+ ambiguous_color);
return proj;
}
+ // FIXME : display_label [in label]
+ template <unsigned n>
image2d<value::label_8>
display2_histo3d_unsigned(const image3d<unsigned>& histo,
- const image3d<value::label_8>& label)
+ const image3d<value::label_8>& label,
+ const value::label_8 ambiguous_label)
{
- image2d<value::label_8> proj = project2_histo<0>(histo, label);
+ image2d<value::label_8> proj = project2_histo<n,0>(histo,
+ label,
+ ambiguous_label);
return proj;
}
- image2d<value::rgb8>
- display3_histo3d_unsigned(const image3d<unsigned>& histo)
+ // FIXME : display_color [in color]
+ template <unsigned n>
+ image2d< value::rgb<n> >
+ display3_histo3d_unsigned(const image3d<unsigned>& histo,
+ const value::rgb<n> ambiguous_color)
{
- image2d<value::rgb8> proj = project3_histo<0>(histo);
+ image2d< value::rgb<n> > proj = project3_histo<n,0>(histo,
+ ambiguous_color);
return proj;
}
- image2d<value::rgb8>
- display3_histo3d_unsigned(const image3d<unsigned>& histo,
- const image3d<value::label_8>& label)
+
+ // FIXME : display_label [in color]
+ template <unsigned n>
+ image2d< value::rgb8 >
+ display3_histo3d_unsigned(const image3d<unsigned>& histo,
+ const image3d<value::label_8>& label,
+ const util::array<algebra::vec<3,float> >& pal,
+ const value::rgb8 ambiguous_color)
{
- image2d<value::rgb8> proj = project3_histo<0>(histo, label);
+ image2d< value::rgb8 > proj = project3_histo<n,0>(histo,
+ label,
+ pal,
+ ambiguous_color);
return proj;
}
+
#endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/sandbox/green/mln/display/project_histo.hh b/milena/sandbox/green/mln/display/project_histo.hh
index d842c70..30bcd6d 100644
--- a/milena/sandbox/green/mln/display/project_histo.hh
+++ b/milena/sandbox/green/mln/display/project_histo.hh
@@ -37,12 +37,16 @@
# include <mln/accu/image/take.hh>
# include <mln/accu/image/to_result.hh>
+# include <mln/algebra/vec.hh>
+
# include <mln/opt/at.hh>
# include <mln/value/int_u8.hh>
# include <mln/value/rgb8.hh>
# include <mln/value/label_8.hh>
+# include <mln/util/array.hh>
+
/// \file
///
/// \brief Allow the visualization of 3d histogram.
@@ -60,9 +64,30 @@ namespace mln
image2d<mln_result(A)>
project_histo(const image3d<V>& histo);
- template <typename A, unsigned direction, typename V>
+ template <typename A, unsigned n, unsigned direction, typename V>
image2d<mln_result(A)>
- project2_histo(const image3d<V>& histo);
+ project2_histo(const image3d<V>& histo,
+ const value::int_u<n>& ambiguous_color);
+
+ template <unsigned n, unsigned direction, typename V>
+ image2d<V>
+ project2_histo(const image3d<unsigned>& histo,
+ const image3d<V>& label);
+
+ template <unsigned n, unsigned direction>
+ image2d< value::rgb<n> >
+ project3_histo(const image3d<unsigned>& histo,
+ const value::rgb<n> ambiguous_color);
+
+ template <unsigned n, unsigned direction>
+ image2d< value::rgb8 >
+ project3_histo(const image3d<unsigned>& histo,
+ const image3d<value::label_8>& label,
+ const util::array<algebra::vec<3, float> >& pal,
+ const value::rgb8 ambiguous_color);
+ // FIXME ==> palette must be 1d-image not an array !!
+
+
# ifndef MLN_INCLUDE_ONLY
@@ -96,80 +121,96 @@ namespace mln
return accu::image::to_result(histo_accu);
}
- template <unsigned direction>
- image2d<value::int_u8>
- project2_histo(const image3d<unsigned>& histo)
+ // 0 ==> blue
+ // 1 ==> red
+ // 2 ==> green
+
+ // mln::opt::at(histo, blue, red, green)
+
+ template <unsigned n, unsigned direction>
+ image2d< value::int_u<n> >
+ project2_histo(const image3d<unsigned>& histo,
+ const value::int_u<n>& ambiguous_color)
{
- image2d<value::int_u8> result;
+ image2d< value::int_u<n> > result;
if (0 == direction) // blue
{
- image2d<value::int_u8> arg_max(histo.ncols(), histo.nslices());
+ image2d< value::int_u<n> > arg_max(histo.nrows(), histo.ncols());
- for (unsigned j = 0; j < histo.ncols(); ++j)
- for (unsigned i = 0; i < histo.nslices(); ++i)
+ for (def::coord green = 0; green < (signed)histo.ncols(); ++green)
+ for (def::coord red = 0; red < (signed)histo.nrows(); ++red)
{
- unsigned max = 0; // minimum as possible
- signed pos = -1;
+ unsigned max = 0; // minimum as possible
+ def::coord pos = -1;
- for (unsigned k = 0; k < histo.nrows(); ++k)
+ for (def::coord blue = 0; blue < (signed)histo.nslices(); ++blue)
{
- if (max <= opt::at(histo,i,j,k))
+ if (max < opt::at(histo,blue,red,green))
{
- max = opt::at(histo,i,j,k);
- pos = k;
+ max = opt::at(histo,blue,red,green);
+ pos = blue;
}
}
- opt::at(arg_max,i,j) = pos;
+ if (-1 == pos)
+ opt::at(arg_max,red,green) = ambiguous_color;
+ else
+ opt::at(arg_max,red,green) = pos;
}
result = arg_max;
}
else if (1 == direction) // red
{
- image2d<value::int_u8> arg_max(histo.nrows(), histo.nslices());
+ image2d< value::int_u<n> > arg_max(histo.ncols(), histo.nslices());
- for (unsigned j = 0; j < histo.nslices(); ++j)
- for (unsigned i = 0; i < histo.nrows(); ++i)
+ for (def::coord blue = 0; blue < (signed)histo.nslices(); ++blue)
+ for (def::coord green = 0; green < (signed)histo.ncols(); ++green)
{
unsigned max = 0; // minimum as possible
signed pos = -1;
- for (unsigned k = 0; k < histo.ncols(); ++k)
+ for (def::coord red = 0; red < (signed)histo.nrows(); ++red)
{
- if (max <= opt::at(histo,i,j,k))
+ if (max < opt::at(histo,blue,red,green))
{
- max = opt::at(histo,i,j,k);
- pos = k;
+ max = opt::at(histo,blue,red,green);
+ pos = red;
}
}
- opt::at(arg_max,i,j) = pos;
+ if (-1 == pos)
+ opt::at(arg_max,green,blue) = ambiguous_color;
+ else
+ opt::at(arg_max,green,blue) = pos;
}
result = arg_max;
}
else // 2 == direction // green
{
- image2d<value::int_u8> arg_max(histo.nrows(), histo.ncols());
+ image2d< value::int_u<n> > arg_max(histo.nrows(), histo.nslices());
- for (unsigned j = 0; j < histo.ncols(); ++j)
- for (unsigned i = 0; i < histo.nrows(); ++i)
+ for (def::coord blue = 0; blue < (signed)histo.nslices(); ++blue)
+ for (def::coord red = 0; red < (signed)histo.nrows(); ++red)
{
unsigned max = 0; // minimum as possible
signed pos = -1;
- for (unsigned k = 0; k < histo.nslices(); ++k)
+ for (def::coord green = 0; green < (signed)histo.ncols(); ++green)
{
- if (max <= opt::at(histo,i,j,k))
+ if (max < opt::at(histo,blue,red,green))
{
- max = opt::at(histo,i,j,k);
- pos = k;
+ max = opt::at(histo,blue,red,green);
+ pos = green;
}
}
- opt::at(arg_max,i,j) = pos;
+ if (-1 == pos)
+ opt::at(arg_max,red,blue) = ambiguous_color;
+ else
+ opt::at(arg_max,red,blue) = pos;
}
result = arg_max;
@@ -178,81 +219,91 @@ namespace mln
return result;
}
- template <unsigned direction>
+ template <unsigned n, unsigned direction>
image2d<value::label_8>
project2_histo(const image3d<unsigned>& histo,
- const image3d<value::label_8>& label)
+ const image3d<value::label_8>& label,
+ const value::label_8 ambiguous_label)
{
image2d<value::label_8> result;
if (0 == direction) // blue
{
- image2d<value::label_8> arg_max(histo.ncols(), histo.nslices());
+ image2d<value::label_8> arg_max(histo.nrows(), histo.ncols());
- for (unsigned j = 0; j < histo.ncols(); ++j)
- for (unsigned i = 0; i < histo.nslices(); ++i)
+ for (def::coord green = 0; green < (signed)histo.ncols(); ++green)
+ for (def::coord red = 0; red < (signed)histo.nrows(); ++red)
{
- unsigned max = 0; // minimum as possible
- signed pos = -1;
+ unsigned max = 0; // minimum as possible
+ def::coord pos = -1;
- for (unsigned k = 0; k < histo.nrows(); ++k)
+ for (def::coord blue = 0; blue < (signed)histo.nslices(); ++blue)
{
- if (max <= opt::at(histo,i,j,k))
+ if (max < opt::at(histo,blue,red,green))
{
- max = opt::at(histo,i,j,k);
- pos = k;
+ max = opt::at(histo,blue,red,green);
+ pos = blue;
}
}
- opt::at(arg_max,i,j) = opt::at(label,i,j,pos);
+ if (-1 == pos)
+ opt::at(arg_max,red,green) = ambiguous_label;
+ else
+ opt::at(arg_max,red,green) = opt::at(label, pos, red, green);
}
result = arg_max;
}
else if (1 == direction) // red
{
- image2d<value::label_8> arg_max(histo.nrows(), histo.nslices());
+ image2d<value::label_8> arg_max(histo.ncols(), histo.nslices());
- for (unsigned j = 0; j < histo.nslices(); ++j)
- for (unsigned i = 0; i < histo.nrows(); ++i)
+ for (def::coord blue = 0; blue < (signed)histo.nslices(); ++blue)
+ for (def::coord green = 0; green < (signed)histo.ncols(); ++green)
{
unsigned max = 0; // minimum as possible
signed pos = -1;
- for (unsigned k = 0; k < histo.ncols(); ++k)
+ for (def::coord red = 0; red < (signed)histo.nrows(); ++red)
{
- if (max <= opt::at(histo,i,j,k))
+ if (max < opt::at(histo,blue,red,green))
{
- max = opt::at(histo,i,j,k);
- pos = k;
+ max = opt::at(histo,blue,red,green);
+ pos = red;
}
}
- opt::at(arg_max,i,j) = opt::at(label,pos,i,j);
+ if (-1 == pos)
+ opt::at(arg_max,green,blue) = ambiguous_label;
+ else
+ opt::at(arg_max,green,blue) = opt::at(label, blue, pos, green);
}
result = arg_max;
}
else // 2 == direction // green
{
- image2d<value::label_8> arg_max(histo.nrows(), histo.ncols());
+ image2d<value::label_8> arg_max(histo.nrows(), histo.nslices());
- for (unsigned j = 0; j < histo.ncols(); ++j)
- for (unsigned i = 0; i < histo.nrows(); ++i)
+ for (def::coord blue = 0; blue < (signed)histo.nslices(); ++blue)
+ for (def::coord red = 0; red < (signed)histo.nrows(); ++red)
{
unsigned max = 0; // minimum as possible
signed pos = -1;
- for (unsigned k = 0; k < histo.nslices(); ++k)
+ for (def::coord green = 0; green < (signed)histo.ncols(); ++green)
{
- if (max <= opt::at(histo,i,j,k))
+ if (max < opt::at(histo,blue,red,green))
{
- max = opt::at(histo,i,j,k);
- pos = k;
+ max = opt::at(histo,blue,red,green);
+ pos = green;
}
}
- opt::at(arg_max,i,j) = opt::at(label,i,pos,j);
+ if (-1 == pos)
+ opt::at(arg_max,red,blue) = ambiguous_label;
+ else
+ opt::at(arg_max,red,blue) = opt::at(label, blue, red, pos);
}
result = arg_max;
@@ -262,83 +313,117 @@ namespace mln
}
+
+
// FIXME ... determine the color of each class.
- template <unsigned direction>
- image2d<value::rgb8>
- project3_histo(const image3d<unsigned>& histo,
- const image3d<value::label_8>& label)
+ // FIXME la palette est supposée en 8 bits
+ template <unsigned n, unsigned direction>
+ image2d< value::rgb8 >
+ project3_histo(const image3d<unsigned>& histo,
+ const image3d<value::label_8>& label,
+ const util::array<algebra::vec<3,float> >& pal,
+ const value::rgb8 ambiguous_color)
{
- image2d<value::rgb8> result;
+ image2d< value::rgb8 > result;
if (0 == direction) // blue
{
- image2d<value::rgb8> arg_max(histo.ncols(), histo.nslices());
+ image2d< value::rgb8 > arg_max(histo.nrows(), histo.ncols());
- for (unsigned j = 0; j < histo.ncols(); ++j)
- for (unsigned i = 0; i < histo.nslices(); ++i)
+ for (def::coord green = 0; green < (signed)histo.ncols(); ++green)
+ for (def::coord red = 0; red < (signed)histo.nrows(); ++red)
{
- unsigned max = 0; // minimum as possible
- signed pos = -1;
+ unsigned max = 0; // minimum as possible
+ def::coord pos = -1;
- for (unsigned k = 0; k < histo.nrows(); ++k)
+ for (def::coord blue = 0; blue < (signed)histo.nslices(); ++blue)
{
- if (max <= opt::at(histo,i,j,k))
+ if (max < opt::at(histo,blue,red,green))
{
- max = opt::at(histo,i,j,k);
- pos = k;
+ max = opt::at(histo,blue,red,green);
+ pos = blue;
}
}
- opt::at(arg_max,i,j) = value::rgb8(i,j,pos);
+ if (-1 == pos)
+ opt::at(arg_max,red,green) = ambiguous_color;
+ else
+ {
+ value::int_u8 r = pal[opt::at(label,pos,red,green)][0];
+ value::int_u8 g = pal[opt::at(label,pos,red,green)][1];
+ value::int_u8 b = pal[opt::at(label,pos,red,green)][2];
+ value::rgb8 color(r,g,b);
+
+ opt::at(arg_max,red,green) = color;
+ }
}
result = arg_max;
}
else if (1 == direction) // red
{
- image2d<value::rgb8> arg_max(histo.nrows(), histo.nslices());
+ image2d< value::rgb8 > arg_max(histo.ncols(), histo.nslices());
- for (unsigned j = 0; j < histo.nslices(); ++j)
- for (unsigned i = 0; i < histo.nrows(); ++i)
+ for (def::coord blue = 0; blue < (signed)histo.nslices(); ++blue)
+ for (def::coord green = 0; green < (signed)histo.ncols(); ++green)
{
unsigned max = 0; // minimum as possible
signed pos = -1;
- for (unsigned k = 0; k < histo.ncols(); ++k)
+ for (def::coord red = 0; red < (signed)histo.nrows(); ++red)
{
- if (max <= opt::at(histo,i,j,k))
+ if (max < opt::at(histo,blue,red,green))
{
- max = opt::at(histo,i,j,k);
- pos = k;
+ max = opt::at(histo,blue,red,green);
+ pos = red;
}
}
- opt::at(arg_max,i,j) = value::rgb8(pos,i,j);
+ if (-1 == pos)
+ opt::at(arg_max,green,blue) = ambiguous_color;
+ else
+ {
+ value::int_u8 r = pal[opt::at(label,blue,pos,green)][0];
+ value::int_u8 g = pal[opt::at(label,blue,pos,green)][1];
+ value::int_u8 b = pal[opt::at(label,blue,pos,green)][2];
+ value::rgb8 color(r,g,b);
+
+ opt::at(arg_max,green,blue) = color;
+ }
}
result = arg_max;
}
else // 2 == direction // green
{
- image2d<value::rgb8> arg_max(histo.nrows(), histo.ncols());
+ image2d< value::rgb8 > arg_max(histo.nrows(), histo.nslices());
- for (unsigned j = 0; j < histo.ncols(); ++j)
- for (unsigned i = 0; i < histo.nrows(); ++i)
+ for (def::coord blue = 0; blue < (signed)histo.nslices(); ++blue)
+ for (def::coord red = 0; red < (signed)histo.nrows(); ++red)
{
unsigned max = 0; // minimum as possible
signed pos = -1;
- for (unsigned k = 0; k < histo.nslices(); ++k)
+ for (def::coord green = 0; green < (signed)histo.ncols(); ++green)
{
- if (max <= opt::at(histo,i,j,k))
+ if (max < opt::at(histo,blue,red,green))
{
- max = opt::at(histo,i,j,k);
- pos = k;
+ max = opt::at(histo,blue,red,green);
+ pos = green;
}
}
- // FIXME ... how to fix the n of rgb
- opt::at(arg_max,i,j) = value::rgb8(i,pos,j);
+ if (-1 == pos)
+ opt::at(arg_max,red,blue) = ambiguous_color;
+ else
+ {
+ value::int_u8 r = pal[opt::at(label,blue,red,pos)][0];
+ value::int_u8 g = pal[opt::at(label,blue,red,pos)][1];
+ value::int_u8 b = pal[opt::at(label,blue,red,pos)][2];
+ value::rgb8 color(r,g,b);
+
+ opt::at(arg_max,red,blue) = color;
+ }
}
result = arg_max;
@@ -347,81 +432,91 @@ namespace mln
return result;
}
- template <unsigned direction>
- image2d<value::rgb8>
- project3_histo(const image3d<unsigned>& histo)
+
+ template <unsigned n, unsigned direction>
+ image2d< value::rgb<n> >
+ project3_histo(const image3d<unsigned>& histo,
+ const value::rgb<n> ambiguous_color)
{
- image2d<value::rgb8> result;
+ image2d< value::rgb<n> > result;
if (0 == direction) // blue
{
- image2d<value::rgb8> arg_max(histo.ncols(), histo.nslices());
+ image2d< value::rgb<n> > arg_max(histo.nrows(), histo.ncols());
- for (unsigned j = 0; j < histo.ncols(); ++j)
- for (unsigned i = 0; i < histo.nslices(); ++i)
+ for (def::coord green = 0; green < (signed)histo.ncols(); ++green)
+ for (def::coord red = 0; red < (signed)histo.nrows(); ++red)
{
- unsigned max = 0; // minimum as possible
- signed pos = -1;
+ unsigned max = 0; // minimum as possible
+ def::coord pos = -1;
- for (unsigned k = 0; k < histo.nrows(); ++k)
+ for (def::coord blue = 0; blue < (signed)histo.nslices(); ++blue)
{
- if (max <= opt::at(histo,i,j,k))
+ if (max < opt::at(histo,blue,red,green))
{
- max = opt::at(histo,i,j,k);
- pos = k;
+ max = opt::at(histo,blue,red,green);
+ pos = blue;
}
}
- opt::at(arg_max,i,j) = value::rgb8(i,j,pos);
+ if (-1 == pos)
+ opt::at(arg_max,red,green) = ambiguous_color;
+ else
+ opt::at(arg_max,red,green) = value::rgb<n>(red,green,pos);
}
result = arg_max;
}
else if (1 == direction) // red
{
- image2d<value::rgb8> arg_max(histo.nrows(), histo.nslices());
+ image2d< value::rgb<n> > arg_max(histo.ncols(), histo.nslices());
- for (unsigned j = 0; j < histo.nslices(); ++j)
- for (unsigned i = 0; i < histo.nrows(); ++i)
+ for (def::coord blue = 0; blue < (signed)histo.nslices(); ++blue)
+ for (def::coord green = 0; green < (signed)histo.ncols(); ++green)
{
unsigned max = 0; // minimum as possible
signed pos = -1;
- for (unsigned k = 0; k < histo.ncols(); ++k)
+ for (def::coord red = 0; red < (signed)histo.nrows(); ++red)
{
- if (max <= opt::at(histo,i,j,k))
+ if (max < opt::at(histo,blue,red,green))
{
- max = opt::at(histo,i,j,k);
- pos = k;
+ max = opt::at(histo,blue,red,green);
+ pos = red;
}
}
- opt::at(arg_max,i,j) = value::rgb8(pos,i,j);
+ if (-1 == pos)
+ opt::at(arg_max,green,blue) = ambiguous_color;
+ else
+ opt::at(arg_max,green,blue) = value::rgb<n>(pos,green,blue);;
}
result = arg_max;
}
else // 2 == direction // green
{
- image2d<value::rgb8> arg_max(histo.nrows(), histo.ncols());
+ image2d< value::rgb<n> > arg_max(histo.nrows(), histo.nslices());
- for (unsigned j = 0; j < histo.ncols(); ++j)
- for (unsigned i = 0; i < histo.nrows(); ++i)
+ for (def::coord blue = 0; blue < (signed)histo.nslices(); ++blue)
+ for (def::coord red = 0; red < (signed)histo.nrows(); ++red)
{
unsigned max = 0; // minimum as possible
signed pos = -1;
- for (unsigned k = 0; k < histo.nslices(); ++k)
+ for (def::coord green = 0; green < (signed)histo.ncols(); ++green)
{
- if (max <= opt::at(histo,i,j,k))
+ if (max < opt::at(histo,blue,red,green))
{
- max = opt::at(histo,i,j,k);
- pos = k;
+ max = opt::at(histo,blue,red,green);
+ pos = green;
}
}
- // FIXME ... how to fix the n of rgb
- opt::at(arg_max,i,j) = value::rgb8(i,pos,j);
+ if (-1 == pos)
+ opt::at(arg_max,red,blue) = ambiguous_color;
+ else
+ opt::at(arg_max,red,blue) = value::rgb<n>(red,pos,blue);
}
result = arg_max;
--
1.5.6.5
1
0
10 Feb '10
* green/tools/annotating/histo/histo.cc: Manage new inputs/outputs.
* green/tools/annotating/opening/opening.cc: Manage new inputs/outputs.
* green/tools/annotating/iz/Makefile.am: New Makefile.
* green/tools/annotating/iz/iz.cc: New file.
* green/tools/annotating/regmax/regmax.cc: Manage new inputs/outputs.
---
milena/sandbox/ChangeLog | 10 +
.../sandbox/green/tools/annotating/histo/histo.cc | 84 +++--
.../tools/annotating/{histo => iz}/Makefile.am | 0
milena/sandbox/green/tools/annotating/iz/iz.cc | 373 ++++++++++++++++++++
.../green/tools/annotating/opening/opening.cc | 76 +++--
.../green/tools/annotating/regmax/regmax.cc | 253 ++++++++++++--
6 files changed, 714 insertions(+), 82 deletions(-)
copy milena/sandbox/green/tools/annotating/{histo => iz}/Makefile.am (100%)
create mode 100644 milena/sandbox/green/tools/annotating/iz/iz.cc
diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog
index b9d40cb..097ea5c 100644
--- a/milena/sandbox/ChangeLog
+++ b/milena/sandbox/ChangeLog
@@ -1,3 +1,13 @@
+2010-02-10 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+
+ Fix last details in the image processing chain.
+
+ * green/tools/annotating/histo/histo.cc: Manage new inputs/outputs.
+ * green/tools/annotating/opening/opening.cc: Manage new inputs/outputs.
+ * green/tools/annotating/iz/Makefile.am: New Makefile.
+ * green/tools/annotating/iz/iz.cc: New file.
+ * green/tools/annotating/regmax/regmax.cc: Manage new inputs/outputs.
+
2010-01-05 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
Extend the histogram visualization tools for new projection concept.
diff --git a/milena/sandbox/green/tools/annotating/histo/histo.cc b/milena/sandbox/green/tools/annotating/histo/histo.cc
index ab0b8af..8037e1a 100644
--- a/milena/sandbox/green/tools/annotating/histo/histo.cc
+++ b/milena/sandbox/green/tools/annotating/histo/histo.cc
@@ -16,14 +16,14 @@
#include <mln/fun/v2v/rgb8_to_rgbn.hh>
-#include <mln/io/dump/save.hh>
#include <mln/io/pbm/load.hh>
-#include <mln/io/pbm/save.hh>
-#include <mln/io/pgm/load.hh>
-#include <mln/io/pgm/save.hh>
#include <mln/io/ppm/load.hh>
+#include <mln/io/dump/save.hh>
+#include <mln/io/pgm/save.hh>
#include <mln/io/ppm/save.hh>
+#include <mln/literal/colors.hh>
+
#include <mln/opt/at.hh>
#include <mln/pw/value.hh>
@@ -33,15 +33,19 @@
template <unsigned n>
-void mk_histo(const std::string& input,
- const std::string& output,
- const std::string& histo,
- const std::string& mask)
+void mk_histo(const std::string& input, // in
+ const std::string& quant, // in
+ const std::string& histo, // out
+ const std::string& proj1, // out
+ const std::string& proj2, // out
+ const std::string& mask) // [in]
{
typedef mln::value::int_u8 t_int_u8;
+ typedef mln::value::int_u<n> t_int_un;
typedef mln::value::rgb8 t_rgb8;
typedef mln::value::rgb<n> t_rgbn;
typedef mln::image2d<t_int_u8> t_image2d_int_u8;
+ typedef mln::image2d<t_int_un> t_image2d_int_un;
typedef mln::image2d<t_rgb8> t_image2d_rgb8;
typedef mln::image2d<t_rgbn> t_image2d_rgbn;
typedef mln::image2d<bool> t_image2d_bool;
@@ -54,7 +58,9 @@ void mk_histo(const std::string& input,
t_image2d_rgbn i1_input; // input rgbn
t_image2d_bool m0_input; // mask input
t_histo3d h1_input; // histo input
- t_image2d_int_u8 p1_histo; // histo proj
+ t_image2d_int_u8 p1_histo1;// histo proj1
+ t_image2d_rgbn p1_histo2;// histo proj2
+ t_rgbn red(mln::literal::red);
mln::io::ppm::load(i0_input, input.c_str());
i1_input = mln::data::transform(i0_input, t_rgb8_to_rgbn());
@@ -72,9 +78,13 @@ void mk_histo(const std::string& input,
// END OF IMAGE PROCESSING CHAIN
// BEGIN DUMPING
- p1_histo = mln::display::display_histo3d_unsigned(h1_input);
+ p1_histo1 = mln::display::display_histo3d_unsigned(h1_input);
+ p1_histo2 = mln::display::display3_histo3d_unsigned(h1_input, red);
+
+ mln::io::ppm::save(i1_input, quant.c_str());
mln::io::dump::save(h1_input, histo.c_str());
- mln::io::pgm::save(p1_histo, output.c_str());
+ mln::io::pgm::save(p1_histo1, proj1.c_str());
+ mln::io::ppm::save(p1_histo2, proj2.c_str());
// END DUMPING
}
@@ -82,35 +92,47 @@ void mk_histo(const std::string& input,
void usage()
{
std::cout << std::endl;
- std::cout << "histo input.ppm q out.ppm histo.dump [msk.pbm]" << std::endl;
- std::cout << "where" << std::endl;
- std::cout << "input.ppm is the 8 bits color ppm image" << std::endl;
- std::cout << "q is the degree of quanification {2,3,4,5,6,7,8}" << std::endl;
- std::cout << "out.pgm is the r/g projection of the histogram" << std::endl;
- std::cout << "out.dump is the quantified color histogram" << std::endl;
- std::cout << "msk.pbm is the mask which select the pixels" << std::endl;
+ std::cout << "histo input.ppm q quant.ppm histo.dump proj.pgm"
+ << " proj.ppm [msk.pbm]" << std::endl;
+ std::cout << std::endl;
+ std::cout << "where :" << std::endl;
+ std::cout << "* [ in] input.ppm is the 8 bits color ppm image" << std::endl;
+ std::cout << "* [ in] q is the degree of quantification"
+ << " {2,3,4,5,6,7,8}" << std::endl;
+ std::cout << "* [out] quant.ppm is the q bits quantified input"
+ << " image" << std::endl;
+ std::cout << "* [out] histo.dump is the quantified color"
+ << " histogram" << std::endl;
+ std::cout << "* [out] proj.pgm is the r/g projection of the"
+ << " histogram (summing along the blue axe)" << std::endl;
+ std::cout << "* [out] proj.ppm is the r/g projection of the"
+ << " histogram with maxima plot on" << std::endl;
+ std::cout << "* [ in] msk.pbm is the mask which selects the"
+ << " pixels" << std::endl;
std::cout << std::endl;
}
int main(int argc, char* args[])
{
- if (5 == argc || 6 == argc)
+ if (7 == argc || 8 == argc)
{
- const std::string input(args[1]);
- const char q = args[2][0];
- const std::string output(args[3]);
- const std::string histo(args[4]);
- const std::string mask(6 == argc? args[5] : "");
+ const std::string input(args[1]); // in
+ const char q = args[2][0]; // in
+ const std::string quant(args[3]); // out
+ const std::string histo(args[4]); // out
+ const std::string proj1(args[5]); // out
+ const std::string proj2(args[6]); // out
+ const std::string mask(8 == argc? args[7] : ""); // [in]
switch(q)
{
- case '2': mk_histo<2>(input, output, histo, mask); break;
- case '3': mk_histo<3>(input, output, histo, mask); break;
- case '4': mk_histo<4>(input, output, histo, mask); break;
- case '5': mk_histo<5>(input, output, histo, mask); break;
- case '6': mk_histo<6>(input, output, histo, mask); break;
- case '7': mk_histo<7>(input, output, histo, mask); break;
- case '8': mk_histo<8>(input, output, histo, mask); break;
+ case '2': mk_histo<2>(input, quant, histo, proj1, proj2, mask); break;
+ case '3': mk_histo<3>(input, quant, histo, proj1, proj2, mask); break;
+ case '4': mk_histo<4>(input, quant, histo, proj1, proj2, mask); break;
+ case '5': mk_histo<5>(input, quant, histo, proj1, proj2, mask); break;
+ case '6': mk_histo<6>(input, quant, histo, proj1, proj2, mask); break;
+ case '7': mk_histo<7>(input, quant, histo, proj1, proj2, mask); break;
+ case '8': mk_histo<8>(input, quant, histo, proj1, proj2, mask); break;
default: usage(); break;
}
}
diff --git a/milena/sandbox/green/tools/annotating/histo/Makefile.am b/milena/sandbox/green/tools/annotating/iz/Makefile.am
similarity index 100%
copy from milena/sandbox/green/tools/annotating/histo/Makefile.am
copy to milena/sandbox/green/tools/annotating/iz/Makefile.am
diff --git a/milena/sandbox/green/tools/annotating/iz/iz.cc b/milena/sandbox/green/tools/annotating/iz/iz.cc
new file mode 100644
index 0000000..07e5dd9
--- /dev/null
+++ b/milena/sandbox/green/tools/annotating/iz/iz.cc
@@ -0,0 +1,373 @@
+// TOOLS ==> influence zone transformation
+
+#include <iostream>
+#include <fstream>
+#include <boost/format.hpp>
+
+#include <mln/accu/stat/histo3d_rgb.hh>
+
+#include <mln/core/macros.hh>
+#include <mln/core/alias/neighb3d.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/core/image/image3d.hh>
+
+#include <mln/data/compute.hh>
+
+#include <mln/display/display_histo.hh>
+
+#include <mln/io/dump/load.hh>
+#include <mln/io/dump/save.hh>
+#include <mln/io/ppm/load.hh>
+#include <mln/io/ppm/save.hh>
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+#include <mln/literal/colors.hh>
+
+#include <mln/labeling/compute.hh>
+#include <mln/labeling/mean_values.hh>
+
+#include <mln/transform/influence_zone_geodesic.hh>
+
+#include <mln/value/int_u8.hh>
+
+template <unsigned n>
+struct t_labeling_rgbn : mln::Function_v2v< t_labeling_rgbn<n> >
+{
+ typedef mln::value::rgb<n> t_rgbn;
+ typedef mln::value::label_8 t_lbl8;
+ typedef t_rgbn argument;
+ typedef t_lbl8 result;
+ typedef mln::image3d<t_lbl8> t_label;
+
+ const t_label& _label;
+
+ t_labeling_rgbn(const t_label& label) : _label(label) {}
+
+ result operator()(const argument& c) const
+ {
+ t_lbl8 tmp = mln::opt::at(_label, c.blue(), c.red(), c.green());
+
+ return tmp;
+ }
+};
+
+void compute_stats(const mln::image2d<mln::value::rgb8>& i_input_rgb8,
+ const mln::image2d<mln::value::label_8>& l_input_lbl8,
+ const mln::image3d<unsigned>& h_histo_rgbn,
+ const mln::image3d<mln::value::label_8>& l_histo_lbl8,
+ const mln::value::label_8& n_labels,
+ const std::string& log)
+{
+ typedef mln::algebra::vec<3,float> t_vec3f;
+ typedef mln::accu::math::sum<unsigned,unsigned> t_sum;
+ typedef mln::accu::stat::mean<t_vec3f,t_vec3f,t_vec3f> t_mean;
+ typedef mln::util::array<unsigned> t_count_array;
+ typedef mln::util::array<t_vec3f> t_mean_array;
+
+ mln::util::array<float> abs((unsigned)(n_labels)+1);
+ mln::util::array<float> rel((unsigned)(n_labels)+1);
+ unsigned nb = 0;
+
+ for (unsigned i = 0; i <= n_labels; ++i)
+ {
+ abs[i] = 0.0;
+ rel[i] = 0.0;
+ }
+
+ // COMPUTE THE SUM
+ t_count_array count = mln::labeling::compute(t_sum(),
+ h_histo_rgbn,
+ l_histo_lbl8,
+ n_labels);
+
+ // COMPUTE THE TOTAL
+ for (unsigned i = 0; i <= n_labels; ++i)
+ {
+ unsigned c = count[i];
+ nb += c;
+ }
+
+ // COMPUTE THE PERCENTAGES
+ for (unsigned i = 0; i <= n_labels; ++i)
+ if (0 < count[i])
+ {
+ abs[i] = ((float)count[i] / nb)*100.0;
+ rel[i] = ((float)count[i] / (nb - count[0]))*100.0;
+ }
+
+ // COMPUTE THE MEAN
+
+ t_mean_array mean = mln::labeling::compute(t_mean(),
+ i_input_rgb8,
+ l_input_lbl8,
+ n_labels);
+
+ // CORRECT 0 LABEL STATS
+ rel[0] = 0;
+ mean[0][0] = 255.0;
+ mean[0][1] = 255.0;
+ mean[0][2] = 0.0;
+
+ // PRINT STATS
+ std::ofstream log_stream(log.c_str());
+
+ for (unsigned i = 0; i <= n_labels; ++i)
+ {
+ const t_vec3f& mean_v = mean[i];
+
+ log_stream << boost::format("%2i|"
+ "r = %6.2f, g = %6.2f, b = %6.2f |"
+ "c = %7i, %%i = %5.2f, %%c = %5.2f")
+ % i
+ % mean_v[0]
+ % mean_v[1]
+ % mean_v[2]
+ % count[i]
+ % abs[i]
+ % rel[i]
+ << std::endl;
+ }
+
+ log_stream << std::endl << std::endl;
+ log_stream.flush();
+ log_stream.close();
+}
+
+bool expect(std::istream& stream, const std::string expected)
+{
+ bool result;
+ std::string got;
+
+ stream >> got;
+
+ result = (got == expected);
+
+ return result;
+}
+
+std::istream& operator>>(std::istream& stream,
+ mln::algebra::vec<3,float>& color)
+{
+ unsigned lbl;
+
+ stream >> lbl;
+ if (expect(stream, std::string("|")) &&
+ expect(stream, std::string("r")) &&
+ expect(stream, std::string("=")))
+ {
+ stream >> color[0];
+
+ if (expect(stream, std::string(",")) &&
+ expect(stream, std::string("g")) &&
+ expect(stream, std::string("=")))
+ {
+ stream >> color[1];
+
+ if (expect(stream, std::string(",")) &&
+ expect(stream, std::string("b")) &&
+ expect(stream, std::string("=")))
+ {
+ stream >> color[2];
+ }
+ }
+ }
+
+ return stream;
+}
+
+void load(mln::util::array< mln::algebra::vec<3,float> >& m2_label,
+ const char *colormap)
+{
+ typedef mln::algebra::vec<3,float> t_vec3f;
+ typedef mln::util::array<t_vec3f> t_mean_array;
+
+ std::ifstream stream(colormap);
+ std::string buffer;
+
+ getline(stream, buffer);
+
+ while (0 < buffer.size())
+ {
+ std::stringstream line(buffer);
+ t_vec3f mean_v;
+
+ line >> mean_v;
+
+ m2_label.append(mean_v);
+
+ getline(stream, buffer);
+ }
+
+ stream.close();
+}
+
+template<unsigned n>
+void mk_iz(const std::string& labeled, // in
+ const unsigned d, // in
+ const mln::neighb3d& nbh, // in
+ const std::string& input, // in
+ const std::string& quant, // in
+ const std::string& histo, // in
+ const std::string& colormap,// in
+ const std::string& iz, // out
+ const std::string& proj, // out
+ const std::string& mean, // out
+ const std::string& stats) // [out]
+{
+ typedef mln::value::int_u8 t_int_u8;
+ typedef mln::value::label_8 t_lbl8;
+ typedef mln::value::rgb8 t_rgb8;
+ typedef mln::value::rgb<n> t_rgbn;
+ typedef mln::algebra::vec<3,float> t_v3f;
+ typedef mln::image2d<t_int_u8> t_image2d_int_u8;
+ typedef mln::image2d<t_rgb8> t_image2d_rgb8;
+ typedef mln::image2d<t_rgbn> t_image2d_rgbn;
+ typedef mln::image2d<t_lbl8> t_image2d_lbl8;
+ typedef mln::image3d<unsigned> t_histo3d;
+ typedef mln::image3d<t_lbl8> t_image3d_lbl8;
+ typedef mln::accu::meta::stat::histo3d_rgb t_histo3d_fun;
+ typedef mln::accu::stat::mean<t_v3f,t_v3f,t_v3f> t_mean;
+ typedef mln::util::array<t_v3f> t_mean_array;
+
+ // START OF IMAGE PROCESSING CHAIN
+ t_image2d_rgb8 i0_input; // input img
+ t_image2d_rgbn i1_input; // quant img
+ t_histo3d h1_input; // histo input
+ t_histo3d h2_input; // histo input
+ t_image2d_int_u8 p1_histo; // histo proj
+ t_image2d_rgb8 p3_histo; // histo proj
+ t_image3d_lbl8 l2_histo; // label histo
+ t_image3d_lbl8 l3_histo; // iz label hist
+ t_mean_array m2_label; // colormap
+ t_mean_array m3_label; // colormap
+ t_image2d_lbl8 l3_input; // label input
+ t_image2d_rgb8 i3_mean; // reconstructed
+
+ t_lbl8 n_lbl; // nb labels
+ t_rgb8 red(mln::literal::red);
+
+ mln::io::dump::load(l2_histo, labeled.c_str());
+ mln::io::ppm::load(i0_input, input.c_str());
+ mln::io::ppm::load(i1_input, quant.c_str());
+ mln::io::dump::load(h1_input, histo.c_str());
+ load(m2_label, colormap.c_str());
+
+ if (0 == d)
+ {
+ l3_histo = mln::transform::influence_zone_geodesic(l2_histo, nbh);
+ }
+ else
+ {
+ l3_histo = mln::transform::influence_zone_geodesic(l2_histo, nbh, d);
+ }
+ // END OF IMAGE PROCESSING CHAIN
+
+ // BEGIN DUMPING
+
+ n_lbl = (t_lbl8)(m2_label.size()-1);
+
+ l3_input = mln::data::transform(i1_input, t_labeling_rgbn<n>(l3_histo));
+ i3_mean = mln::labeling::mean_values(i0_input, l3_input, n_lbl);
+ m3_label = mln::labeling::compute(t_mean(), i0_input, l3_input, n_lbl);
+
+ // CORRECT 0 LABEL STATS
+ m3_label[0][0] = 255.0;
+ m3_label[0][1] = 255.0;
+ m3_label[0][2] = 0.0;
+
+ p3_histo = mln::display::display3_histo3d_unsigned<n>(h1_input,
+ l3_histo,
+ m3_label,
+ red);
+ mln::io::dump::save(l3_input, iz.c_str());
+ mln::io::ppm::save(p3_histo, proj.c_str());
+ mln::io::ppm::save(i3_mean, mean.c_str());
+
+ if (0 < stats.size())
+ compute_stats(i0_input, l3_input, h1_input, l3_histo, n_lbl, stats);
+
+ // END DUMPING
+}
+
+
+void usage()
+{
+ std::cout << std::endl;
+ std::cout << "iz labeled.dump d nbh input.ppm q quant.ppm"
+ << " histo.dump colormap.txt iz.dump proj.ppm"
+ << " mean.ppm [stats.txt]" << std::endl;
+ std::cout << std::endl;
+ std::cout << "where :" << std::endl;
+ std::cout << "* [ in] labeled.dump is the labeled 3d histogram" << std::endl;
+ std::cout << "* [ in] d is the depth for the zone influence"
+ << " transformation (0 means infinite)" << std::endl;
+ std::cout << "* [ in] nbh is the 3d neighbourhood {6,18,26}" << std::endl;
+ std::cout << "* [ in] input.ppm is the 8 bits color ppm image" << std::endl;
+ std::cout << "* [ in] q is the degree of quantification"
+ << " {2,3,4,5,6,7,8}" << std::endl;
+ std::cout << "* [ in] quant.ppm is the q bits quantified input"
+ << " image" << std::endl;
+ std::cout << "* [ in] histo.dump is the quantified color"
+ << " histogram" << std::endl;
+ std::cout << "* [ in] colormap.txt is the colormap for labels" << std::endl;
+ std::cout << "* [out] iz.dump is the iz labeled 3d histogram" << std::endl;
+ std::cout << "* [out] proj.ppm is the r/g projection of the"
+ << " histogram with maxima label plot on" << std::endl;
+ std::cout << "* [out] mean.ppm is the mean reconstructed image" << std::endl;
+ std::cout << "* [out] stats.txt is the statistical label report"<< std::endl;
+ std::cout << std::endl;
+}
+
+int main(int argc, char* args[])
+{
+ if (12 == argc || 13 == argc)
+ {
+ const std::string labeled(args[1]); // in
+ const unsigned d = atoi(args[2]); // in
+ const char nbh = args[3][0]; // in
+ const std::string input(args[4]); // in
+ const char q = args[5][0]; // in
+ const std::string quant(args[6]); // in
+ const std::string histo(args[7]); // in
+ const std::string colormap(args[8]); // in
+ const std::string iz(args[9]); // out
+ const std::string proj(args[10]); // out
+ const std::string mean(args[11]); // out
+ const std::string stats(13 == argc? args[12] : ""); // [out]
+
+
+ mln::neighb3d neighbourhood;
+
+ switch (nbh)
+ {
+ case '6': neighbourhood = mln::c6(); break;
+ case '1': neighbourhood = mln::c18(); break;
+ case '2': neighbourhood = mln::c26(); break;
+ default: usage(); return 0; // force usage and quit
+ }
+
+ switch (q)
+ {
+ case '2' : mk_iz<2>(labeled,d,neighbourhood,input,quant,
+ histo,colormap,iz,proj,mean,stats);break;
+ case '3' : mk_iz<3>(labeled,d,neighbourhood,input,quant,
+ histo,colormap,iz,proj,mean,stats);break;
+ case '4' : mk_iz<4>(labeled,d,neighbourhood,input,quant,
+ histo,colormap,iz,proj,mean,stats);break;
+ case '5' : mk_iz<5>(labeled,d,neighbourhood,input,quant,
+ histo,colormap,iz,proj,mean,stats);break;
+ case '6' : mk_iz<6>(labeled,d,neighbourhood,input,quant,
+ histo,colormap,iz,proj,mean,stats);break;
+ case '7' : mk_iz<7>(labeled,d,neighbourhood,input,quant,
+ histo,colormap,iz,proj,mean,stats);break;
+ case '8' : mk_iz<8>(labeled,d,neighbourhood,input,quant,
+ histo,colormap,iz,proj,mean,stats);break;
+ default: usage(); break;
+ }
+ }
+ else
+ usage();
+
+ return 0;
+}
diff --git a/milena/sandbox/green/tools/annotating/opening/opening.cc b/milena/sandbox/green/tools/annotating/opening/opening.cc
index 3e1dbf2..cdd37fb 100644
--- a/milena/sandbox/green/tools/annotating/opening/opening.cc
+++ b/milena/sandbox/green/tools/annotating/opening/opening.cc
@@ -15,36 +15,47 @@
#include <mln/io/dump/load.hh>
#include <mln/io/dump/save.hh>
-#include <mln/io/pgm/load.hh>
+#include <mln/io/ppm/save.hh>
#include <mln/io/pgm/save.hh>
+#include <mln/literal/colors.hh>
+
#include <mln/morpho/opening/volume.hh>
+#include <mln/value/rgb.hh>
#include <mln/value/int_u8.hh>
-void mk_opening(const std::string& input,
- const unsigned min_vol,
- const std::string& output,
- const std::string& opened)
+template <unsigned n>
+void mk_opening(const std::string& histo, // in
+ const unsigned min_vol, // in
+ const std::string& opened, // out
+ const std::string& proj1, // out
+ const std::string& proj2) // out
{
typedef mln::value::int_u8 t_int_u8;
+ typedef mln::value::rgb<n> t_rgbn;
typedef mln::image2d<t_int_u8> t_image2d_int_u8;
+ typedef mln::image2d<t_rgbn> t_image2d_rgbn;
typedef mln::image3d<unsigned> t_histo3d;
typedef mln::accu::meta::stat::histo3d_rgb t_histo3d_fun;
// START OF IMAGE PROCESSING CHAIN
t_histo3d h1_input; // histo input
t_histo3d h2_input; // histo input
- t_image2d_int_u8 p1_histo; // histo proj
+ t_image2d_int_u8 p1_histo1;// histo proj1
+ t_image2d_rgbn p1_histo2;// histo proj2
+ t_rgbn red(mln::literal::red);
- mln::io::dump::load(h1_input, input.c_str());
+ mln::io::dump::load(h1_input, histo.c_str());
h2_input = mln::morpho::opening::volume(h1_input, mln::c6(), min_vol);
// END OF IMAGE PROCESSING CHAIN
// BEGIN DUMPING
- p1_histo = mln::display::display_histo3d_unsigned(h2_input);
+ p1_histo1 = mln::display::display_histo3d_unsigned(h2_input);
+ p1_histo2 = mln::display::display3_histo3d_unsigned(h2_input, red);
mln::io::dump::save(h2_input, opened.c_str());
- mln::io::pgm::save(p1_histo, output.c_str());
+ mln::io::pgm::save(p1_histo1, proj1.c_str());
+ mln::io::ppm::save(p1_histo2, proj2.c_str());
// END DUMPING
}
@@ -52,25 +63,46 @@ void mk_opening(const std::string& input,
void usage()
{
std::cout << std::endl;
- std::cout << "opening input.dump v out.dump out.ppm" << std::endl;
- std::cout << "where" << std::endl;
- std::cout << "input.dump is the 3d color input histo" << std::endl;
- std::cout << "v is the minimum size of each composant" << std::endl;
- std::cout << "out.pgm is the r/g proj of the opened histogram" << std::endl;
- std::cout << "out.dump is the opened histogram" << std::endl;
+ std::cout << "opening q histo.dump v opened.dump proj.pgm"
+ << " proj.ppm" << std::endl;
+ std::cout << std::endl;
+ std::cout << "where :" << std::endl;
+ std::cout << "* [ in] q is the degree of quantification"
+ << " {2,3,4,5,6,7,8}" << std::endl;
+ std::cout << "* [ in] histo.dump is the quantified color"
+ << " histogram" << std::endl;
+ std::cout << "* [ in] v is the minimum size (in pixels) of"
+ << " each composant" << std::endl;
+ std::cout << "* [out] opened.dump is the filtered histogram" << std::endl;
+ std::cout << "* [out] proj.pgm is the r/g projection of the"
+ << " histogram (summing along the blue axe)" << std::endl;
+ std::cout << "* [out] proj.ppm is the r/g projection of the"
+ << " histogram with maxima plot on" << std::endl;
std::cout << std::endl;
}
int main(int argc, char* args[])
{
- if (5 == argc)
+ if (7 == argc)
{
- const std::string input(args[1]);
- const unsigned min_vol = atoi(args[2]);
- const std::string output(args[3]);
- const std::string opened(args[4]);
-
- mk_opening(input, min_vol, output, opened);
+ const char q = args[1][0]; // in
+ const std::string histo(args[2]); // in
+ const unsigned min_vol = atoi(args[3]); // in
+ const std::string opened(args[4]); // out
+ const std::string proj1(args[5]); // out
+ const std::string proj2(args[6]); // out
+
+ switch(q)
+ {
+ case '2': mk_opening<2>(histo, min_vol, opened, proj1, proj2); break;
+ case '3': mk_opening<3>(histo, min_vol, opened, proj1, proj2); break;
+ case '4': mk_opening<4>(histo, min_vol, opened, proj1, proj2); break;
+ case '5': mk_opening<5>(histo, min_vol, opened, proj1, proj2); break;
+ case '6': mk_opening<6>(histo, min_vol, opened, proj1, proj2); break;
+ case '7': mk_opening<7>(histo, min_vol, opened, proj1, proj2); break;
+ case '8': mk_opening<8>(histo, min_vol, opened, proj1, proj2); break;
+ default: usage(); break;
+ }
}
else
usage();
diff --git a/milena/sandbox/green/tools/annotating/regmax/regmax.cc b/milena/sandbox/green/tools/annotating/regmax/regmax.cc
index 2079bc4..0ff4d2e 100644
--- a/milena/sandbox/green/tools/annotating/regmax/regmax.cc
+++ b/milena/sandbox/green/tools/annotating/regmax/regmax.cc
@@ -1,8 +1,13 @@
// TOOLS ==> regmax on histo
#include <iostream>
+#include <fstream>
+#include <boost/format.hpp>
#include <mln/accu/stat/histo3d_rgb.hh>
+#include <mln/accu/stat/mean.hh>
+
+#include <mln/algebra/vec.hh>
#include <mln/core/macros.hh>
#include <mln/core/alias/neighb3d.hh>
@@ -18,9 +23,14 @@
#include <mln/io/dump/save.hh>
#include <mln/io/pgm/load.hh>
#include <mln/io/pgm/save.hh>
+#include <mln/io/ppm/load.hh>
#include <mln/io/ppm/save.hh>
#include <mln/labeling/regional_maxima.hh>
+#include <mln/labeling/compute.hh>
+#include <mln/labeling/mean_values.hh>
+
+#include <mln/literal/colors.hh>
#include <mln/morpho/opening/volume.hh>
@@ -28,6 +38,8 @@
#include <mln/value/int_u8.hh>
#include <mln/value/rgb8.hh>
+#include <mln/util/array.hh>
+
template <unsigned n>
struct t_labeling_rgbn : mln::Function_v2v< t_labeling_rgbn<n> >
{
@@ -49,19 +61,134 @@ struct t_labeling_rgbn : mln::Function_v2v< t_labeling_rgbn<n> >
}
};
-void mk_regmax(const std::string& input,
- const std::string& quant,
- const std::string& histo,
- const std::string& label,
- const std::string& output)
+void compute_stats(const mln::image2d<mln::value::rgb8>& i_input_rgb8,
+ const mln::image2d<mln::value::label_8>& l_input_lbl8,
+ const mln::image3d<unsigned>& h_histo_rgbn,
+ const mln::image3d<mln::value::label_8>& l_histo_lbl8,
+ const mln::value::label_8& n_labels,
+ const std::string& log)
+{
+ typedef mln::algebra::vec<3,float> t_vec3f;
+ typedef mln::accu::math::sum<unsigned,unsigned> t_sum;
+ typedef mln::accu::stat::mean<t_vec3f,t_vec3f,t_vec3f> t_mean;
+ typedef mln::util::array<unsigned> t_count_array;
+ typedef mln::util::array<t_vec3f> t_mean_array;
+
+ mln::util::array<float> abs((unsigned)(n_labels)+1);
+ mln::util::array<float> rel((unsigned)(n_labels)+1);
+ unsigned nb = 0;
+
+ for (unsigned i = 0; i <= n_labels; ++i)
+ {
+ abs[i] = 0.0;
+ rel[i] = 0.0;
+ }
+
+ // COMPUTE THE SUM
+ t_count_array count = mln::labeling::compute(t_sum(),
+ h_histo_rgbn,
+ l_histo_lbl8,
+ n_labels);
+
+ // COMPUTE THE TOTAL
+ for (unsigned i = 0; i <= n_labels; ++i)
+ {
+ unsigned c = count[i];
+ nb += c;
+ }
+
+ // COMPUTE THE PERCENTAGES
+ for (unsigned i = 0; i <= n_labels; ++i)
+ if (0 < count[i])
+ {
+ abs[i] = ((float)count[i] / nb)*100.0;
+ rel[i] = ((float)count[i] / (nb - count[0]))*100.0;
+ }
+
+ // COMPUTE THE MEAN
+
+ t_mean_array mean = mln::labeling::compute(t_mean(),
+ i_input_rgb8,
+ l_input_lbl8,
+ n_labels);
+
+ // CORRECT 0 LABEL STATS
+ rel[0] = 0;
+ mean[0][0] = 255.0;
+ mean[0][1] = 255.0;
+ mean[0][2] = 0.0;
+
+ // PRINT STATS
+ std::ofstream log_stream(log.c_str());
+
+ for (unsigned i = 0; i <= n_labels; ++i)
+ {
+ const t_vec3f& mean_v = mean[i];
+
+ log_stream << boost::format("%2i|"
+ "r = %6.2f, g = %6.2f, b = %6.2f |"
+ "c = %7i, %%i = %5.2f, %%c = %5.2f")
+ % i
+ % mean_v[0]
+ % mean_v[1]
+ % mean_v[2]
+ % count[i]
+ % abs[i]
+ % rel[i]
+ << std::endl;
+ }
+
+ log_stream << std::endl << std::endl;
+ log_stream.flush();
+ log_stream.close();
+}
+
+void save(mln::util::array< mln::algebra::vec<3,float> >& m2_label,
+ const char *colormap)
+{
+ typedef mln::algebra::vec<3,float> t_vec3f;
+ typedef mln::util::array<t_vec3f> t_mean_array;
+
+ std::ofstream stream(colormap);
+
+ for (unsigned i = 0; i < m2_label.size(); ++i)
+ {
+ const t_vec3f& mean_v = m2_label[i];
+
+ stream << boost::format("%2i | r = %6.2f, g = %6.2f, b = %6.2f")
+ % i
+ % mean_v[0]
+ % mean_v[1]
+ % mean_v[2]
+ << std::endl;
+ }
+
+ stream.flush();
+ stream.close();
+}
+
+template <unsigned n>
+void mk_regmax(const std::string& input, // in
+ const std::string& quant, // in
+ const std::string& histo, // in
+ const std::string& opened, // in
+ const mln::neighb3d& nbh, // in
+ const std::string& labeled, // out
+ const std::string& proj, // out
+ const std::string& colormap,// out
+ const std::string& mean, // out
+ const std::string& stats) // [out]
{
typedef mln::value::label_8 t_lbl8;
typedef mln::value::rgb8 t_rgb8;
- typedef mln::value::rgbn t_rgbn;
+ typedef mln::value::rgb<n> t_rgbn;
typedef mln::value::int_u8 t_int_u8;
+ typedef mln::value::int_u<n> t_int_un;
typedef mln::algebra::vec<3,float> t_v3f;
typedef mln::image2d<t_int_u8> t_image2d_int_u8;
+ typedef mln::image2d<t_int_un> t_image2d_int_un;
typedef mln::image2d<t_rgb8> t_image2d_rgb8;
+ typedef mln::image2d<t_rgbn> t_image2d_rgbn;
typedef mln::image3d<t_lbl8> t_image3d_lbl8;
typedef mln::image2d<t_lbl8> t_image2d_lbl8;
typedef mln::image3d<unsigned> t_histo3d;
@@ -71,60 +198,128 @@ void mk_regmax(const std::string& input,
t_image2d_rgb8 i0_input; // input img
t_image2d_rgbn i1_input; // quant img
+ t_histo3d h1_input; // input histo
t_histo3d h2_input; // opened histo
-// t_image2d_int_u8 p2_label; // histo proj
- t_image2d_lbl8 p2_label; // histo proj
-// t_image2d_rgb8 p2_label; // histo proj
+ t_image2d_rgb8 p2_label; // histo proj
t_image3d_lbl8 l2_histo; // label histo
- t_mean_array m2_label; // palette
+ t_image2d_lbl8 l2_input; // label input
+ t_mean_array m2_label; // colormap
+ t_image2d_rgb8 i2_mean; // reconstructed
t_lbl8 n_lbl; // nb class
+ t_rgb8 red(mln::literal::red);
+
// BEGIN LOADING
mln::io::ppm::load(i0_input, input.c_str());
mln::io::ppm::load(i1_input, quant.c_str());
- mln::io::dump::load(h2_input, histo.c_str());
+ mln::io::dump::load(h1_input, histo.c_str());
+ mln::io::dump::load(h2_input, opened.c_str());
// END LOADING
// BEGIN IMAGE PROCESSING
- l2_histo = mln::labeling::regional_maxima(h2_input, mln::c6(), n_lbl);
+ l2_histo = mln::labeling::regional_maxima(h2_input, nbh, n_lbl);
// END IMAGE PROCESSING
// BEGIN SAVING
- mln::debug::println(h2_input);
mln::io::dump::save(l2_histo, labeled.c_str());
l2_input = mln::data::transform(i1_input, t_labeling_rgbn<n>(l2_histo));
- m2_label = mln::labeling::compute(t_mean(), i0_input, l2_input, n_labels);
- p2_label =mln::display::display3_histo3d_unsigned(h2_input,l2_histo,m2_label);
+ i2_mean = mln::labeling::mean_values(i0_input, l2_input, n_lbl);
+ m2_label = mln::labeling::compute(t_mean(), i0_input, l2_input, n_lbl);
+
+ // CORRECT 0 LABEL STATS
+ m2_label[0][0] = 255.0;
+ m2_label[0][1] = 255.0;
+ m2_label[0][2] = 0.0;
+
+ p2_label =mln::display::display3_histo3d_unsigned<n>(h1_input,
+ l2_histo,
+ m2_label,
+ red);
+
+ mln::io::ppm::save(p2_label, proj.c_str());
+ save(m2_label, colormap.c_str());
+ mln::io::ppm::save(i2_mean, mean.c_str());
+
+ if (0 < stats.size())
+ compute_stats(i0_input, l2_input, h1_input, l2_histo, n_lbl, stats);
-// mln::io::pgm::save(p2_label, output.c_str());
- mln::io::ppm::save(p2_label, output.c_str());
- std::cout << "Nb classes : " << n_lbl << std::endl;
// END SAVING
}
-
void usage()
{
std::cout << std::endl;
- std::cout << "regmax input.dump out.dump out.ppm" << std::endl;
- std::cout << "where" << std::endl;
- std::cout << "input.dump is opened histo" << std::endl;
- std::cout << "out.pgm is the r/g proj of the opened histogram" << std::endl;
- std::cout << "out.dump is the labeled histogram" << std::endl;
+ std::cout << "regmax input.ppm q quant.ppm histo.dump"
+ << " opened.dump nbh labeled.dump proj.ppm"
+ << " colormap.txt mean.ppm [stats.txt]" << std::endl;
+ std::cout << std::endl;
+ std::cout << "where :" << std::endl;
+ std::cout << "* [ in] input.ppm is the 8 bits color ppm image" << std::endl;
+ std::cout << "* [ in] q is the degree of quantification"
+ << " {2,3,4,5,6,7,8}" << std::endl;
+ std::cout << "* [ in] quant.ppm is the q bits quantified input"
+ << " image" << std::endl;
+ std::cout << "* [ in] histo.dump is the quantified color"
+ << " histogram" << std::endl;
+ std::cout << "* [ in] opened.dump is the filtered histogram" << std::endl;
+ std::cout << "* [ in] nbh is the 3d neighbourhood {6,18,26}" << std::endl;
+ std::cout << "* [out] labeled.dump is the labeled 3d histogram" << std::endl;
+ std::cout << "* [out] proj.ppm is the r/g projection of the"
+ << " histogram with maxima label plot on" << std::endl;
+ std::cout << "* [out] colormap.txt is the colormap for labels" << std::endl;
+ std::cout << "* [out] mean.ppm is the mean reconstructed image" << std::endl;
+ std::cout << "* [out] stats.txt is the statistical label report"<< std::endl;
std::cout << std::endl;
}
int main(int argc, char* args[])
{
- if (4 == argc)
+ if (11 == argc || 12 == argc)
{
- const std::string input(args[1]);
- const std::string output(args[2]);
- const std::string labeled(args[3]);
+ const std::string input(args[1]); // in
+ const char q = args[2][0]; // in
+ const std::string quant(args[3]); // in
+ const std::string histo(args[4]); // in
+ const std::string opened(args[5]); // in
+ const char nbh = args[6][0]; // in
+ const std::string labeled(args[7]); // out
+ const std::string proj(args[8]); // out
+ const std::string colormap(args[9]);// out
+ const std::string mean(args[10]); // out
+ const std::string stats(12 == argc? args[11] : ""); // [out]
+
+
+ mln::neighb3d neighbourhood;
+
+ switch (nbh)
+ {
+ case '6': neighbourhood = mln::c6(); break;
+ case '1': neighbourhood = mln::c18(); break;
+ case '2': neighbourhood = mln::c26(); break;
+ default: usage(); return 0; // force usage and quit
+ }
+
+ switch (q)
+ {
- mk_regmax(input, output, labeled);
+ case '2': mk_regmax<2>(input,quant,histo,opened,neighbourhood,
+ labeled,proj,colormap,mean,stats); break;
+ case '3': mk_regmax<3>(input,quant,histo,opened,neighbourhood,
+ labeled,proj,colormap,mean,stats); break;
+ case '4': mk_regmax<4>(input,quant,histo,opened,neighbourhood,
+ labeled,proj,colormap,mean,stats); break;
+ case '5': mk_regmax<5>(input,quant,histo,opened,neighbourhood,
+ labeled,proj,colormap,mean,stats); break;
+ case '6': mk_regmax<6>(input,quant,histo,opened,neighbourhood,
+ labeled,proj,colormap,mean,stats); break;
+ case '7': mk_regmax<7>(input,quant,histo,opened,neighbourhood,
+ labeled,proj,colormap,mean,stats); break;
+ case '8': mk_regmax<8>(input,quant,histo,opened,neighbourhood,
+ labeled,proj,colormap,mean,stats); break;
+ default: usage(); break;
+ }
}
else
usage();
--
1.5.6.5
1
0
last-svn-commit-9-g4ecf262 Add a Swilena wrapper for mln::image2d<mln::value::rgb8>.
by Roland Levillain 08 Feb '10
by Roland Levillain 08 Feb '10
08 Feb '10
* image2d_rgb8.i: New file.
* Makefile.am (wrappers): Add image2d_rgb8.i.
* python/swilena.py: Import the contents of module image2d_rgb8.
* python/Makefile.am (pyexec_LTLIBRARIES): Add _image2d_rgb8.la.
(nodist__image2d_rgb8_la_SOURCES, _image2d_rgb8_la_LIBADD): New.
(CLEANFILES): Add $(nodist__image2d_rgb8_la_SOURCES)
image2d_rgb8.py image2d_rgb8.py[co].
(nodist_python_PYTHON): Add image2d_rgb8.py.
(image2d_rgb8-wrap.cc): Add dependencies.
---
swilena/ChangeLog | 14 +++++++++++
swilena/Makefile.am | 1 +
swilena/{image2d_int.i => image2d_rgb8.i} | 36 +++++++++++++++++++---------
swilena/python/Makefile.am | 15 ++++++++++++
swilena/python/swilena.py | 1 +
5 files changed, 55 insertions(+), 12 deletions(-)
copy swilena/{image2d_int.i => image2d_rgb8.i} (62%)
diff --git a/swilena/ChangeLog b/swilena/ChangeLog
index 605c3d5..fb854f5 100644
--- a/swilena/ChangeLog
+++ b/swilena/ChangeLog
@@ -1,5 +1,19 @@
2010-02-08 Roland Levillain <roland(a)lrde.epita.fr>
+ Add a Swilena wrapper for mln::image2d<mln::value::rgb8>.
+
+ * image2d_rgb8.i: New file.
+ * Makefile.am (wrappers): Add image2d_rgb8.i.
+ * python/swilena.py: Import the contents of module image2d_rgb8.
+ * python/Makefile.am (pyexec_LTLIBRARIES): Add _image2d_rgb8.la.
+ (nodist__image2d_rgb8_la_SOURCES, _image2d_rgb8_la_LIBADD): New.
+ (CLEANFILES): Add $(nodist__image2d_rgb8_la_SOURCES)
+ image2d_rgb8.py image2d_rgb8.py[co].
+ (nodist_python_PYTHON): Add image2d_rgb8.py.
+ (image2d_rgb8-wrap.cc): Add dependencies.
+
+2010-02-08 Roland Levillain <roland(a)lrde.epita.fr>
+
Add a Swilena meta-wrapper for PPM I/O.
* ppm.ixx: New file.
diff --git a/swilena/Makefile.am b/swilena/Makefile.am
index 7e84230..f484707 100644
--- a/swilena/Makefile.am
+++ b/swilena/Makefile.am
@@ -45,6 +45,7 @@ wrappers = \
dpoint2d.i \
image2d_int.i \
image2d_int_u8.i \
+ image2d_rgb8.i \
int_u32.i \
int_u8.i \
neighb2d.i \
diff --git a/swilena/image2d_int.i b/swilena/image2d_rgb8.i
similarity index 62%
copy from swilena/image2d_int.i
copy to swilena/image2d_rgb8.i
index ac82fe6..bda1ff9 100644
--- a/swilena/image2d_int.i
+++ b/swilena/image2d_rgb8.i
@@ -1,5 +1,6 @@
-// -*- C++ -*-
-// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// -*- C++ -*-
+// Copyright (C) 2008, 2009, 2010 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -25,20 +26,29 @@
// executable file might be covered by the GNU General Public License.
/// \file image2d.i
-/// \brief A simple wrapping of mln::image2d<int> along with some
-/// algorithms.
+/// \brief A simple wrapping of mln::image2d<mln::value::rgb8> along
+/// with some algorithms.
-%module image2d_int
+%module image2d_rgb8
+
+%import "rgb8.i"
+// FIXME: The import directive does not include the `%{ ... %}' clauses.
+%{
+#include "mln/value/rgb8.hh"
+%}
-%include "intp.ixx"
%include "image2d.ixx"
-instantiate_image2d(image2d_int, int)
+instantiate_image2d(image2d_rgb8, mln::value::rgb<8>)
+
+%include "ppm.ixx"
+%template(load) mln::io::ppm::load< mln::value::rgb<8> >;
+%template(save) mln::io::ppm::save< mln::image2d< mln::value::rgb<8> > >;
%include "fill.ixx"
-%template(fill) mln::data::fill< mln::image2d<int> >;
+%template(fill) mln::data::fill< mln::image2d< mln::value::rgb<8> > >;
%include "println.ixx"
-%template(println) mln::debug::println< mln::image2d<int> >;
+%template(println) mln::debug::println< mln::image2d< mln::value::rgb<8> > >;
%import "window2d.i"
// FIXME: The import directive does not include the `%{ ... %}' clauses.
@@ -46,6 +56,8 @@ instantiate_image2d(image2d_int, int)
#include "mln/core/alias/window2d.hh"
%}
-%include "morpho.ixx"
-instantiate_erosion(erosion, mln::image2d<int>, mln::window2d)
-instantiate_dilation(dilation, mln::image2d<int>, mln::window2d)
+%import "neighb2d.i"
+// FIXME: The import directive does not include the `%{ ... %}' clauses.
+%{
+#include "mln/core/alias/neighb2d.hh"
+%}
diff --git a/swilena/python/Makefile.am b/swilena/python/Makefile.am
index 13b17cc..44b9210 100644
--- a/swilena/python/Makefile.am
+++ b/swilena/python/Makefile.am
@@ -184,6 +184,16 @@ CLEANFILES += $(nodist__image2d_int_u8_la_SOURCES) image2d_int_u8.py image2d_int
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/_image2d_int_u8-wrap.Pcc@am__quote@
nodist_python_PYTHON += image2d_int_u8.py
+## image2d_rgb8.
+pyexec_LTLIBRARIES += _image2d_rgb8.la
+nodist__image2d_rgb8_la_SOURCES = image2d_rgb8-wrap.cc
+_image2d_rgb8_la_LIBADD = $(AM_LIBADD)
+CLEANFILES += $(nodist__image2d_rgb8_la_SOURCES) image2d_rgb8.py image2d_rgb8.py[co]
+## Include the dependency files. Copied from Automake's generated
+## case for C++.
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/_image2d_rgb8-wrap.Pcc@am__quote@
+nodist_python_PYTHON += image2d_rgb8.py
+
## dynamic_image2d.
pyexec_LTLIBRARIES += _dynamic_image2d.la
# Swig also generates a header for this module, since it makes use of
@@ -240,6 +250,11 @@ image2d_int_u8-wrap.cc: $(top_srcdir)/swilena/fill.ixx
image2d_int_u8-wrap.cc: $(top_srcdir)/swilena/println.ixx
image2d_int_u8-wrap.cc: $(top_srcdir)/swilena/morpho.ixx $(morpho_ixx_deps)
+image2d_rgb8-wrap.cc: $(top_srcdir)/swilena/image2d.ixx
+image2d_rgb8-wrap.cc: $(top_srcdir)/swilena/ppm.ixx
+image2d_rgb8-wrap.cc: $(top_srcdir)/swilena/fill.ixx
+image2d_rgb8-wrap.cc: $(top_srcdir)/swilena/println.ixx
+
## ---------------------------- ##
## Swilena Python Shell (sps). ##
diff --git a/swilena/python/swilena.py b/swilena/python/swilena.py
index 763bf40..14b9838 100644
--- a/swilena/python/swilena.py
+++ b/swilena/python/swilena.py
@@ -36,3 +36,4 @@ from rgb8 import *
import image2d_int
import image2d_int_u8
+import image2d_rgb8
--
1.5.6.5
1
0
08 Feb '10
* ppm.ixx: New file.
* Makefile.am (meta_wrappers): Add ppm.ixx.
---
swilena/ChangeLog | 7 +++++++
swilena/Makefile.am | 1 +
swilena/{pgm.ixx => ppm.ixx} | 20 ++++++++++----------
3 files changed, 18 insertions(+), 10 deletions(-)
copy swilena/{pgm.ixx => ppm.ixx} (79%)
diff --git a/swilena/ChangeLog b/swilena/ChangeLog
index ac6fcdf..605c3d5 100644
--- a/swilena/ChangeLog
+++ b/swilena/ChangeLog
@@ -1,5 +1,12 @@
2010-02-08 Roland Levillain <roland(a)lrde.epita.fr>
+ Add a Swilena meta-wrapper for PPM I/O.
+
+ * ppm.ixx: New file.
+ * Makefile.am (meta_wrappers): Add ppm.ixx.
+
+2010-02-08 Roland Levillain <roland(a)lrde.epita.fr>
+
Add a setter in the mln::image2d<T> meta-wrapper.
* image2d.ixx (mln::image2d<T>::set): New method (extension).
diff --git a/swilena/Makefile.am b/swilena/Makefile.am
index f6638b6..7e84230 100644
--- a/swilena/Makefile.am
+++ b/swilena/Makefile.am
@@ -32,6 +32,7 @@ meta_wrappers = \
intp.ixx \
morpho.ixx \
pgm.ixx \
+ ppm.ixx \
println.ixx \
python-utils.ixx \
rgb.ixx
diff --git a/swilena/pgm.ixx b/swilena/ppm.ixx
similarity index 79%
copy from swilena/pgm.ixx
copy to swilena/ppm.ixx
index 166903a..c66a577 100644
--- a/swilena/pgm.ixx
+++ b/swilena/ppm.ixx
@@ -1,5 +1,5 @@
// -*- C++ -*-
-// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 2010 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -24,34 +24,34 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-/// \file pgm.ixx
-/// \brief A wrapper of mln::io::pgm::load and mln::io::pgm::save
+/// \file ppm.ixx
+/// \brief A wrapper of mln::io::ppm::load and mln::io::ppm::save
-%module pgm
+%module ppm
%include std_string.i
%{
-#include "mln/io/pgm/load.hh"
-#include "mln/io/pgm/save.hh"
+#include "mln/io/ppm/load.hh"
+#include "mln/io/ppm/save.hh"
%}
-// Wrap mln::io::pgm::load(const std::string&) by hand, to force swig
+// Wrap mln::io::ppm::load(const std::string&) by hand, to force swig
// to choose this overloading.
namespace mln
{
namespace io
{
- namespace pgm
+ namespace ppm
{
template <typename V>
mln::image2d<V> load(const std::string& filename);
- } // end of namespace mln::io::pgm
+ } // end of namespace mln::io::ppm
} // end of namespace mln::io
} // end of namespace mln
-%include "mln/io/pgm/save.hh"
+%include "mln/io/ppm/save.hh"
--
1.5.6.5
1
0
last-svn-commit-7-g2cf95fd Add a setter in the mln::image2d<T> meta-wrapper.
by Roland Levillain 08 Feb '10
by Roland Levillain 08 Feb '10
08 Feb '10
* image2d.ixx (mln::image2d<T>::set): New method (extension).
---
swilena/ChangeLog | 6 ++++++
swilena/image2d.ixx | 23 +++++++++++++++++++++--
2 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/swilena/ChangeLog b/swilena/ChangeLog
index 9b948f7..ac6fcdf 100644
--- a/swilena/ChangeLog
+++ b/swilena/ChangeLog
@@ -1,5 +1,11 @@
2010-02-08 Roland Levillain <roland(a)lrde.epita.fr>
+ Add a setter in the mln::image2d<T> meta-wrapper.
+
+ * image2d.ixx (mln::image2d<T>::set): New method (extension).
+
+2010-02-08 Roland Levillain <roland(a)lrde.epita.fr>
+
Add a Swilena wrapper for mln::value::rgb8.
* rgb8.i: New file.
diff --git a/swilena/image2d.ixx b/swilena/image2d.ixx
index 90532bc..702bc74 100644
--- a/swilena/image2d.ixx
+++ b/swilena/image2d.ixx
@@ -1,5 +1,6 @@
// -*- C++ -*-
-// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 2009, 2010 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -63,6 +64,24 @@
// FIXME: Doc.
%define instantiate_image2d(I, T)
+ /* Add a setter, since Python does not seem to allow writings like
+
+ ima(p) = 1
+
+ and will complain with this message:
+
+ SyntaxError: can't assign to function call
+
+ which is a real pain. How about adding an operator `[]'? Or a
+ method , like `at'? */
+ %extend mln::image2d< T >
+ {
+ void set(const point2d& p, const T& v)
+ {
+ (*$self)(p) = v;
+ }
+ }
+
// Instantiate base classes of mln::image2d<T> so that Swig knows it
// derives from mln::Image.
%template() mln::internal::image_primary< T, mln::box2d, mln::image2d< T > >;
@@ -70,4 +89,4 @@
%template() mln::internal::image_checked_< mln::image2d< T > >;
// Instantiate mln::image2d<T>
%template(I) mln::image2d< T >;
-%enddef
+%enddef // !instantiate_image2d
--
1.5.6.5
1
0
last-svn-commit-6-g43118cb Add a Swilena wrapper for mln::value::rgb8.
by Roland Levillain 08 Feb '10
by Roland Levillain 08 Feb '10
08 Feb '10
* rgb8.i: New file.
* Makefile.am (wrappers): Add rgb8.i.
* python/swilena.py: Import the contents of module rgb8.
* python/Makefile.am (pyexec_LTLIBRARIES): Add _rgb8.la.
(nodist__rgb8_la_SOURCES, _rgb8_la_LIBADD): New.
(CLEANFILES): Add $(nodist__rgb8_la_SOURCES) rgb8.py rgb8.py[co].
(nodist_python_PYTHON): Add rgb8.py.
(rgb8-wrap.cc): Add dependencies.
---
swilena/ChangeLog | 13 +++++++++++++
swilena/Makefile.am | 1 +
swilena/python/Makefile.am | 11 +++++++++++
swilena/python/swilena.py | 4 +++-
swilena/{println.ixx => rgb8.i} | 16 +++++++++++-----
5 files changed, 39 insertions(+), 6 deletions(-)
copy swilena/{println.ixx => rgb8.i} (82%)
diff --git a/swilena/ChangeLog b/swilena/ChangeLog
index 7d670b3..9b948f7 100644
--- a/swilena/ChangeLog
+++ b/swilena/ChangeLog
@@ -1,5 +1,18 @@
2010-02-08 Roland Levillain <roland(a)lrde.epita.fr>
+ Add a Swilena wrapper for mln::value::rgb8.
+
+ * rgb8.i: New file.
+ * Makefile.am (wrappers): Add rgb8.i.
+ * python/swilena.py: Import the contents of module rgb8.
+ * python/Makefile.am (pyexec_LTLIBRARIES): Add _rgb8.la.
+ (nodist__rgb8_la_SOURCES, _rgb8_la_LIBADD): New.
+ (CLEANFILES): Add $(nodist__rgb8_la_SOURCES) rgb8.py rgb8.py[co].
+ (nodist_python_PYTHON): Add rgb8.py.
+ (rgb8-wrap.cc): Add dependencies.
+
+2010-02-08 Roland Levillain <roland(a)lrde.epita.fr>
+
Add a Swilena meta-wrapper for mln::value::rgb<n>.
* rgb.ixx: New file.
diff --git a/swilena/Makefile.am b/swilena/Makefile.am
index ea221a3..f6638b6 100644
--- a/swilena/Makefile.am
+++ b/swilena/Makefile.am
@@ -48,6 +48,7 @@ wrappers = \
int_u8.i \
neighb2d.i \
point2d.i \
+ rgb8.i \
window2d.i \
\
dynamic_image2d.i
diff --git a/swilena/python/Makefile.am b/swilena/python/Makefile.am
index 8f7faa9..13b17cc 100644
--- a/swilena/python/Makefile.am
+++ b/swilena/python/Makefile.am
@@ -144,6 +144,16 @@ CLEANFILES += $(nodist__neighb2d_la_SOURCES) neighb2d.py neighb2d.py[co]
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/_neighb2d-wrap.Pcc@am__quote@
nodist_python_PYTHON += neighb2d.py
+## rgb8.
+pyexec_LTLIBRARIES += _rgb8.la
+nodist__rgb8_la_SOURCES = rgb8-wrap.cc
+_rgb8_la_LIBADD = $(AM_LIBADD)
+CLEANFILES += $(nodist__rgb8_la_SOURCES) rgb8.py rgb8.py[co]
+## Include the dependency files. Copied from Automake's generated
+## case for C++.
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/_rgb8-wrap.Pcc@am__quote@
+nodist_python_PYTHON += rgb8.py
+
## window2d.
pyexec_LTLIBRARIES += _window2d.la
nodist__window2d_la_SOURCES = window2d-wrap.cc
@@ -208,6 +218,7 @@ morpho_ixx_deps = \
# Dependencies of wrappers not automatically computed (yet).
int_u8-wrap.cc: $(top_srcdir)/swilena/int_u.ixx $(int_u_ixx_deps)
int_u32-wrap.cc: $(top_srcdir)/swilena/int_u.ixx $(int_u_ixx_deps)
+rgb8-wrap.cc: $(top_srcdir)/swilena/rgb.ixx $(rgb_ixx_deps)
box2d-wrap.cc: $(top_srcdir)/swilena/box.ixx $(box_ixx_deps)
box2d_piter-wrap.cc: $(top_srcdir)/swilena/box_piter.ixx
diff --git a/swilena/python/swilena.py b/swilena/python/swilena.py
index 8cb695a..763bf40 100644
--- a/swilena/python/swilena.py
+++ b/swilena/python/swilena.py
@@ -1,6 +1,7 @@
#! /usr/bin/env python
-# Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+# Copyright (C) 2008, 2009, 2010 EPITA Research and Development
+# Laboratory (LRDE)
#
# This file is part of Olena.
#
@@ -31,6 +32,7 @@ from window2d import *
from int_u8 import *
from int_u32 import *
+from rgb8 import *
import image2d_int
import image2d_int_u8
diff --git a/swilena/println.ixx b/swilena/rgb8.i
similarity index 82%
copy from swilena/println.ixx
copy to swilena/rgb8.i
index 5f56e63..bc6d313 100644
--- a/swilena/println.ixx
+++ b/swilena/rgb8.i
@@ -1,5 +1,5 @@
// -*- C++ -*-
-// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -24,11 +24,17 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-/// \file println.ixx
-/// \brief A wrapper of mln::debug::println.
+/// \file rgb8.i
+/// \brief A wrapper of mln::value::rgb8.
+
+%module rgb8
+
+%include "rgb.ixx"
%{
- #include "mln/debug/println.hh"
+#include "mln/value/rgb8.hh"
%}
-%include "mln/debug/println.hh"
+%include "mln/value/rgb8.hh"
+
+%template (rgb8) mln::value::rgb<8>;
--
1.5.6.5
1
0
last-svn-commit-4-g1276c8a Improve dependency management in Swilena/Python.
by Roland Levillain 08 Feb '10
by Roland Levillain 08 Feb '10
08 Feb '10
* python/Makefile.am (int_u_ixx_deps, box_ixx_deps)
(morpho_ixx_deps):
New variables.
(int_u8-wrap.cc, int_u32-wrap.cc, box2d-wrap.cc)
(box2d_piter-wrap.cc, point2d-wrap.cc, dynamic_image2d-wrap.cc)
(image2d_int-wrap.cc, image2d_int_u8-wrap.cc):
Add dependencies.
---
swilena/ChangeLog | 12 ++++++++++++
swilena/python/Makefile.am | 43 ++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 54 insertions(+), 1 deletions(-)
diff --git a/swilena/ChangeLog b/swilena/ChangeLog
index f6a3e78..0860765 100644
--- a/swilena/ChangeLog
+++ b/swilena/ChangeLog
@@ -1,3 +1,15 @@
+2010-02-08 Roland Levillain <roland(a)lrde.epita.fr>
+
+ Improve dependency management in Swilena/Python.
+
+ * python/Makefile.am (int_u_ixx_deps, box_ixx_deps)
+ (morpho_ixx_deps):
+ New variables.
+ (int_u8-wrap.cc, int_u32-wrap.cc, box2d-wrap.cc)
+ (box2d_piter-wrap.cc, point2d-wrap.cc, dynamic_image2d-wrap.cc)
+ (image2d_int-wrap.cc, image2d_int_u8-wrap.cc):
+ Add dependencies.
+
2009-11-17 Roland Levillain <roland(a)lrde.epita.fr>
* python/morpho-segm.py: Remove a superfluous semi-colon.
diff --git a/swilena/python/Makefile.am b/swilena/python/Makefile.am
index 0ad96da..f6a834c 100644
--- a/swilena/python/Makefile.am
+++ b/swilena/python/Makefile.am
@@ -1,4 +1,5 @@
-# Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE).
+# Copyright (C) 2008, 2009, 2010 EPITA Research and Development
+# Laboratory (LRDE).
#
# This file is part of Olena.
#
@@ -188,6 +189,46 @@ CLEANFILES += $(nodist__dynamic_image2d_la_SOURCES) dynamic_image2d.py dynamic_i
nodist_python_PYTHON += dynamic_image2d.py
+## -------------------- ##
+## Extra dependencies. ##
+## -------------------- ##
+
+# FIXME: It would be cool to have them generated automatically.
+
+# Dependencies pulled by the meta wrapper (.ixx) files.
+int_u_ixx_deps = $(top_srcdir)/swilena/python-utils.ixx
+
+box_ixx_deps = $(top_srcdir)/swilena/coord.ixx
+
+morpho_ixx_deps = \
+ $(top_srcdir)/swilena/concrete.ixx \
+ $(top_srcdir)/swilena/ch_value.ixx
+
+# Dependencies of wrappers not automatically computed (yet).
+int_u8-wrap.cc: $(top_srcdir)/swilena/int_u.ixx $(int_u_ixx_deps)
+int_u32-wrap.cc: $(top_srcdir)/swilena/int_u.ixx $(int_u_ixx_deps)
+
+box2d-wrap.cc: $(top_srcdir)/swilena/box.ixx $(box_ixx_deps)
+box2d_piter-wrap.cc: $(top_srcdir)/swilena/box_piter.ixx
+
+point2d-wrap.cc: $(top_srcdir)/swilena/concat.ixx
+point2d-wrap.cc: $(top_srcdir)/swilena/python-utils.ixx
+
+dynamic_image2d-wrap.cc: $(top_srcdir)/swilena/fill.ixx
+dynamic_image2d-wrap.cc: $(top_srcdir)/swilena/println.ixx
+
+image2d_int-wrap.cc: $(top_srcdir)/swilena/image2d.ixx
+image2d_int-wrap.cc: $(top_srcdir)/swilena/fill.ixx
+image2d_int-wrap.cc: $(top_srcdir)/swilena/println.ixx
+image2d_int-wrap.cc: $(top_srcdir)/swilena/morpho.ixx $(morpho_ixx_deps)
+
+image2d_int_u8-wrap.cc: $(top_srcdir)/swilena/image2d.ixx
+image2d_int_u8-wrap.cc: $(top_srcdir)/swilena/pgm.ixx
+image2d_int_u8-wrap.cc: $(top_srcdir)/swilena/fill.ixx
+image2d_int_u8-wrap.cc: $(top_srcdir)/swilena/println.ixx
+image2d_int_u8-wrap.cc: $(top_srcdir)/swilena/morpho.ixx $(morpho_ixx_deps)
+
+
## ---------------------------- ##
## Swilena Python Shell (sps). ##
## ---------------------------- ##
--
1.5.6.5
1
0
last-svn-commit-5-g8408837 Add a Swilena meta-wrapper for mln::value::rgb<n>.
by Roland Levillain 08 Feb '10
by Roland Levillain 08 Feb '10
08 Feb '10
* rgb.ixx: New file.
* Makefile.am (meta_wrappers): Add rgb.ixx.
* python/Makefile.am (rgb_ixx_deps): New variable.
---
swilena/ChangeLog | 8 ++
swilena/Makefile.am | 6 +-
swilena/python/Makefile.am | 1 +
swilena/rgb.ixx | 155 ++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 168 insertions(+), 2 deletions(-)
create mode 100644 swilena/rgb.ixx
diff --git a/swilena/ChangeLog b/swilena/ChangeLog
index 0860765..7d670b3 100644
--- a/swilena/ChangeLog
+++ b/swilena/ChangeLog
@@ -1,5 +1,13 @@
2010-02-08 Roland Levillain <roland(a)lrde.epita.fr>
+ Add a Swilena meta-wrapper for mln::value::rgb<n>.
+
+ * rgb.ixx: New file.
+ * Makefile.am (meta_wrappers): Add rgb.ixx.
+ * python/Makefile.am (rgb_ixx_deps): New variable.
+
+2010-02-08 Roland Levillain <roland(a)lrde.epita.fr>
+
Improve dependency management in Swilena/Python.
* python/Makefile.am (int_u_ixx_deps, box_ixx_deps)
diff --git a/swilena/Makefile.am b/swilena/Makefile.am
index 109fb2e..ea221a3 100644
--- a/swilena/Makefile.am
+++ b/swilena/Makefile.am
@@ -1,4 +1,5 @@
-# Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE).
+# Copyright (C) 2008, 2009, 2010 EPITA Research and Development
+# Laboratory (LRDE).
#
# This file is part of Olena.
#
@@ -32,7 +33,8 @@ meta_wrappers = \
morpho.ixx \
pgm.ixx \
println.ixx \
- python-utils.ixx
+ python-utils.ixx \
+ rgb.ixx
# Wrappers (generating actual modules).
wrappers = \
diff --git a/swilena/python/Makefile.am b/swilena/python/Makefile.am
index f6a834c..8f7faa9 100644
--- a/swilena/python/Makefile.am
+++ b/swilena/python/Makefile.am
@@ -197,6 +197,7 @@ nodist_python_PYTHON += dynamic_image2d.py
# Dependencies pulled by the meta wrapper (.ixx) files.
int_u_ixx_deps = $(top_srcdir)/swilena/python-utils.ixx
+rgb_ixx_deps = $(top_srcdir)/swilena/python-utils.ixx
box_ixx_deps = $(top_srcdir)/swilena/coord.ixx
diff --git a/swilena/rgb.ixx b/swilena/rgb.ixx
new file mode 100644
index 0000000..c5607f3
--- /dev/null
+++ b/swilena/rgb.ixx
@@ -0,0 +1,155 @@
+// -*- C++ -*-
+// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to produce
+// an executable, this file does not by itself cause the resulting
+// executable to be covered by the GNU General Public License. This
+// exception does not however invalidate any other reasons why the
+// executable file might be covered by the GNU General Public License.
+
+/// \file rgb.i
+/// \brief A wrapper of mln::value::rgb.
+
+%module rgb
+
+%{
+#include "mln/value/rgb.hh"
+%}
+
+// FIXME: Wrap mln::rgb by hand, for Milena macros disturb swig.
+// Annotate the original source code instead?
+namespace mln
+{
+
+ namespace value
+ {
+
+ /*! \brief Unsigned integer value class.
+ *
+ * The parameter is \c n the number of encoding bits.
+ */
+ template <unsigned n>
+ struct rgb
+ :
+ public Vectorial< rgb<n> >
+ ,
+ public internal::value_like_< algebra::vec< 3, int_u<n> >, // Equivalent.
+ algebra::vec< 3, int_u<n> >, // Encoding.
+ algebra::vec< 3, int >, // Interoperation.
+ rgb<n> > // Exact.
+ {
+ public:
+
+ typedef int_u<n> red_t;
+ typedef int_u<n> green_t;
+ typedef int_u<n> blue_t;
+
+ /// Acces to red/green/blue component.
+ /// \{
+ mln::value::int_u<n> red() const;
+ mln::value::int_u<n>& red();
+
+ mln::value::int_u<n> green() const;
+ mln::value::int_u<n>& green();
+
+ mln::value::int_u<n> blue() const;
+ mln::value::int_u<n>& blue();
+
+ mln::value::int_u<n> comp(unsigned k);
+ mln::value::int_u<n>& comp(unsigned k);
+ /// \}
+
+ /// Constructor without argument.
+ rgb<n>();
+
+ /// Constructor from component values.
+ rgb<n>(int r, int g, int b);
+
+ /// Constructor from a algebra::vec.
+ rgb<n>(const mln::algebra::vec<3, int>& rhs);
+ rgb<n>(const mln::algebra::vec<3, unsigned>& rhs);
+ rgb<n>(const mln::algebra::vec<3, mln::value::int_u<n> >& rhs);
+ rgb<n>(const mln::algebra::vec<3, float>& rhs);
+
+ // Conversion to the interoperation type.
+ operator mln::algebra::vec<3, int>() const;
+ // Conversion to the sum type.
+ operator mln::algebra::vec<3, float>() const;
+
+ /// Constructors with literals.
+ /// \{
+ rgb<n>(const mln::literal::white_t&);
+ rgb<n>(const mln::literal::black_t&);
+
+ rgb<n>(const mln::literal::light_gray_t&);
+ rgb<n>(const mln::literal::medium_gray_t&);
+ rgb<n>(const mln::literal::dark_gray_t&);
+
+ rgb<n>(const mln::literal::red_t&);
+ rgb<n>(const mln::literal::blue_t&);
+ rgb<n>(const mln::literal::green_t&);
+ rgb<n>(const mln::literal::brown_t&);
+ rgb<n>(const mln::literal::lime_t&);
+ rgb<n>(const mln::literal::orange_t&);
+ rgb<n>(const mln::literal::pink_t&);
+ rgb<n>(const mln::literal::purple_t&);
+ rgb<n>(const mln::literal::teal_t&);
+ rgb<n>(const mln::literal::violet_t&);
+ rgb<n>(const mln::literal::cyan_t&);
+ rgb<n>(const mln::literal::magenta_t&);
+ rgb<n>(const mln::literal::yellow_t&);
+ rgb<n>(const mln::literal::olive_t&);
+ /// \}
+
+ /// Assignment.
+ rgb<n>& operator=(const rgb<n>& rhs);
+
+ /// Zero value.
+ static const rgb<n> zero;
+ };
+
+
+ /*! \brief Print an unsigned integer \p i into the output stream \p ostr.
+ *
+ * \param[in,out] ostr An output stream.
+ * \param[in] i An unsigned integer.
+ *
+ * \return The modified output stream \p ostr.
+ */
+ template <unsigned n>
+ std::ostream& operator<<(std::ostream& ostr, const rgb<n>& i);
+
+ // FIXME: Doc!
+ template <unsigned n>
+ std::istream& operator>>(std::istream& istr, rgb<n>& i);
+
+ } // end of namespace mln::value
+
+} // end of namespace mln
+
+
+/*--------------------------------.
+| Conversion helpers for Python. |
+`--------------------------------*/
+
+#if SWIGPYTHON
+%include python-utils.ixx
+generate__str__(mln::value::rgb)
+#endif // !SWIGPYTHON
--
1.5.6.5
1
0
[Olena] #223: Set up an automatic news/mail notification upon patch reception
by Olena Trac 16 Dec '09
by Olena Trac 16 Dec '09
16 Dec '09
#223: Set up an automatic news/mail notification upon patch reception
-----------------------------+----------------------------------------------
Reporter: levill_r | Owner: levill_r
Type: enhancement | Status: new
Priority: major | Milestone:
Component: Olena | Version: 1.0
Keywords: Git send e-mail |
-----------------------------+----------------------------------------------
See Vaucanson's and Spot's installations.
--
Ticket URL: <https://trac.lrde.org/olena/ticket/223>
Olena <http://olena.lrde.epita.fr>
Olena, a generic and efficient C++ image processing library.
1
2