URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog:
2009-04-19 Edwin Carlinet <carlinet(a)lrde.epita.fr>
Process line: watershed from color image after height closing.
* edwin/rush/*,
* edwin/rush/leaves: New directory for leaves export
routines. Move rush/* to rush/leaves.*
* edwin/rush/exo2: New.
* edwin/rush/exo2/color_internal_gradient.hh: Routine that
computes internal gradient from color image.
* edwin/rush/exo2/color_labeling_mean.hh: Routine that
replaces a basin label by its mean color.
* edwin/rush/exo2/wst_from_closing.cc: Process line.
---
exo2/Makefile | 29 +++++++
exo2/color_internal_gradient.hh | 149 ++++++++++++++++++++++++++++++++++++++++
exo2/color_labeling_mean.hh | 70 ++++++++++++++++++
exo2/configure | 21 +++++
exo2/wst_from_closing.cc | 127 ++++++++++++++++++++++++++++++++++
leaves/Makefile | 35 +++++++++
leaves/chain.sh | 34 +++++++++
leaves/configure | 21 +++++
leaves/export_leaves.hh | 115 ++++++++++++++++++++++++++++++
leaves/get_leaves.cc | 65 +++++++++++++++++
leaves/splot.sh | 10 ++
leaves/test/Makefile | 41 +++++++++++
leaves/test/configure | 21 +++++
leaves/test/export.cc | 63 ++++++++++++++++
14 files changed, 801 insertions(+)
Index: trunk/milena/sandbox/edwin/rush/configure (deleted)
===================================================================
Index: trunk/milena/sandbox/edwin/rush/get_leaves.cc (deleted)
===================================================================
Index: trunk/milena/sandbox/edwin/rush/splot.sh (deleted)
===================================================================
Index: trunk/milena/sandbox/edwin/rush/chain.sh (deleted)
===================================================================
Index: trunk/milena/sandbox/edwin/rush/Makefile (deleted)
===================================================================
Index: trunk/milena/sandbox/edwin/rush/export_leaves.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/edwin/rush/leaves/test/configure
===================================================================
--- trunk/milena/sandbox/edwin/rush/leaves/test/configure (revision 0)
+++ trunk/milena/sandbox/edwin/rush/leaves/test/configure (revision 3687)
@@ -0,0 +1,21 @@
+#! /bin/bash
+
+for arg in "$@"; do
+ if [ "$arg" == "--debug" ]; then
+ debug=1;
+ elif [ "$arg" == "--release" ]; then
+ release=1;
+ elif [ "${arg#--mln_dir=}" ]; then
+ MLN_DIR=${arg#--mln_dir=}
+ fi
+done
+
+rm -f makefile.rules
+touch makefile.rules
+if [ "$debug" ]; then
+ echo 'DEBUG = 1' >> makefile.rules
+fi
+if [ "$release" ]; then
+ echo 'RELEASE = 1' >> makefile.rules
+fi
+echo "MLN_DIR = $MLN_DIR" >> makefile.rules
\ No newline at end of file
Property changes on: trunk/milena/sandbox/edwin/rush/leaves/test/configure
___________________________________________________________________
Name: svn:executable
+ *
Index: trunk/milena/sandbox/edwin/rush/leaves/test/export.cc
===================================================================
--- trunk/milena/sandbox/edwin/rush/leaves/test/export.cc (revision 0)
+++ trunk/milena/sandbox/edwin/rush/leaves/test/export.cc (revision 3687)
@@ -0,0 +1,63 @@
+// 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.
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/neighb2d.hh>
+#include <mln/core/site_set/p_array.hh>
+
+#include <mln/level/sort_psites.hh>
+
+#include <mln/morpho/tree/data.hh>
+#include "../export_leaves.hh"
+
+#include <mln/io/pbm/save.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ typedef image2d<int> I;
+ typedef p_array<point2d> S;
+ typedef morpho::tree::data<I,S> tree_t;
+
+ int vals[] = {3, 3, 4,
+ 3, 5, 4,
+ 4, 4, 4 };
+
+ I ima = make::image2d(vals);
+ S s = level::sort_psites_decreasing(ima);
+ tree_t t(ima, s, c4());
+
+ export_leaves_to_file(t, ima);
+
+ typedef mln_ch_value_(I, bool) B;
+ B b_img = export_leaves_to_img(t, ima);
+
+ io::pbm::save(b_img, "leaves.pbm");
+}
Index: trunk/milena/sandbox/edwin/rush/leaves/test/Makefile
===================================================================
--- trunk/milena/sandbox/edwin/rush/leaves/test/Makefile (revision 0)
+++ trunk/milena/sandbox/edwin/rush/leaves/test/Makefile (revision 3687)
@@ -0,0 +1,41 @@
+include makefile.rules
+TARGET=export
+#sharp_SRC=sharp.cc
+#sharp_OBJS=${sharp_SRC:.cc=.o}
+
+export_SRC=export.cc
+export_OBJS=${export_SRC:.cc=.o}
+
+OLENADIR=$(MLN_DIR)/..
+MILENADIR=$(MLN_DIR)
+
+CXXFLAGS=-I$(MILENADIR) -I./ -W -Wall
+
+
+CXXFLAGS += $(if $(DEBUG), -g -ggdb, -DNDEBUG\
+ $(if $(RELEASE), -O3, -O1))
+
+CXX=g++
+LD=g++
+LDFLAGS=
+
+all: $(TARGET)
+
+
+$(TARGET): $($(TARGET)_OBJS) $($(TARGET)_SRC)
+ $(LD) $(LDFLAGS) -o $@ $($(TARGET)_OBJS)
+
+%.o: %.cc
+ $(CXX) $(CXXFLAGS) -c $<
+
+%.o: %.hh
+ $(CXX) $(CXXFLAGS) -c $<
+
+depend:
+ makedepend -- $(CXXFLAGS) -- -v $($(TARGET)_SRC)
+
+clean:
+ rm -f *.o $(TARGET)
+ #rm -f *.pbm
+ #find -name "*.pgm" \! -regex ".*/affiche2?.pgm" -delete
+# DO NOT DELETE
\ No newline at end of file
Index: trunk/milena/sandbox/edwin/rush/leaves/configure
===================================================================
--- trunk/milena/sandbox/edwin/rush/leaves/configure (revision 0)
+++ trunk/milena/sandbox/edwin/rush/leaves/configure (revision 3687)
@@ -0,0 +1,21 @@
+#! /bin/bash
+
+for arg in "$@"; do
+ if [ "$arg" == "--debug" ]; then
+ debug=1;
+ elif [ "$arg" == "--release" ]; then
+ release=1;
+ elif [ "${arg#--mln_dir=}" ]; then
+ MLN_DIR=${arg#--mln_dir=}
+ fi
+done
+
+rm -f makefile.rules
+touch makefile.rules
+if [ "$debug" ]; then
+ echo 'DEBUG = 1' >> makefile.rules
+fi
+if [ "$release" ]; then
+ echo 'RELEASE = 1' >> makefile.rules
+fi
+echo "MLN_DIR = $MLN_DIR" >> makefile.rules
\ No newline at end of file
Property changes on: trunk/milena/sandbox/edwin/rush/leaves/configure
___________________________________________________________________
Name: svn:executable
+ *
Index: trunk/milena/sandbox/edwin/rush/leaves/get_leaves.cc
===================================================================
--- trunk/milena/sandbox/edwin/rush/leaves/get_leaves.cc (revision 0)
+++ trunk/milena/sandbox/edwin/rush/leaves/get_leaves.cc (revision 3687)
@@ -0,0 +1,65 @@
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/neighb2d.hh>
+#include <mln/core/site_set/p_array.hh>
+
+#include <mln/level/sort_psites.hh>
+
+#include <mln/morpho/tree/data.hh>
+#include <mln/morpho/tree/compute_attribute_image.hh>
+#include "export_leaves.hh"
+
+#include <mln/morpho/attribute/sharpness.hh>
+
+#include <mln/io/pbm/save.hh>
+#include <mln/io/pgm/load.hh>
+
+#include <mln/value/int_u8.hh>
+
+#include <iostream>
+
+
+
+void usage(char** argv)
+{
+ std::cout << "Retrieve leaves of the component tree using sharpness"
+ << " attribute. It returns a binary image of leaves and creates"
+ << " txt file that contains nodes of the branch that the leaf belongs to."
+ << std::endl;
+ std::cout << "Usage: " << argv[0] << " input.pgm" << std::endl;
+ abort();
+}
+
+
+int main(int argc, char* argv[])
+{
+ using namespace mln;
+ using value::int_u8;
+
+ if (argc == 0)
+ usage(argv);
+
+
+ // Load a pgm img (Gray level Or Gradient Image)
+ typedef image2d<int_u8> I;
+ I input;
+ io::pgm::load(input, argv[1]);
+
+ // Tree Creation
+ typedef p_array<point2d> S;
+ typedef morpho::tree::data<I,S> tree_t;
+ S s = level::sort_psites_decreasing(input);
+ tree_t t(input, s, c4());
+
+ // Attribute pruning.
+ typedef morpho::attribute::sharpness<I> sharp_t;
+ typedef mln_ch_value_(I, double) A;
+
+ A a = morpho::tree::compute_attribute_image(sharp_t (), t);
+
+
+ //Export Leaves
+ typedef mln_ch_value_(I, bool) B;
+ B b_img = export_leaves_to_img(t, a);
+ io::pbm::save(b_img, "leaves.pbm");
+ export_leaves_to_file(t, a);
+}
Index: trunk/milena/sandbox/edwin/rush/leaves/splot.sh
===================================================================
--- trunk/milena/sandbox/edwin/rush/leaves/splot.sh (revision 0)
+++ trunk/milena/sandbox/edwin/rush/leaves/splot.sh (revision 3687)
@@ -0,0 +1,10 @@
+#! /bin/bash
+FILE=gplot.batch
+
+echo "set terminal png" > "$FILE"
+for f in *.txt; do
+ echo 'set output "'$f'.png"' >> "$FILE"
+ echo 'plot "'$f'"' >> "$FILE"
+done;
+
+gnuplot "$FILE"
\ No newline at end of file
Property changes on: trunk/milena/sandbox/edwin/rush/leaves/splot.sh
___________________________________________________________________
Name: svn:executable
+ *
Index: trunk/milena/sandbox/edwin/rush/leaves/chain.sh
===================================================================
--- trunk/milena/sandbox/edwin/rush/leaves/chain.sh (revision 0)
+++ trunk/milena/sandbox/edwin/rush/leaves/chain.sh (revision 3687)
@@ -0,0 +1,34 @@
+#! /bin/bash
+
+function usage()
+{
+echo "./chain.sh input.ppm (--graylevel | --gradient)"
+exit 2
+}
+
+if [ $# -ne 2 ]; then
+ usage
+fi
+
+if [ "$2" = "--gradient" ]; then
+ gradient=1
+elif [ "$2" = "--graylevel" ]; then
+ graylevel=1
+else
+ usage
+fi
+
+make leaves
+if [ "x$gradient" = "x1" ]; then
+ make all
+ name="gradient.pgm"
+ ./gradient "$1" "$name"
+else
+ name="$1"
+ name="${name%.ppm}.pgm"
+ convert +compress -depth 8 -colorspace Gray "$1" "$name"
+fi
+./leaves "$name"
+rm -Rf "$1".dir
+mkdir "$1".dir
+mv *.txt "leaves.pbm" "$name" "$1".dir
\ No newline at end of file
Property changes on: trunk/milena/sandbox/edwin/rush/leaves/chain.sh
___________________________________________________________________
Name: svn:executable
+ *
Index: trunk/milena/sandbox/edwin/rush/leaves/Makefile
===================================================================
--- trunk/milena/sandbox/edwin/rush/leaves/Makefile (revision 0)
+++ trunk/milena/sandbox/edwin/rush/leaves/Makefile (revision 3687)
@@ -0,0 +1,35 @@
+include makefile.rules
+
+
+OLENADIR=$(MLN_DIR)/..
+MILENADIR=$(MLN_DIR)
+
+CXXFLAGS = -I$(MILENADIR) -I./ -W -Wall
+CXXFLAGS += $(if $(DEBUG), -g -ggdb, -DNDEBUG\
+ $(if $(RELEASE), -O3, -O1))
+CXX=g++
+LD=g++
+LDFLAGS=
+SRC=
+
+
+GRADIENT_SRC = $(MLN_DIR)/sandbox/theo/exec/color_internal_gradient.cc
+LEAVES_SRC = get_leaves.cc
+
+
+all: leaves gradient
+
+
+leaves: $(LEAVES_SRC)
+ $(CXX) $(CXXFLAGS) $< -o leaves
+
+gradient: $(GRADIENT_SRC)
+ $(CXX) $(CXXFLAGS) $< -o gradient
+
+
+clean:
+ rm -f leaves gradient
+
+
+%.o: %.cc
+ $(CXX) $(CXXFLAGS) -c $<
\ No newline at end of file
Index: trunk/milena/sandbox/edwin/rush/leaves/export_leaves.hh
===================================================================
--- trunk/milena/sandbox/edwin/rush/leaves/export_leaves.hh (revision 0)
+++ trunk/milena/sandbox/edwin/rush/leaves/export_leaves.hh (revision 3687)
@@ -0,0 +1,115 @@
+// 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 EXPORT_LEAVES_HH_
+# define EXPORT_LEAVES_HH_
+
+# include <mln/core/concept/image.hh>
+
+# include <mln/morpho/tree/data.hh>
+# include "../../tree/propagate.hh"
+
+
+# include <mln/data/fill.hh>
+
+# include <fstream>
+# include <sstream>
+
+namespace mln {
+
+ template <typename T, typename A>
+ inline
+ void
+ export_leaves_to_file(const T& tree, const Image<A>& attr_image);
+
+ template <typename T, typename A>
+ inline
+ mln_ch_value(A, bool)
+ export_leaves_to_img(const T& tree, const Image<A>& attr_image);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename T, typename A>
+ inline
+ void
+ export_leaves_to_file(const T& tree, const Image<A>& attr_image)
+ {
+ mln_precondition(tree.f().domain() == attr_image.domain());
+
+ const A& a = exact(attr_image);
+ mln_leaf_piter(T) leaf(tree);
+
+ for_all(leaf)
+ {
+ std::stringstream fn;
+ for (int i = 0; i < leaf.dim; i++)
+ fn << "[" << leaf[i] << "]";
+ fn << ".txt";
+
+ std::ofstream out(fn.str().c_str());
+ mln_psite(T) n = leaf;
+ int i = 0;
+ while (!tree.is_root(n))
+ {
+ out << i++ << " " << a(n) << std::endl;
+ n = tree.parent(n);
+ }
+ out << i << " " << a(n) << std::endl;
+ }
+ }
+
+ template <typename T, typename A>
+ inline
+ mln_ch_value(A, bool)
+ export_leaves_to_img(const T& tree, const Image<A>& attr_image)
+ {
+ mln_precondition(tree.f().domain() == attr_image.domain());
+
+ typedef mln_ch_value(A, bool) I;
+ const A& a = exact(attr_image);
+
+ I output;
+ initialize(output, a);
+ data::fill(output, false);
+
+ mln_leaf_piter(T) l(tree);
+ for_all(l)
+ output(l) = true;
+
+ morpho::tree::propagate_representant(tree, output);
+ return output;
+ }
+
+
+
+# endif /* !MLN_INCLUDE_ONLY */
+
+} // end of namespace mln
+
+#endif /* !EXPORT_LEAVES_HH_ */
Index: trunk/milena/sandbox/edwin/rush/exo2/configure
===================================================================
--- trunk/milena/sandbox/edwin/rush/exo2/configure (revision 0)
+++ trunk/milena/sandbox/edwin/rush/exo2/configure (revision 3687)
@@ -0,0 +1,21 @@
+#! /bin/bash
+
+for arg in "$@"; do
+ if [ "$arg" == "--debug" ]; then
+ debug=1;
+ elif [ "$arg" == "--release" ]; then
+ release=1;
+ elif [ "${arg#--mln_dir=}" ]; then
+ MLN_DIR=${arg#--mln_dir=}
+ fi
+done
+
+rm -f makefile.rules
+touch makefile.rules
+if [ "$debug" ]; then
+ echo 'DEBUG = 1' >> makefile.rules
+fi
+if [ "$release" ]; then
+ echo 'RELEASE = 1' >> makefile.rules
+fi
+echo "MLN_DIR = $MLN_DIR" >> makefile.rules
\ No newline at end of file
Property changes on: trunk/milena/sandbox/edwin/rush/exo2/configure
___________________________________________________________________
Name: svn:executable
+ *
Index: trunk/milena/sandbox/edwin/rush/exo2/wst_from_closing.cc
===================================================================
--- trunk/milena/sandbox/edwin/rush/exo2/wst_from_closing.cc (revision 0)
+++ trunk/milena/sandbox/edwin/rush/exo2/wst_from_closing.cc (revision 3687)
@@ -0,0 +1,127 @@
+// 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.
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/neighb2d.hh>
+
+#include <mln/value/int_u8.hh>
+#include <mln/value/int_u16.hh>
+#include <mln/value/rgb8.hh>
+#include <mln/value/label_16.hh>
+#include <mln/level/convert.hh>
+
+#include <mln/io/ppm/load.hh>
+#include <mln/io/ppm/save.hh>
+#include <mln/io/pgm/save.hh>
+
+#include "color_internal_gradient.hh"
+#include "color_labeling_mean.hh"
+#include <mln/morpho/closing/height.hh>
+#include <mln/morpho/watershed/all.hh>
+#include <mln/morpho/elementary/dilation.hh>
+
+
+#include <iostream>
+#include <string>
+
+
+void usage(char** argv)
+{
+ std::cout << "Usage: " << argv[0] << " input.ppm height [-o1 | -o2 | -o3]"
+ << std::endl
+ << "-o1\tSuperpose WS on input image (out: superpose.ppm)" << std::endl
+ << "-o2\tCount number of basins" << std::endl
+ << "-o3\tReplace basin by its mean color on the input (out: mean.ppm)"
+ << std::endl;
+ abort();
+}
+
+
+
+int main(int argc, char** argv)
+{
+ using namespace mln;
+ using value::int_u8;
+ using value::int_u16;
+ using value::rgb8;
+
+ if (argc < 3)
+ usage(argv);
+
+ int output_ = 0;
+ int lambda_h = std::atoi(argv[2]);
+
+ if (argc == 4)
+ if (std::string(argv[3]) == "-o1")
+ output_ = 1;
+ else if (std::string(argv[3]) == "-o2")
+ output_ = 2;
+ else if (std::string(argv[3]) == "-o3")
+ output_ = 3;
+ else
+ usage(argv);
+
+
+
+ // Load color image.
+ typedef image2d<rgb8> I_;
+ I_ input_;
+ io::ppm::load(input_, argv[1]);
+
+ // Gradient.
+ typedef image2d<int_u8> I;
+ I input = color_internal_gradient(input_);
+
+ // Closing
+ std::cout << lambda_h << std::endl;
+ input = morpho::closing::height(input, c4(), lambda_h);
+
+ // Watershed
+ typedef image2d<int_u16> WST;
+ int_u16 n_basins = 0;
+ WST wst = morpho::watershed::flooding(input, c4(), n_basins);
+
+ if (!output_ || output_ == 1)
+ {
+ I_ out = morpho::watershed::superpose(input_, wst);
+ io::ppm::save(out, "superpose.pgm");
+ }
+
+ if (!output_ || output_ == 2)
+ std::cout << "Number of basins: " << n_basins << std::endl;
+
+ if (!output_ || output_ == 3)
+ {
+ typedef image2d<value::label_16> L;
+ L lab = level::convert(value::label_16(),
+ morpho::elementary::dilation(wst, c8()));
+ I_ out = color_labeling_mean(input_, lab, n_basins);
+ io::ppm::save(out, "mean.pgm");
+ }
+
+}
Index: trunk/milena/sandbox/edwin/rush/exo2/color_internal_gradient.hh
===================================================================
--- trunk/milena/sandbox/edwin/rush/exo2/color_internal_gradient.hh (revision 0)
+++ trunk/milena/sandbox/edwin/rush/exo2/color_internal_gradient.hh (revision 3687)
@@ -0,0 +1,149 @@
+// 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 COLOR_INTERNAL_GRADIENT_HH_
+# define COLOR_INTERNAL_GRADIENT_HH_
+
+#include <mln/core/alias/neighb2d.hh>
+#include <mln/morpho/elementary/gradient_internal.hh>
+#include <mln/math/diff_abs.hh>
+
+#include <mln/accu/image/init.hh>
+#include <mln/accu/image/take.hh>
+#include <mln/accu/image/to_result.hh>
+
+#include <mln/accu/max.hh>
+
+namespace mln
+{
+
+ value::int_u8
+ dist(const value::rgb8& c1,
+ const value::rgb8& c2)
+ {
+ unsigned d = 0;
+ d += math::diff_abs(c1.red(), c2.red());
+ d += math::diff_abs(c1.green(), c2.green());
+ d += math::diff_abs(c1.blue(), c2.blue());
+ if (d > 255)
+ d = 255;
+ return d;
+ }
+
+ template <typename N>
+ image2d<value::int_u8>
+ color_gradient(const image2d<value::rgb8>& input,
+ const N& nbh)
+ {
+ using value::int_u8;
+ image2d<int_u8> output(input.domain());
+
+ mln_piter(box2d) p(input.domain());
+ mln_niter(N) n(nbh, p);
+ for_all(p)
+ {
+ int_u8 d = 0u;
+ for_all(n) if (input.domain().has(n))
+ {
+ int_u8 d_ = dist(input(p), input(n));
+ if (d_ > d)
+ d = d_;
+ }
+ output(p) = d;
+ }
+
+ return output;
+ }
+
+
+
+ template <typename I>
+ image2d<value::int_u8>
+ get_red(const I& input)
+ {
+ typedef image2d<value::int_u8> J;
+ J output(input.domain());
+
+ mln_pixter(const I) p_in(input);
+ mln_pixter(J) p_out(output);
+ for_all_2(p_in, p_out)
+ p_out.val() = p_in.val().red();
+ return output;
+ }
+
+ template <typename I>
+ image2d<value::int_u8>
+ get_green(const I& input)
+ {
+ typedef image2d<value::int_u8> J;
+ J output(input.domain());
+
+ mln_pixter(const I) p_in(input);
+ mln_pixter(J) p_out(output);
+ for_all_2(p_in, p_out)
+ p_out.val() = p_in.val().green();
+ return output;
+ }
+
+ template <typename I>
+ image2d<value::int_u8>
+ get_blue(const I& input)
+ {
+ typedef image2d<value::int_u8> J;
+ J output(input.domain());
+
+ mln_pixter(const I) p_in(input);
+ mln_pixter(J) p_out(output);
+ for_all_2(p_in, p_out)
+ p_out.val() = p_in.val().blue();
+ return output;
+ }
+
+ image2d<value::int_u8>
+ color_internal_gradient(const image2d<value::rgb8>& input)
+ {
+ typedef accu::max< value::int_u8 > A;
+ image2d<A> grad(input.domain());
+
+ using morpho::elementary::gradient_internal;
+
+ accu::image::init(grad);
+
+ accu::image::take(grad,
+ gradient_internal(get_red(input), c4()));
+ accu::image::take(grad,
+ gradient_internal(get_green(input), c4()));
+ accu::image::take(grad,
+ gradient_internal(get_blue(input), c4()));
+
+ return accu::image::to_result(grad);
+ }
+
+} // mln
+
+#endif /* !COLOR_INTERNAL_GRADIENT_HH_ */
Index: trunk/milena/sandbox/edwin/rush/exo2/color_labeling_mean.hh
===================================================================
--- trunk/milena/sandbox/edwin/rush/exo2/color_labeling_mean.hh (revision 0)
+++ trunk/milena/sandbox/edwin/rush/exo2/color_labeling_mean.hh (revision 3687)
@@ -0,0 +1,70 @@
+// 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 COLOR_LABELING_MEAN_HH_
+# define COLOR_LABELING_MEAN_HH_
+
+# include <mln/core/image/image2d.hh>
+
+# include <mln/labeling/compute.hh>
+# include <mln/accu/mean.hh>
+# include <mln/level/transform.hh>
+
+# include <mln/value/label_8.hh>
+# include <mln/value/int_u16.hh>
+
+namespace mln {
+
+ template <typename L>
+ image2d< value::rgb8 >
+ color_labeling_mean(const image2d< value::rgb8>& input,
+ const Image<L>& label,
+ unsigned nlabels)
+ {
+ using value::rgb8;
+ typedef algebra::vec<3,float> V;
+
+ accu::mean<value::rgb8> m_;
+ util::array<V> m = labeling::compute(m_, input, exact(label), nlabels);
+
+ util::array<rgb8> c(unsigned(nlabels) + 1);
+
+ c[0] = rgb8(0,0,0);
+ for (unsigned l = 1; l <= nlabels; ++l)
+ {
+ c[l].red() = m[l][0];
+ c[l].green() = m[l][1];
+ c[l].blue() = m[l][2];
+ }
+
+ return level::transform(label, c);
+ }
+
+} // mln
+
+#endif /* !COLOR_LABELING_MEAN_HH_ */
Index: trunk/milena/sandbox/edwin/rush/exo2/Makefile
===================================================================
--- trunk/milena/sandbox/edwin/rush/exo2/Makefile (revision 0)
+++ trunk/milena/sandbox/edwin/rush/exo2/Makefile (revision 3687)
@@ -0,0 +1,29 @@
+include makefile.rules
+
+
+OLENADIR=$(MLN_DIR)/..
+MILENADIR=$(MLN_DIR)
+
+CXXFLAGS = -I$(MILENADIR) -I./ -W -Wall
+CXXFLAGS += $(if $(DEBUG), -g -ggdb, -DNDEBUG\
+ $(if $(RELEASE), -O3, -O1))
+CXX=g++
+LD=g++
+LDFLAGS=
+SRC=
+
+OUT_IMG=superpose.pgm mean.pgm gradient.pgm closing.pgm
+
+all: wst_from_closing
+
+%: %.cc
+ $(CXX) $(CXXFLAGS) $< -o $@
+
+
+clean:
+ rm -f $(OUT_IMG)
+ rm -f wst_from_closing
+
+
+%.o: %.cc
+ $(CXX) $(CXXFLAGS) -c $<
\ No newline at end of file
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog:
2009-04-19 Edwin Carlinet <carlinet(a)lrde.epita.fr>
Routines to export leaves toward several representation.
* edwin/rush/Makefile: New.
* edwin/rush/chain.sh: Script that handles process.
* edwin/rush/configure: New.
* edwin/rush/export_leaves.hh: Leaves exportation methods.
* edwin/rush/get_leaves.cc: Process file that import pgm image,
creates tree, applies an attribute and export the leaves.
* edwin/rush/splot.sh: New file to autogenerate gnuplot graphics.
* edwin/rush/test/Makefile: New.
* edwin/rush/test/configure: New.
* edwin/rush/test/export.cc: Test file for routines.
* edwin/rush/test: New test folder.
* edwin/rush: New.
* edwin/tree/propagate.hh: Add missing include.
---
rush/Makefile | 35 +++++++++++++++
rush/chain.sh | 34 ++++++++++++++
rush/configure | 21 +++++++++
rush/export_leaves.hh | 115 ++++++++++++++++++++++++++++++++++++++++++++++++++
rush/get_leaves.cc | 65 ++++++++++++++++++++++++++++
rush/splot.sh | 10 ++++
rush/test/Makefile | 41 +++++++++++++++++
rush/test/configure | 21 +++++++++
rush/test/export.cc | 63 +++++++++++++++++++++++++++
tree/propagate.hh | 1
10 files changed, 406 insertions(+)
Index: trunk/milena/sandbox/edwin/tree/propagate.hh
===================================================================
--- trunk/milena/sandbox/edwin/tree/propagate.hh (revision 3685)
+++ trunk/milena/sandbox/edwin/tree/propagate.hh (revision 3686)
@@ -33,6 +33,7 @@
/// Functions to propagate a node value in the tree.
#include <mln/morpho/tree/data.hh>
+# include "propagate_node.hh"
namespace mln {
namespace morpho {
Index: trunk/milena/sandbox/edwin/rush/test/configure
===================================================================
--- trunk/milena/sandbox/edwin/rush/test/configure (revision 0)
+++ trunk/milena/sandbox/edwin/rush/test/configure (revision 3686)
@@ -0,0 +1,21 @@
+#! /bin/bash
+
+for arg in "$@"; do
+ if [ "$arg" == "--debug" ]; then
+ debug=1;
+ elif [ "$arg" == "--release" ]; then
+ release=1;
+ elif [ "${arg#--mln_dir=}" ]; then
+ MLN_DIR=${arg#--mln_dir=}
+ fi
+done
+
+rm -f makefile.rules
+touch makefile.rules
+if [ "$debug" ]; then
+ echo 'DEBUG = 1' >> makefile.rules
+fi
+if [ "$release" ]; then
+ echo 'RELEASE = 1' >> makefile.rules
+fi
+echo "MLN_DIR = $MLN_DIR" >> makefile.rules
\ No newline at end of file
Property changes on: trunk/milena/sandbox/edwin/rush/test/configure
___________________________________________________________________
Name: svn:executable
+ *
Index: trunk/milena/sandbox/edwin/rush/test/export.cc
===================================================================
--- trunk/milena/sandbox/edwin/rush/test/export.cc (revision 0)
+++ trunk/milena/sandbox/edwin/rush/test/export.cc (revision 3686)
@@ -0,0 +1,63 @@
+// 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.
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/neighb2d.hh>
+#include <mln/core/site_set/p_array.hh>
+
+#include <mln/level/sort_psites.hh>
+
+#include <mln/morpho/tree/data.hh>
+#include "../export_leaves.hh"
+
+#include <mln/io/pbm/save.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ typedef image2d<int> I;
+ typedef p_array<point2d> S;
+ typedef morpho::tree::data<I,S> tree_t;
+
+ int vals[] = {3, 3, 4,
+ 3, 5, 4,
+ 4, 4, 4 };
+
+ I ima = make::image2d(vals);
+ S s = level::sort_psites_decreasing(ima);
+ tree_t t(ima, s, c4());
+
+ export_leaves_to_file(t, ima);
+
+ typedef mln_ch_value_(I, bool) B;
+ B b_img = export_leaves_to_img(t, ima);
+
+ io::pbm::save(b_img, "leaves.pbm");
+}
Index: trunk/milena/sandbox/edwin/rush/test/Makefile
===================================================================
--- trunk/milena/sandbox/edwin/rush/test/Makefile (revision 0)
+++ trunk/milena/sandbox/edwin/rush/test/Makefile (revision 3686)
@@ -0,0 +1,41 @@
+include makefile.rules
+TARGET=export
+#sharp_SRC=sharp.cc
+#sharp_OBJS=${sharp_SRC:.cc=.o}
+
+export_SRC=export.cc
+export_OBJS=${export_SRC:.cc=.o}
+
+OLENADIR=$(MLN_DIR)/..
+MILENADIR=$(MLN_DIR)
+
+CXXFLAGS=-I$(MILENADIR) -I./ -W -Wall
+
+
+CXXFLAGS += $(if $(DEBUG), -g -ggdb, -DNDEBUG\
+ $(if $(RELEASE), -O3, -O1))
+
+CXX=g++
+LD=g++
+LDFLAGS=
+
+all: $(TARGET)
+
+
+$(TARGET): $($(TARGET)_OBJS) $($(TARGET)_SRC)
+ $(LD) $(LDFLAGS) -o $@ $($(TARGET)_OBJS)
+
+%.o: %.cc
+ $(CXX) $(CXXFLAGS) -c $<
+
+%.o: %.hh
+ $(CXX) $(CXXFLAGS) -c $<
+
+depend:
+ makedepend -- $(CXXFLAGS) -- -v $($(TARGET)_SRC)
+
+clean:
+ rm -f *.o $(TARGET)
+ #rm -f *.pbm
+ #find -name "*.pgm" \! -regex ".*/affiche2?.pgm" -delete
+# DO NOT DELETE
\ No newline at end of file
Index: trunk/milena/sandbox/edwin/rush/configure
===================================================================
--- trunk/milena/sandbox/edwin/rush/configure (revision 0)
+++ trunk/milena/sandbox/edwin/rush/configure (revision 3686)
@@ -0,0 +1,21 @@
+#! /bin/bash
+
+for arg in "$@"; do
+ if [ "$arg" == "--debug" ]; then
+ debug=1;
+ elif [ "$arg" == "--release" ]; then
+ release=1;
+ elif [ "${arg#--mln_dir=}" ]; then
+ MLN_DIR=${arg#--mln_dir=}
+ fi
+done
+
+rm -f makefile.rules
+touch makefile.rules
+if [ "$debug" ]; then
+ echo 'DEBUG = 1' >> makefile.rules
+fi
+if [ "$release" ]; then
+ echo 'RELEASE = 1' >> makefile.rules
+fi
+echo "MLN_DIR = $MLN_DIR" >> makefile.rules
\ No newline at end of file
Property changes on: trunk/milena/sandbox/edwin/rush/configure
___________________________________________________________________
Name: svn:executable
+ *
Index: trunk/milena/sandbox/edwin/rush/get_leaves.cc
===================================================================
--- trunk/milena/sandbox/edwin/rush/get_leaves.cc (revision 0)
+++ trunk/milena/sandbox/edwin/rush/get_leaves.cc (revision 3686)
@@ -0,0 +1,65 @@
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/neighb2d.hh>
+#include <mln/core/site_set/p_array.hh>
+
+#include <mln/level/sort_psites.hh>
+
+#include <mln/morpho/tree/data.hh>
+#include <mln/morpho/tree/compute_attribute_image.hh>
+#include "export_leaves.hh"
+
+#include <mln/morpho/attribute/sharpness.hh>
+
+#include <mln/io/pbm/save.hh>
+#include <mln/io/pgm/load.hh>
+
+#include <mln/value/int_u8.hh>
+
+#include <iostream>
+
+
+
+void usage(char** argv)
+{
+ std::cout << "Retrieve leaves of the component tree using sharpness"
+ << " attribute. It returns a binary image of leaves and creates"
+ << " txt file that contains nodes of the branch that the leaf belongs to."
+ << std::endl;
+ std::cout << "Usage: " << argv[0] << " input.pgm" << std::endl;
+ abort();
+}
+
+
+int main(int argc, char* argv[])
+{
+ using namespace mln;
+ using value::int_u8;
+
+ if (argc == 0)
+ usage(argv);
+
+
+ // Load a pgm img (Gray level Or Gradient Image)
+ typedef image2d<int_u8> I;
+ I input;
+ io::pgm::load(input, argv[1]);
+
+ // Tree Creation
+ typedef p_array<point2d> S;
+ typedef morpho::tree::data<I,S> tree_t;
+ S s = level::sort_psites_decreasing(input);
+ tree_t t(input, s, c4());
+
+ // Attribute pruning.
+ typedef morpho::attribute::sharpness<I> sharp_t;
+ typedef mln_ch_value_(I, double) A;
+
+ A a = morpho::tree::compute_attribute_image(sharp_t (), t);
+
+
+ //Export Leaves
+ typedef mln_ch_value_(I, bool) B;
+ B b_img = export_leaves_to_img(t, a);
+ io::pbm::save(b_img, "leaves.pbm");
+ export_leaves_to_file(t, a);
+}
Index: trunk/milena/sandbox/edwin/rush/splot.sh
===================================================================
--- trunk/milena/sandbox/edwin/rush/splot.sh (revision 0)
+++ trunk/milena/sandbox/edwin/rush/splot.sh (revision 3686)
@@ -0,0 +1,10 @@
+#! /bin/bash
+FILE=gplot.batch
+
+echo "set terminal png" > "$FILE"
+for f in *.txt; do
+ echo 'set output "'$f'.png"' >> "$FILE"
+ echo 'plot "'$f'"' >> "$FILE"
+done;
+
+gnuplot "$FILE"
\ No newline at end of file
Property changes on: trunk/milena/sandbox/edwin/rush/splot.sh
___________________________________________________________________
Name: svn:executable
+ *
Index: trunk/milena/sandbox/edwin/rush/chain.sh
===================================================================
--- trunk/milena/sandbox/edwin/rush/chain.sh (revision 0)
+++ trunk/milena/sandbox/edwin/rush/chain.sh (revision 3686)
@@ -0,0 +1,34 @@
+#! /bin/bash
+
+function usage()
+{
+echo "./chain.sh input.ppm (--graylevel | --gradient)"
+exit 2
+}
+
+if [ $# -ne 2 ]; then
+ usage
+fi
+
+if [ "$2" = "--gradient" ]; then
+ gradient=1
+elif [ "$2" = "--graylevel" ]; then
+ graylevel=1
+else
+ usage
+fi
+
+make leaves
+if [ "x$gradient" = "x1" ]; then
+ make all
+ name="gradient.pgm"
+ ./gradient "$1" "$name"
+else
+ name="$1"
+ name="${name%.ppm}.pgm"
+ convert +compress -depth 8 -colorspace Gray "$1" "$name"
+fi
+./leaves "$name"
+rm -Rf "$1".dir
+mkdir "$1".dir
+mv *.txt "leaves.pbm" "$name" "$1".dir
\ No newline at end of file
Property changes on: trunk/milena/sandbox/edwin/rush/chain.sh
___________________________________________________________________
Name: svn:executable
+ *
Index: trunk/milena/sandbox/edwin/rush/Makefile
===================================================================
--- trunk/milena/sandbox/edwin/rush/Makefile (revision 0)
+++ trunk/milena/sandbox/edwin/rush/Makefile (revision 3686)
@@ -0,0 +1,35 @@
+include makefile.rules
+
+
+OLENADIR=$(MLN_DIR)/..
+MILENADIR=$(MLN_DIR)
+
+CXXFLAGS = -I$(MILENADIR) -I./ -W -Wall
+CXXFLAGS += $(if $(DEBUG), -g -ggdb, -DNDEBUG\
+ $(if $(RELEASE), -O3, -O1))
+CXX=g++
+LD=g++
+LDFLAGS=
+SRC=
+
+
+GRADIENT_SRC = $(MLN_DIR)/sandbox/theo/exec/color_internal_gradient.cc
+LEAVES_SRC = get_leaves.cc
+
+
+all: leaves gradient
+
+
+leaves: $(LEAVES_SRC)
+ $(CXX) $(CXXFLAGS) $< -o leaves
+
+gradient: $(GRADIENT_SRC)
+ $(CXX) $(CXXFLAGS) $< -o gradient
+
+
+clean:
+ rm -f leaves gradient
+
+
+%.o: %.cc
+ $(CXX) $(CXXFLAGS) -c $<
\ No newline at end of file
Index: trunk/milena/sandbox/edwin/rush/export_leaves.hh
===================================================================
--- trunk/milena/sandbox/edwin/rush/export_leaves.hh (revision 0)
+++ trunk/milena/sandbox/edwin/rush/export_leaves.hh (revision 3686)
@@ -0,0 +1,115 @@
+// 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 EXPORT_LEAVES_HH_
+# define EXPORT_LEAVES_HH_
+
+# include <mln/core/concept/image.hh>
+
+# include <mln/morpho/tree/data.hh>
+# include "../tree/propagate.hh"
+
+
+# include <mln/data/fill.hh>
+
+# include <fstream>
+# include <sstream>
+
+namespace mln {
+
+ template <typename T, typename A>
+ inline
+ void
+ export_leaves_to_file(const T& tree, const Image<A>& attr_image);
+
+ template <typename T, typename A>
+ inline
+ mln_ch_value(A, bool)
+ export_leaves_to_img(const T& tree, const Image<A>& attr_image);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename T, typename A>
+ inline
+ void
+ export_leaves_to_file(const T& tree, const Image<A>& attr_image)
+ {
+ mln_precondition(tree.f().domain() == attr_image.domain());
+
+ const A& a = exact(attr_image);
+ mln_leaf_piter(T) leaf(tree);
+
+ for_all(leaf)
+ {
+ std::stringstream fn;
+ for (int i = 0; i < leaf.dim; i++)
+ fn << "[" << leaf[i] << "]";
+ fn << ".txt";
+
+ std::ofstream out(fn.str().c_str());
+ mln_psite(T) n = leaf;
+ int i = 0;
+ while (!tree.is_root(n))
+ {
+ out << i++ << " " << a(n) << std::endl;
+ n = tree.parent(n);
+ }
+ out << i << " " << a(n) << std::endl;
+ }
+ }
+
+ template <typename T, typename A>
+ inline
+ mln_ch_value(A, bool)
+ export_leaves_to_img(const T& tree, const Image<A>& attr_image)
+ {
+ mln_precondition(tree.f().domain() == attr_image.domain());
+
+ typedef mln_ch_value(A, bool) I;
+ const A& a = exact(attr_image);
+
+ I output;
+ initialize(output, a);
+ data::fill(output, false);
+
+ mln_leaf_piter(T) l(tree);
+ for_all(l)
+ output(l) = true;
+
+ morpho::tree::propagate_representant(tree, output);
+ return output;
+ }
+
+
+
+# endif /* !MLN_INCLUDE_ONLY */
+
+} // end of namespace mln
+
+#endif /* !EXPORT_LEAVES_HH_ */
#3: Migrate Olena 0.11 (and previous revisions) from PRCS to Git
--------------------------+-------------------------------------------------
Reporter: levill_r | Owner: levill_r
Type: enhancement | Status: reopened
Priority: blocker | Milestone: Olena 0.11.1
Component: other | Version: 0.11
Resolution: | Keywords: prcs subversion svn git
--------------------------+-------------------------------------------------
Changes (by levill_r):
* keywords: prcs subversion svn => prcs subversion svn git
* status: closed => reopened
* resolution: wontfix =>
Old description:
> '''No further development should be done on the 0.11 branch until this
> task is either fixed or removed.'''
>
> This task is an open discussion. I haven't much tried to convert the
> PRCS Olena repository to a Subversion one, and I think it '''is''' really
> feasible, though not trivial. If you're interested in this migration,
> please ask me (Roland) first before making actual changes to the PRCS or
> the SVN repository.
New description:
Use `prcs2git` (http://takaki-web.media-as.org/my_works/prcs2git) to
convert the old PRCS revisions of Olena to Git.
I (Roland) made an attempt and successfully converted the whole repository
(minus two bogus revisions, namely 10.138 and 10.139) by using it.
However there is room for improvement:
* ignoring revisions is not possible (there should be an option taking an
ignore pattern as argument)
* information about author and committer (name, e-mail, date) is not
propagated;
* log title (short messages) are filled with PRCS metadata (ugly!) ; we
should retrieve the title from somewhere (PRCS, the !ChangeLog(s) or even
the mailing list);
* log messages are meaningless.
Branches, however, have been well translated.
'''Remember that no further development should be done on the 0.11 branch
until this task is either fixed or removed.'''
--
Comment:
s/Subversion/Git/.
--
Ticket URL: <https://trac.lrde.org/olena/ticket/3#comment:8>
Olena <http://olena.lrde.epita.fr>
Olena, a generic and efficient C++ image processing library.
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2009-04-17 Edwin Carlinet <carlinet(a)lrde.epita.fr>
Remove check save + modification in compute attribute method.
* mln/io/pgm/save.hh: Remove static check unit_8 while saving pgm.
* mln/morpho/tree/compute_attribute_image.hh: Add extra
argument where the accumulator image will be store.
---
io/pgm/save.hh | 3 -
morpho/tree/compute_attribute_image.hh | 57 ++++++++++++++++++++++-----------
2 files changed, 38 insertions(+), 22 deletions(-)
Index: trunk/milena/mln/morpho/tree/compute_attribute_image.hh
===================================================================
--- trunk/milena/mln/morpho/tree/compute_attribute_image.hh (revision 3683)
+++ trunk/milena/mln/morpho/tree/compute_attribute_image.hh (revision 3684)
@@ -35,6 +35,7 @@
///
/// \todo Specialize for low quant (and try fastest).
+# include <mln/core/routine/duplicate.hh>
# include <mln/core/concept/image.hh>
# include <mln/morpho/tree/data.hh>
# include <mln/trait/accumulators.hh>
@@ -42,7 +43,6 @@
# include <mln/data/fill.hh>
-
namespace mln
{
@@ -52,25 +52,38 @@
namespace tree
{
- /// Compute a tree with a parent relationship between sites.
- ///
- /// Warning: \p s translates the ordering related to the
- /// "natural" childhood relationship. The parenthood is thus
- /// inverted w.r.t. to \p s.
- ///
- /// It is very convenient since all processing upon the parent
- /// tree are performed following \p s (in the default "forward"
- /// way).
- ///
- /// FIXME: Put it more clearly...
- ///
- /// The parent result image verifies: \n
- /// - p is root iff parent(p) == p \n
- /// - p is a node iff either p is root or f(parent(p)) != f(p).
-
+ /**
+ ** Compute an attribute image using tree with a parent
+ ** relationship between sites. In the attribute image, the
+ ** resulting value at a node is the 'sum' of its sub-components
+ ** value + the attribute value at this node.
+ **
+ ** Warning: \p s translates the ordering related to the
+ ** "natural" childhood relationship. The parenthood is thus
+ ** inverted w.r.t. to \p s.
+ **
+ ** It is very convenient since all processing upon the parent
+ ** tree are performed following \p s (in the default "forward"
+ ** way).
+ **
+ ** FIXME: Put it more clearly...
+ **
+ ** The parent result image verifies: \n
+ ** - p is root iff parent(p) == p \n
+ ** - p is a node iff either p is root or f(parent(p)) != f(p).
+ **
+ ** @param[in] a Attribute.
+ ** @param[in] t Component tree.
+ ** @param[out] accu_image Optional argument used to store image
+ ** of attribute accumulator.
+ **
+ ** @return The attribute image.
+ */
template <typename A, typename T>
mln_ch_value(typename T::function, mln_result(A))
- compute_attribute_image(const Accumulator<A>& a, const T& t);
+ compute_attribute_image(const Accumulator<A>& a,
+ const T& t,
+ mln_ch_value(typename T::function, A)* accu_image = 0);
@@ -121,7 +134,9 @@
template <typename A, typename T>
inline
mln_ch_value(typename T::function, mln_result(A))
- compute_attribute_image(const Accumulator<A>& a_, const T& t)
+ compute_attribute_image(const Accumulator<A>& a_,
+ const T& t,
+ mln_ch_value(typename T::function, A)* accu_image = 0)
{
trace::entering("morpho::tree::compute_attribute_image");
@@ -161,6 +176,10 @@
}
}
+ // Store accumulator image.
+ if (accu_image)
+ *accu_image = duplicate(acc);
+
typedef typename T::function I;
mln_ch_value(I, mln_result(A)) output;
initialize(output, acc);
Index: trunk/milena/mln/io/pgm/save.hh
===================================================================
--- trunk/milena/mln/io/pgm/save.hh (revision 3683)
+++ trunk/milena/mln/io/pgm/save.hh (revision 3684)
@@ -82,9 +82,6 @@
// FIXME: Is it exhaustive?
mlc_is_not_a(mln_value(I), value::Vectorial)::check();
mlc_converts_to(mln_value(I),unsigned)::check();
- /// Make sure this is a low quantification value type
- /// (mln_card returns 0 if it is not)
- metal::bool_<mln_card(mln_value(I)) != 0>::check();
trace::entering("mln::io::pgm::save");
io::pnm::save(PGM, exact(ima), filename);