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
24 Apr '09
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog:
2009-04-24 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Change data type, conversion to mln dump not yet effective.
* fabien/igr/mat2mln/raw2mlndata.cc: Change data type
(double -> int).
---
raw2mlndata.cc | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
Index: trunk/milena/sandbox/fabien/igr/mat2mln/raw2mlndata.cc
===================================================================
--- trunk/milena/sandbox/fabien/igr/mat2mln/raw2mlndata.cc (revision 3704)
+++ trunk/milena/sandbox/fabien/igr/mat2mln/raw2mlndata.cc (revision 3705)
@@ -4,6 +4,13 @@
#include <mln/core/image/image3d.hh>
#include <mln/io/dump/save.hh>
+#include <mln/io/pgm/save.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/level/stretch.hh>
+#include <mln/core/image/slice_image.hh>
+#include <mln/core/routine/duplicate.hh>
+#include <mln/core/image/image2d.hh>
+
using namespace mln;
@@ -11,7 +18,7 @@
{
if (argc != 3)
{
- std::cout << "Usage: " << argv[0] << " input.raw output.raw" << std::endl;
+ std::cout << "Usage: " << argv[0] << " input.raw output.dump" << std::endl;
return 1;
}
@@ -99,7 +106,7 @@
std::cout << "ncols: " << ncols << "; nrows: " << nrows << "; nslis: " << nslis << std::endl;
// Data buffer.
- typedef double V;
+ typedef int V;
int data_size = ncols * nrows * nslis;
V* data_buffer = new V[data_size];
input.seekg(offset);
@@ -109,5 +116,10 @@
memcpy(ima.buffer(), data_buffer, data_size);
io::dump::save(ima, argv[2]);
+ // Debug.
+ image2d<V> ima_debug;
+ ima_debug = duplicate(slice(ima, 50));
+ io::pgm::save(level::stretch(value::int_u8(), ima_debug), "debug.pgm");
+
return 0;
}
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog:
2009-04-24 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Add binary tools for parsing of .mat files.
* fabien/igr/mat2mln/mat2raw.cc: Uncompress .mat data.
* fabien/igr/mat2mln/raw2mlndata.cc: Convert uncompressed .mat data
to Milena dump format.
* fabien/igr/seg_fixed.cc: Creation of edges between pixels.
---
TODO | 4 +
igr/mat2mln/mat2raw.cc | 52 ++++++++++++++++++++
igr/mat2mln/raw2mlndata.cc | 113 +++++++++++++++++++++++++++++++++++++++++++++
igr/seg_fixed.cc | 25 ++++++---
4 files changed, 184 insertions(+), 10 deletions(-)
Index: trunk/milena/sandbox/fabien/igr/seg_fixed.cc
===================================================================
--- trunk/milena/sandbox/fabien/igr/seg_fixed.cc (revision 3703)
+++ trunk/milena/sandbox/fabien/igr/seg_fixed.cc (revision 3704)
@@ -59,6 +59,8 @@
res += std::min(ima_arr(p)[i], ima_arr(n)[i]);
res /= std::max(ima_sum(p), ima_sum(n));
+ std::cout << "dist = " << res << std::endl;
+
return res;
}
@@ -87,15 +89,21 @@
initialize(ima_sum, ima_arr);
compute_sum_arrays(ima_sum, ima_arr);
+ std::cout << "can i has a loop?" << std::endl;
mln_piter(image2d<util::array<I> >) p(ima_arr.domain());
- mln_niter(neighb2d) n(c4(), p);
for_all(p)
+ {
+ std::cout << "for_all(p)" << std::endl;
+ mln_niter(neighb2d) n(c4(), p);
for_all(n)
{
+ std::cout << "for_all(n)" << std::endl;
point2d location = get_edge_location(p, n);
- if (edges(location) != -1)
+ std::cout << "location = " << p << " && edge = " << edges(location) << std::endl;
+ if (edges(location) == -1.f)
edges(location) = compute_dist(ima_arr, ima_sum, p, n);
}
+ }
return edges;
}
@@ -112,23 +120,22 @@
int main(int argc, char* argv[])
{
- typedef int_u12 I;
-
if (argc != 2)
return usage(argv[0]);
- image3d<I> input;
- io::dump::save(input, argv[1]);
- image2d<util::array<I> > ima_arr;
+ image3d<int_u12> input;
+ io::dump::load(input, argv[1]);
+ image2d<util::array<int_u12> > ima_arr;
initialize(ima_arr, slice(input, 0));
for (unsigned int i = 0; i < input.nslices(); ++i)
{
- image2d<I> tmp_slice = duplicate(slice(input, i));
- mln_piter_(image2d<I>) p(tmp_slice.domain());
+ image2d<int_u12> tmp_slice = duplicate(slice(input, i));
+ mln_piter_(image2d<int_u12>) p(tmp_slice.domain());
for_all(p)
ima_arr(p).append(tmp_slice(p));
}
+ std::cout << "ho hai _o/" << std::endl;
image2d<float> edges = dist_on_edges(ima_arr);
return 0;
Index: trunk/milena/sandbox/fabien/igr/mat2mln/raw2mlndata.cc
===================================================================
--- trunk/milena/sandbox/fabien/igr/mat2mln/raw2mlndata.cc (revision 0)
+++ trunk/milena/sandbox/fabien/igr/mat2mln/raw2mlndata.cc (revision 3704)
@@ -0,0 +1,113 @@
+#include <iostream>
+#include <fstream>
+
+#include <mln/core/image/image3d.hh>
+#include <mln/io/dump/save.hh>
+
+using namespace mln;
+
+
+int main(int argc, char* argv[])
+{
+ if (argc != 3)
+ {
+ std::cout << "Usage: " << argv[0] << " input.raw output.raw" << std::endl;
+ return 1;
+ }
+
+ std::ifstream input(argv[1]);
+
+ unsigned int size = 0;
+ unsigned int offset = 0;
+
+ // Top level miMATRIX.
+ offset += 4;
+ input.seekg(offset);
+ input.read((char*) &size, sizeof (unsigned int));
+ offset += sizeof (unsigned int);
+ std::cout << "Size: " << size << std::endl;
+
+ // Array flags.
+ offset += 4;
+ input.seekg(offset);
+ input.read((char*) &size, sizeof (unsigned int));
+ offset += sizeof (unsigned int);
+ std::cout << "Flags size: " << size << std::endl;
+
+ // Dimensions array.
+ offset += size;
+ offset += 4;
+ input.seekg(offset);
+ input.read((char*) &size, sizeof (unsigned int));
+ offset += sizeof (unsigned int);
+ std::cout << "Dimensions size: " << size << std::endl;
+
+ // Array name.
+ offset += size;
+ offset += 4;
+ input.seekg(offset);
+ input.read((char*) &size, sizeof (unsigned int));
+ offset += sizeof (unsigned int);
+ std::cout << "Name size: " << size << std::endl;
+ char* name = new char[size + 1];
+ input.seekg(offset);
+ input.read((char*) name, size);
+ name[size + 1] = '\0';
+ std::cout << "Array name: " << name << std::endl;
+ delete name;
+ offset += 8 - size % 8;
+
+ std::cout << "----" << std::endl;
+ // FIXME: Decode data.
+
+ offset = 128;
+
+ // Data miMATRIX.
+ offset += 4;
+ input.seekg(offset);
+ input.read((char*) &size, sizeof (unsigned int));
+ offset += sizeof (unsigned int);
+ std::cout << "Data size: " << size << std::endl;
+
+ // Array flags.
+ offset += 4;
+ input.seekg(offset);
+ input.read((char*) &size, sizeof (unsigned int));
+ offset += sizeof (unsigned int);
+ std::cout << "Flags size: " << size << std::endl;
+
+ // Dimensions array.
+ offset += size;
+ offset += 4;
+ input.seekg(offset);
+ input.read((char*) &size, sizeof (unsigned int));
+ offset += sizeof (unsigned int);
+ std::cout << "Dimensions size: " << size << std::endl;
+ std::cout << "Number of dimensions: " << size / 4 << std::endl;
+ int ncols = 0;
+ int nrows = 0;
+ int nslis = 0;
+ input.seekg(offset);
+ input.read((char*) &ncols, sizeof (unsigned int));
+ offset += sizeof (unsigned int);
+ input.seekg(offset);
+ input.read((char*) &nrows, sizeof (unsigned int));
+ offset += sizeof (unsigned int);
+ input.seekg(offset);
+ input.read((char*) &nslis, sizeof (unsigned int));
+ offset += sizeof (unsigned int);
+ std::cout << "ncols: " << ncols << "; nrows: " << nrows << "; nslis: " << nslis << std::endl;
+
+ // Data buffer.
+ typedef double V;
+ int data_size = ncols * nrows * nslis;
+ V* data_buffer = new V[data_size];
+ input.seekg(offset);
+ input.read((char*) data_buffer, data_size);
+
+ image3d<V> ima(nslis, nrows, ncols);
+ memcpy(ima.buffer(), data_buffer, data_size);
+ io::dump::save(ima, argv[2]);
+
+ return 0;
+}
Index: trunk/milena/sandbox/fabien/igr/mat2mln/mat2raw.cc
===================================================================
--- trunk/milena/sandbox/fabien/igr/mat2mln/mat2raw.cc (revision 0)
+++ trunk/milena/sandbox/fabien/igr/mat2mln/mat2raw.cc (revision 3704)
@@ -0,0 +1,52 @@
+#include <iostream>
+#include <fstream>
+
+#include <zlib.h>
+
+int main(int argc, char* argv[])
+{
+ if (argc != 3)
+ {
+ std::cout << "Usage: " << argv[0] << " input.mat output.raw" << std::endl;
+ return 1;
+ }
+
+ std::ifstream input(argv[1]);
+
+ // Fetch data.
+ unsigned int size;
+ input.seekg(132);
+ input.read((char*) &size, sizeof(unsigned int));
+ std::cout << "Size: " << size << std::endl;
+ unsigned char* data_buffer = new unsigned char[size];
+ input.read((char*) data_buffer, size);
+ input.close();
+
+ // Decompress.
+ unsigned long dest_size = 2 * size;
+ unsigned char* dest_buffer = new unsigned char[dest_size];
+ int dezip_result = uncompress(dest_buffer, &dest_size, data_buffer, size);
+
+ switch (dezip_result)
+ {
+ case Z_OK:
+ std::cout << "Z_OK" << std::endl;
+ std::cout << "Dest size: " << dest_size << std::endl;
+ break;
+ case Z_MEM_ERROR:
+ std::cout << "Z_MEM_ERROR" << std::endl;
+ break;
+ case Z_BUF_ERROR:
+ std::cout << "Z_BUF_ERROR" << std::endl;
+ break;
+ case Z_DATA_ERROR:
+ std::cout << "Z_DATA_ERROR" << std::endl;
+ break;
+ }
+
+ // Write buffer to disk.
+ std::ofstream save_file(argv[2]);
+ save_file.write((char*) dest_buffer, dest_size);
+
+ return 0;
+}
Index: trunk/milena/sandbox/fabien/TODO
===================================================================
--- trunk/milena/sandbox/fabien/TODO (revision 3703)
+++ trunk/milena/sandbox/fabien/TODO (revision 3704)
@@ -49,7 +49,7 @@
[X] Fix spatial smooth
[X] Crop volume 52
[X] Plot all labels (3, 4 labels for tumeur)
-[ ] Prepare data for IGR
+[X] Prepare data for IGR
[X] crop->norm->tmax
[X] crop->norm->space_smooth->tmax
@@ -64,3 +64,5 @@
[X] fausses couleurs watershed
[X] images moyennes
+[ ] Watershed between pixels
+[ ] Mat2Mln
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog:
2009-04-22 Edwin Carlinet <carlinet(a)lrde.epita.fr>
Granulometry tests.
* edwin/rush/exo2/test.cc: Experimentation related to sharpness.
* edwin/rush/exo2/wst_from_tree.cc: Fix bugs linked to
sharpness attribute.
* edwin/rush/granulometry/granulometry.hh: Compute curve
number of components / attribute value.
* edwin/rush/granulometry/test.cc: Test file for granulometry.
* edwin/rush/granulometry: New.
* edwin/tree/components.hh: Minor fixes.
* edwin/tree/propagate.hh: Minor fixes.
---
rush/exo2/Makefile | 2
rush/exo2/test.cc | 131 +++++++++++++++++++++++++++++++++
rush/exo2/wst_from_tree.cc | 2
rush/granulometry/Makefile | 36 +++++++++
rush/granulometry/granulometry.hh | 149 ++++++++++++++++++++++++++++++++++++++
rush/granulometry/test.cc | 107 +++++++++++++++++++++++++++
tree/components.hh | 4 -
tree/propagate.hh | 8 +-
8 files changed, 431 insertions(+), 8 deletions(-)
Index: trunk/milena/sandbox/edwin/tree/propagate.hh
===================================================================
--- trunk/milena/sandbox/edwin/tree/propagate.hh (revision 3698)
+++ trunk/milena/sandbox/edwin/tree/propagate.hh (revision 3699)
@@ -77,16 +77,16 @@
const p_array< mln_psite(A) >& component_list,
const mln_value(A)& null)
{
- const A& attr_img = exact(attr_image);
+ const A& a = exact(attr_image);
A out;
- initialize(out, attr_img);
+ initialize(out, a);
data::fill(out, null);
mln_piter(p_array<mln_psite(A)>) p(component_list);
for_all(p)
{
- out(p) = attr_img(p);
- morpho::tree::propagate_node_to_descendants(p, tree, out);
+ out(p) = a(p);
+ morpho::tree::propagate_node_to_descendants(p, tree, out, a(p));
}
morpho::tree::propagate_representant(tree, out);
return out;
Index: trunk/milena/sandbox/edwin/tree/components.hh
===================================================================
--- trunk/milena/sandbox/edwin/tree/components.hh (revision 3698)
+++ trunk/milena/sandbox/edwin/tree/components.hh (revision 3699)
@@ -222,7 +222,7 @@
p_array< mln_psite(A) > components;
mln_ch_value(A, bool) activity;
p_array< mln_psite(A) > max_arr = tree.nodes();
- unsigned arr_pos; //position in max_array
+ unsigned arr_pos = 0; //position in max_array
unsigned n = 0;
unsigned* nb_leaves = uses_leaves ? new unsigned(0) : 0;
@@ -237,7 +237,7 @@
p = max_arr[arr_pos];
if (a(p) == 0)
break;
- //std::cout << p << " " << a(p) << std::endl;
+ std::cout << p << " " << a(p) << std::endl;
components.insert(p);
morpho::tree::propagate_node_to_descendants(p, tree, activity, false, nb_leaves);
morpho::tree::propagate_node_to_ancestors(p, tree, activity, false);
Index: trunk/milena/sandbox/edwin/rush/granulometry/test.cc
===================================================================
--- trunk/milena/sandbox/edwin/rush/granulometry/test.cc (revision 0)
+++ trunk/milena/sandbox/edwin/rush/granulometry/test.cc (revision 3699)
@@ -0,0 +1,107 @@
+// 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 "granulometry.hh"
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/neighb2d.hh>
+#include <mln/value/int_u8.hh>
+
+#include <mln/io/pgm/load.hh>
+
+#include <mln/level/sort_psites.hh>
+#include <mln/morpho/tree/data.hh>
+#include <mln/morpho/tree/compute_attribute_image.hh>
+#include <mln/morpho/attribute/card.hh>
+
+#include <mln/data/fill.hh>
+#include "../../tree/propagate_node.hh"
+
+#include <iostream>
+#include <map>
+
+void usage(char** argv)
+{
+ 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 != 2)
+ usage(argv);
+
+ typedef image2d<int_u8> I;
+ I input;
+ io::pgm::load(input, argv[1]);
+
+ typedef p_array<point2d> S;
+ typedef morpho::tree::data<I,S> tree_t;
+
+ S s = level::sort_psites_decreasing(input);
+ tree_t tree(input, s, c4());
+
+ typedef mln_ch_value_(I, unsigned) A;
+ typedef morpho::attribute::card<I> card_t;
+ A a = morpho::tree::compute_attribute_image(card_t (), tree);
+
+
+
+ {
+ typedef std::map<mln_value_(A), unsigned> F;
+ F f = morpho::tree::compute_attribute_curve_beta(tree, a);
+
+ unsigned count;
+ mln_ch_value_(A, bool) activity;
+ initialize(activity, a);
+ F::iterator it;
+ for (it = f.begin(); it != f.end(); ++it)
+ {
+ mln_up_node_piter_(tree_t) n(tree);
+ data::fill(activity, true);
+ count = 0;
+ for_all(n)
+ if (a(n) >= it->first && activity(n))
+ {
+ morpho::tree::propagate_node_to_ancestors(n, tree, activity, false);
+ count++;
+ }
+
+ std::cout << it->first << " -> " << it->second << " = " << count
+ << std::endl;
+ mln_assertion(count == it->second);
+ }
+ }
+
+
+}
+
+
Index: trunk/milena/sandbox/edwin/rush/granulometry/granulometry.hh
===================================================================
--- trunk/milena/sandbox/edwin/rush/granulometry/granulometry.hh (revision 0)
+++ trunk/milena/sandbox/edwin/rush/granulometry/granulometry.hh (revision 3699)
@@ -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 GRANULOMETRY_HH_
+# define GRANULOMETRY_HH_
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/site_set/p_array.hh>
+# include <mln/morpho/tree/data.hh>
+
+# include <queue>
+# include <map>
+
+namespace mln {
+ namespace morpho {
+ namespace tree {
+
+
+ template <typename T, typename A>
+ inline
+ std::map<mln_value(A), unsigned>
+ compute_attribute_curve_beta(const T& tree, const Image<A>& attr_img);
+
+
+ template <typename T, typename A>
+ inline
+ std::map<mln_value(A), unsigned>
+ compute_attribute_curve(const T& tree, const Image<A>& attr_img);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace internal {
+
+ template <typename A>
+ struct attr_less
+ {
+ attr_less(const A& f)
+ : f_ (f)
+ {
+ }
+
+ bool operator () (const mln_psite(A)& a, const mln_psite(A)& b) const
+ {
+ return (f_(a) < f_(b));
+ }
+
+ private:
+ const A& f_;
+ };
+
+
+ }
+
+ template <typename T, typename A>
+ inline
+ std::map<mln_value(A), unsigned>
+ compute_attribute_curve(const T& tree, const Image<A>& attr_img)
+ {
+ const A& a = exact(attr_img);
+
+ std::map< mln_value(A), unsigned > f;
+ mln_node_piter(T) n(tree);
+
+ for_all(n)
+ f[a(n)]++;
+
+
+ return f;
+ }
+
+
+ template <typename T, typename A>
+ inline
+ std::map<mln_value(A), unsigned>
+ compute_attribute_curve_beta(const T& tree, const Image<A>& attr_img)
+ {
+ const A& a = exact(attr_img);
+
+ // TODO: precondition attribut croissant
+
+
+ typedef std::priority_queue< mln_psite(A), std::vector< mln_psite(A) >, internal::attr_less<A> > q_type;
+ std::map< mln_value(A), unsigned > f;
+ internal::attr_less<A> cmp(a);
+ q_type pqueue(cmp);
+ unsigned active_components = 1;
+
+ pqueue.push(tree.nodes()[tree.nodes().nsites() - 1]);
+
+ // TODO: push other roots
+
+ while (!pqueue.empty())
+ {
+ mln_value(A) node_v = a(pqueue.top());
+ mln_psite(A) node;
+ std::cout << pqueue.top() << " : " << node_v << std::endl;
+ f[node_v] = pqueue.size();
+ do {
+ ++active_components;
+ node = pqueue.top();
+ pqueue.pop();
+
+ mln_piter(p_array< mln_psite(A) >) child(tree.children(node));
+ for_all(child)
+ {
+ pqueue.push(child);
+ }
+ } while (!pqueue.empty() && a(pqueue.top()) == node_v);
+ }
+ // TODO: postcondition decroissant
+ return f;
+ }
+
+
+# endif /* !MLN_INCLUDE_ONLY */
+
+
+ } // end of namespace mln::morpho::tree
+ } // end of namespace mln::morpho
+} // end of namespace mln
+
+
+#endif /* !GRANULOMETRY_HH_ */
Index: trunk/milena/sandbox/edwin/rush/granulometry/Makefile
===================================================================
--- trunk/milena/sandbox/edwin/rush/granulometry/Makefile (revision 0)
+++ trunk/milena/sandbox/edwin/rush/granulometry/Makefile (revision 3699)
@@ -0,0 +1,36 @@
+include makefile.rules
+TARGET=test
+
+test_SRC=test.cc
+test_OBJS=${test_SRC:.cc=.o}
+
+OLENADIR=$(MLN_DIR)/..
+MILENADIR=$(OLENADIR)/milena
+
+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)
Index: trunk/milena/sandbox/edwin/rush/exo2/test.cc
===================================================================
--- trunk/milena/sandbox/edwin/rush/exo2/test.cc (revision 0)
+++ trunk/milena/sandbox/edwin/rush/exo2/test.cc (revision 3699)
@@ -0,0 +1,131 @@
+#include <mln/morpho/attribute/volume.hh>
+#include <mln/morpho/attribute/height.hh>
+#include <mln/morpho/attribute/sharpness.hh>
+#include <mln/morpho/tree/data.hh>
+#include <mln/morpho/tree/compute_attribute_image.hh>
+#include <mln/level/sort_psites.hh>
+#include <mln/debug/println.hh>
+
+#include <mln/convert/all.hh>
+
+#include <mln/core/image/image1d.hh>
+#include <mln/core/alias/neighb1d.hh>
+#include <mln/value/int_u8.hh>
+
+#include "../../tree/components.hh"
+#include "../../tree/propagate.hh"
+
+#include <mln/fun/p2v/ternary.hh>
+#include <mln/pw/all.hh>
+
+namespace mln
+{
+ // Sharpness Attribute -> Height Attribute
+ template <typename P2V>
+ struct height_wrapper_ : Function_p2v< height_wrapper_<P2V> >
+ {
+ typedef unsigned result;
+
+ height_wrapper_(const Function_p2v<P2V>& f) :
+ f_ (exact(f))
+ {
+ mlc_is_a(mln_result(P2V), Accumulator)::check();
+ }
+
+ template <typename P>
+ unsigned operator() (const P& p) const
+ {
+ return f_(p).height();
+ }
+
+ private:
+ const P2V& f_;
+ };
+
+ // meta
+ template <typename P2V>
+ inline
+ height_wrapper_<P2V>
+ height_wrapper(const Function_p2v<P2V>& f)
+ {
+ return height_wrapper_<P2V>(f);
+ }
+}
+
+
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+
+ const char arr[]= { 16, 0, 0, 0, 0, 15, 0, 14, 0, 0, 0, 16 };
+
+
+ typedef image1d<int_u8> I;
+ I input;
+ convert::from_to(arr, input);
+
+
+ /***************************/
+ /* Component tree creation */
+ /***************************/
+ typedef p_array<point1d> S;
+ typedef morpho::tree::data<I,S> tree_t;
+
+ S s = level::sort_psites_decreasing(input);
+ tree_t t(input, s, c2());
+
+
+ /******************************/
+ /* Compute Attribute On Image */
+ /******************************/
+ {
+ typedef mln_ch_value_(I, unsigned) A;
+ typedef morpho::attribute::volume<I> attribute_t;
+ A a;
+
+ // Attribute Pruning
+ a = morpho::tree::compute_attribute_image(attribute_t (), t);
+ debug::println("volume", a);
+ }
+
+ mln_ch_value_(I, unsigned) height;
+ {
+ typedef mln_ch_value_(I, unsigned) A;
+ typedef morpho::attribute::height<I> attribute_t;
+
+ // Attribute Pruning
+ height = morpho::tree::compute_attribute_image(attribute_t (), t);
+ debug::println("height", height);
+ }
+
+ {
+ typedef mln_ch_value_(I, double) A;
+ typedef morpho::attribute::sharpness<I> attribute_t;
+ A a, component_img;
+
+ // Attribute Pruning
+ a = morpho::tree::compute_attribute_image(attribute_t (), t);
+ debug::println("sharpness", a);
+
+ // Component filtering
+ a = duplicate((fun::p2v::ternary(pw::value(height) > pw::cst(2),
+ pw::value(a),
+ pw::cst(0.0))) | a.domain());
+
+ debug::println("sharpness", a);
+
+
+ p_array< mln_psite_(A) > obj_array;
+ obj_array = morpho::tree::get_components(t, a);
+ std::cout << obj_array.nsites() << std::endl;
+
+ component_img = morpho::tree::propagate_components(a, t, obj_array, 0);
+
+ debug::println("sharpness", component_img);
+ }
+
+
+}
Property changes on: trunk/milena/sandbox/edwin/rush/exo2/test.cc
___________________________________________________________________
Name: svn:executable
+ *
Index: trunk/milena/sandbox/edwin/rush/exo2/wst_from_tree.cc
===================================================================
--- trunk/milena/sandbox/edwin/rush/exo2/wst_from_tree.cc (revision 3698)
+++ trunk/milena/sandbox/edwin/rush/exo2/wst_from_tree.cc (revision 3699)
@@ -200,7 +200,7 @@
obj_array = morpho::tree::get_components(t, a);
std::cout << obj_array.nsites() << std::endl;
- component_img = morpho::tree::propagate_components(a, t, obj_array, 1);
+ component_img = morpho::tree::propagate_components(a, t, obj_array, 1.1);
// debug
//I output = level::stretch(int_u8(), component_img); //adapt to 0-255
Index: trunk/milena/sandbox/edwin/rush/exo2/Makefile
===================================================================
--- trunk/milena/sandbox/edwin/rush/exo2/Makefile (revision 3698)
+++ trunk/milena/sandbox/edwin/rush/exo2/Makefile (revision 3699)
@@ -13,7 +13,7 @@
SRC=
OUT_IMG=superpose.pgm mean.pgm gradient.pgm closing.pgm
-BIN=wst_from_closing wst_from_tree
+BIN=wst_from_closing wst_from_tree test
all: $(BIN)
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog:
2009-04-21 Warren Seine <soow(a)lrde.epita.fr>
inim: Implement line detection with boxes.
Does not actually output the image.
* boxes.cc: Add debug code and ugly implementation.
---
boxes.cc | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 102 insertions(+), 4 deletions(-)
Index: trunk/milena/sandbox/inim/2010/boxes/boxes.cc
===================================================================
--- trunk/milena/sandbox/inim/2010/boxes/boxes.cc (revision 3696)
+++ trunk/milena/sandbox/inim/2010/boxes/boxes.cc (revision 3697)
@@ -32,6 +32,7 @@
#include <mln/debug/println.hh>
#include <scribo/text/extract_bboxes.hh>
+#include <scribo/text/grouping/group_from_single_link.hh>
#include <scribo/text/grouping/group_with_single_left_link.hh>
#include <scribo/text/grouping/group_with_single_right_link.hh>
#include <scribo/debug/save_linked_textbboxes_image.hh>
@@ -47,6 +48,7 @@
#include <mln/io/pgm/save.hh>
#include <mln/fun/l2l/wrap.hh>
+#include <mln/math/abs.hh>
int usage(const char *name)
{
@@ -54,28 +56,61 @@
return 1;
}
-
-int main(int argc, char* argv[])
-{
using namespace scribo;
using namespace mln;
+typedef image2d<value::label_16> scribo_image;
+
+template< typename T >
+double vec_y_norm(const T& t)
+{
+ return mln::math::abs(t[1] / t[0]);
+}
+
+template< typename T >
+double bboxes_y_mean(const T& bboxes)
+{
+ double mean = 0.;
+
+ for (unsigned i = 1; i < bboxes.nelements(); i++)
+ {
+ mln_VAR(s, bboxes[i].pmax() - bboxes[i].pmin());
+ mean += (s[1] / s[0]);
+ }
+
+ mean /= static_cast<double>(bboxes.nelements());
+
+ return mean;
+}
+
+int main(int argc, char* argv[])
+{
if (argc != 3)
return usage(argv[0]);
scribo::make::internal::debug_filename_prefix = "extract_text_double_link";
+ std::cout << "Debug 1" << std::endl;
+
image2d<bool> input;
io::pbm::load(input, argv[1]);
+ std::cout << "Debug 2" << std::endl;
+
logical::not_inplace(input);
+ std::cout << "Debug 3" << std::endl;
+
value::label_16 nbboxes;
scribo::util::text<image2d<value::label_16> >
text = text::extract_bboxes(input, c8(), nbboxes);
+ std::cout << "Debug 4" << std::endl;
+
text = filter::small_components(text,4);
+ std::cout << "Debug 5" << std::endl;
+
mln::util::array<unsigned>
left_link = text::grouping::group_with_single_left_link(text, 30),
right_link = text::grouping::group_with_single_right_link(text, 30);
@@ -83,14 +118,19 @@
std::cout << "BEFORE - nbboxes = " << nbboxes << std::endl;
+ std::cout << "Debug 6" << std::endl;
+
scribo::debug::save_linked_textbboxes_image(input,
text, left_link, right_link,
literal::red, literal::cyan, literal::yellow,
literal::green,
scribo::make::debug_filename("links.ppm"));
+ std::cout << "Debug 7" << std::endl;
+
// Validation.
- scribo::util::text<image2d<value::label_16> > grouped_text
+
+ scribo::util::text< scribo_image > grouped_text
= text::grouping::group_from_double_link(text, left_link, right_link);
std::cout << "AFTER double grouping - nbboxes = " << grouped_text.bboxes().nelements() << std::endl;
@@ -101,9 +141,67 @@
fun::l2l::wrap<value::int_u8>()),
"tmp.pgm");
+ std::cout << "Debug 8" << std::endl;
+
+
+
+
+
+
+
+ mln_VAR(b, grouped_text.bboxes());
+ std::cout << "Bounding boxes: " << std::endl << b << std::endl;
+
+ mln_VAR(m, grouped_text.mass_centers());
+ std::cout << "Mass centers: " << std::endl << m << std::endl;
+
+ // Mean of the y components of the bounding boxes
+ double mean = bboxes_y_mean(b);
+ std::cout << "Mean: " << mean << std::endl;
+
+ mln::util::array< unsigned > lines(m.size());
+
+ // Suppose that every component is on a different line
+ for (unsigned i = 1; i < m.size(); i++)
+ lines[i] = i;
+
+ // Merge the lines if they are too close
+ for (unsigned i = 1; i < m.size(); i++)
+ for (unsigned j = i + 1; j < m.size(); j++)
+ {
+ if (i == j)
+ continue;
+
+ double y_norm_diff = vec_y_norm(m[j] - m[i]);
+// std::cout << "y_norm_diff: " << y_norm_diff << std::endl;
+ if (y_norm_diff > 1000)
+ {
+ std::cout << "(" << i << "," << j << ")" << std::endl;
+ continue;
+ }
+ if (y_norm_diff < mean * 2)
+ {
+ lines[j] = lines[i];
+// std::cout << "Associating " << i << " to " << j << std::endl;
+ }
+ }
+
+ std::cout << "Lines: " << std::endl << lines << std::endl;
+
+// scribo::util::text< scribo_image > grouped_lines
+// = text::grouping::group_from_single_link(text, lines);
+
+
+
+
+
+
+
+
scribo::debug::save_textbboxes_image(input, grouped_text.bboxes(),
literal::red,
scribo::make::debug_filename("boxes.ppm"));
+ std::cout << "Debug 9" << std::endl;
}
--
:: Warren Seine // SooW ::
:: warren.seine @ gmail.com ::
:: EPITA CSI 2010 ::
1
0
21 Apr '09
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog:
2009-04-21 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Various update for IGR demo and new fixed segmentation.
* fabien/igr/Makefile: Add 'seg_fixed' target.
* fabien/igr/check.sh: Update.
* fabien/igr/fun_labels.cc: Update.
* fabien/igr/fun_labels.sh: Update.
* fabien/igr/med.cc: Update.
* fabien/igr/norm.cc: Update.
* fabien/igr/seg_fixed.cc: New.
* fabien/igr/space_smooth/Makefile: Update.
* fabien/igr/space_smooth/linear.cc: Update.
* fabien/igr/thres.cc: Update.
* fabien/igr/time_max_norm.cc: New tool for tmax map.
* fabien/igr/time_smooth/Makefile: Update.
* fabien/igr/time_smooth/linear.cc: Update.
---
TODO | 18 +++++-
igr/Makefile | 12 +++-
igr/check.sh | 11 ++-
igr/fun_labels.cc | 36 ++++++------
igr/fun_labels.sh | 36 +++++++++---
igr/med.cc | 15 ++---
igr/norm.cc | 14 +---
igr/seg_fixed.cc | 135 +++++++++++++++++++++++++++++++++++++++++++++
igr/space_smooth/Makefile | 2
igr/space_smooth/linear.cc | 21 ++++---
igr/thres.cc | 2
igr/time_max_norm.cc | 116 ++++++++++++++++++++++++++++++++++++++
igr/time_smooth/Makefile | 2
igr/time_smooth/linear.cc | 42 ++++++++++----
14 files changed, 388 insertions(+), 74 deletions(-)
Index: trunk/milena/sandbox/fabien/igr/seg_fixed.cc
===================================================================
--- trunk/milena/sandbox/fabien/igr/seg_fixed.cc (revision 0)
+++ trunk/milena/sandbox/fabien/igr/seg_fixed.cc (revision 3695)
@@ -0,0 +1,135 @@
+#include <algorithm>
+
+#include <mln/core/image/image1d.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/neighb2d.hh>
+#include <mln/core/image/image3d.hh>
+#include <mln/core/image/slice_image.hh>
+#include <mln/core/routine/duplicate.hh>
+
+#include <mln/io/dump/all.hh>
+
+#include <mln/value/int_u12.hh>
+
+#include <mln/accu/sum.hh>
+#include <mln/data/fill.hh>
+#include <mln/convert/from_to.hh>
+#include <mln/level/compute.hh>
+#include <mln/util/array.hh>
+
+
+using namespace mln;
+using value::int_u12;
+
+
+
+inline
+point2d
+get_edge_location(point2d p, point2d n)
+{
+ point2d res(p);
+
+ res.to_vec()[0] *= 2;
+ res.to_vec()[1] *= 2;
+
+ if (n.to_vec()[0] > p.to_vec()[0])
+ ++(res.to_vec()[0]);
+ if (n.to_vec()[0] < p.to_vec()[0])
+ --(res.to_vec()[0]);
+
+ if (n.to_vec()[1] > p.to_vec()[1])
+ ++(res.to_vec()[1]);
+ if (n.to_vec()[1] < p.to_vec()[1])
+ --(res.to_vec()[1]);
+
+ return res;
+}
+
+
+template <typename I>
+inline
+float
+compute_dist(image2d<util::array<I> > ima_arr,
+ image2d<float> ima_sum,
+ point2d p, point2d n)
+{
+ float res = 0.f;
+
+ for (unsigned i = 0; i < ima_arr(p).nelements(); ++i)
+ res += std::min(ima_arr(p)[i], ima_arr(n)[i]);
+ res /= std::max(ima_sum(p), ima_sum(n));
+
+ return res;
+}
+
+template <typename I>
+inline
+void
+compute_sum_arrays(image2d<float> ima_sum, image2d<util::array<I> > ima_arr)
+{
+ mln_piter(image2d<float>) p(ima_sum.domain());
+ for_all(p)
+ {
+ image1d<I> tmp_ima;
+ convert::from_to(ima_arr(p), tmp_ima);
+ accu::sum<I> accu_sum;
+ ima_sum(p) = level::compute(accu_sum, tmp_ima);
+ }
+}
+
+template <typename I>
+image2d<float>
+dist_on_edges(image2d<util::array<I> > ima_arr)
+{
+ image2d<float> edges(2 * ima_arr.nrows(), 2 * ima_arr.ncols());
+ data::fill(edges, -1.f);
+ image2d<float> ima_sum;
+ initialize(ima_sum, ima_arr);
+ compute_sum_arrays(ima_sum, ima_arr);
+
+ mln_piter(image2d<util::array<I> >) p(ima_arr.domain());
+ mln_niter(neighb2d) n(c4(), p);
+ for_all(p)
+ for_all(n)
+ {
+ point2d location = get_edge_location(p, n);
+ if (edges(location) != -1)
+ edges(location) = compute_dist(ima_arr, ima_sum, p, n);
+ }
+
+ return edges;
+}
+
+
+
+
+
+int usage(const char* bin)
+{
+ std::cout << "Usage: " << bin << " input.dump" << std::endl;
+ return 1;
+}
+
+int main(int argc, char* argv[])
+{
+ typedef int_u12 I;
+
+ if (argc != 2)
+ return usage(argv[0]);
+
+ image3d<I> input;
+ io::dump::save(input, argv[1]);
+ image2d<util::array<I> > ima_arr;
+ initialize(ima_arr, slice(input, 0));
+ for (unsigned int i = 0; i < input.nslices(); ++i)
+ {
+ image2d<I> tmp_slice = duplicate(slice(input, i));
+ mln_piter_(image2d<I>) p(tmp_slice.domain());
+ for_all(p)
+ ima_arr(p).append(tmp_slice(p));
+ }
+
+ image2d<float> edges = dist_on_edges(ima_arr);
+
+ return 0;
+}
Index: trunk/milena/sandbox/fabien/igr/time_max_norm.cc
===================================================================
--- trunk/milena/sandbox/fabien/igr/time_max_norm.cc (revision 0)
+++ trunk/milena/sandbox/fabien/igr/time_max_norm.cc (revision 3695)
@@ -0,0 +1,116 @@
+#include <sstream>
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/image/image3d.hh>
+#include <mln/core/image/image_if.hh>
+#include <mln/core/image/cast_image.hh>
+#include <mln/core/image/slice_image.hh>
+#include <mln/core/routine/duplicate.hh>
+
+#include <mln/value/int_u8.hh>
+#include <mln/value/int_u12.hh>
+
+#include <mln/io/dump/load.hh>
+#include <mln/io/pgm/save.hh>
+
+#include <mln/accu/count.hh>
+#include <mln/accu/mean.hh>
+#include <mln/accu/sum.hh>
+#include <mln/accu/image/all.hh>
+
+#include <mln/arith/minus.hh>
+#include <mln/arith/all.hh>
+
+#include <mln/data/fill.hh>
+#include <mln/data/paste.hh>
+
+#include <mln/level/compute.hh>
+#include <mln/level/stretch.hh>
+
+#include <mln/math/abs.hh>
+#include <mln/pw/all.hh>
+#include <mln/trait/concrete.hh>
+#include <mln/util/array.hh>
+
+#include <cmath>
+
+using namespace mln;
+using value::int_u8;
+
+
+
+// FIXME: Protoype is wrong. Should be Image<I>.
+template <typename I>
+inline
+void
+save_tmax_map(util::array<image2d<I> >& arr_ima, unsigned dim3, const char* desc)
+{
+ image2d<float> ima_c;
+ initialize(ima_c, arr_ima[0]);
+ data::fill(ima_c, 0.0);
+ image2d<unsigned> ima_t;
+ initialize(ima_t, ima_c);
+ data::fill(ima_t, 0);
+
+ mln_piter(image2d<float>) p(ima_c.domain());
+ for_all(p)
+ for (unsigned k = 0; k < dim3; ++k)
+ if (ima_c(p) < arr_ima[k](p))
+ {
+ ima_c(p) = arr_ima[k](p);
+ ima_t(p) = k;
+ }
+
+ std::ostringstream smax;
+ smax << desc << "_max.pgm";
+ std::ostringstream stime;
+ stime << desc << "_time.pgm";
+
+ image2d<int_u8> result_c = level::stretch(int_u8(), ima_c);
+ image2d<int_u8> result_t = level::stretch(int_u8(), ima_t);
+ io::pgm::save(result_c, smax.str());
+ io::pgm::save(result_t, stime.str());
+}
+
+
+int main(int argc, char* argv[])
+{
+ if (argc != 2)
+ {
+ std::cout << "Usage: " << argv[0] << " input" << std::endl;
+ return 1;
+ }
+
+ image3d<float> input;
+ io::dump::load(input, argv[1]);
+ util::array<image2d<float> > arr_ima;
+ for (unsigned int i = 0; i < input.nslices(); ++i)
+ arr_ima.append(duplicate(cast_image<float>(slice(input, i))));
+
+ unsigned dim3 = arr_ima.nelements();
+
+
+ /////////////
+ // //
+ // Lissage //
+ // //
+ /////////////
+
+ util::array<image2d<double> > arr_smooth;
+ arr_smooth.append(arr_ima[0] * 1.0);
+ for (unsigned k = 1; k < dim3 - 1; ++k)
+ arr_smooth.append(arr_ima[k] * 0.5 + arr_ima[k - 1] * 0.25 + arr_ima[k + 1] * 0.25);
+ arr_smooth.append(arr_ima[dim3 - 1] * 1.0);
+
+
+ ///////////////////////////////////
+ // //
+ // Calcul image max et temps max //
+ // //
+ ///////////////////////////////////
+
+ save_tmax_map(arr_ima, dim3, "tmax");
+ save_tmax_map(arr_smooth, dim3, "tmax_smooth");
+
+ return 0;
+}
Index: trunk/milena/sandbox/fabien/igr/check.sh
===================================================================
--- trunk/milena/sandbox/fabien/igr/check.sh (revision 3694)
+++ trunk/milena/sandbox/fabien/igr/check.sh (revision 3695)
@@ -2,19 +2,20 @@
process_file ()
{
- echo "Processing $3..."
+ echo "Processing $1..." | cowsay
dist_max=10
input=$1
dim=$2
- ./grad $input $dim
+ ./crop $input 0 50 90 149 230 170 crop.dump
+ ./grad crop.dump $dim
for lambda_closing in 50 100 500 1000 5000 10000 50000; do
echo " for lambda_closing = ${lambda_closing}";
./clo_vol grad.dump $dim ${lambda_closing}
nbasins=`./wst clo_vol.dump $dim`
echo " nbasins = $nbasins"
- ../bin/dumpl32_to_colorize wst.dump $dim $nbasins results/colorize_${3}_${lambda_closing}.ppm
- median=`./med wst.dump $dim $input $nbasins`
+ ../bin/dumpl16_to_colorize wst.dump $dim $nbasins results/colorize_${3}_${lambda_closing}.ppm
+ median=`./med wst.dump $dim crop.dump $nbasins`
echo " median = $median"
threshold=$(($median / 2))
../bin/dumpi12_to_pgm med.dump $dim results/median_${3}_${lambda_closing}.pgm
@@ -38,6 +39,8 @@
# rm *.dump
}
+make crop grad clo_vol wst med thres
+
#process_file "/Users/HiSoKa/Work/IGR/souris18/irm/IM_0049.dcm" 2 "49"
process_file "/Users/HiSoKa/Work/IGR/souris18/irm/IM_0052.dcm" 3 "52"
#process_file "/Users/HiSoKa/Work/IGR/souris18/irm/IM_0055.dcm" 2 "55"
Index: trunk/milena/sandbox/fabien/igr/fun_labels.cc
===================================================================
--- trunk/milena/sandbox/fabien/igr/fun_labels.cc (revision 3694)
+++ trunk/milena/sandbox/fabien/igr/fun_labels.cc (revision 3695)
@@ -71,7 +71,7 @@
box3d slice = make::box3d(sli, min_row, min_col,
sli, max_row, max_col);
mln_VAR(slice_label, vol_label | slice);
- accu::mean<int_u12> accu_mean;
+ accu::mean<mln_value(I)> accu_mean;
float mean = level::compute(accu_mean, slice_label);
arr.append(mean);
}
@@ -148,14 +148,15 @@
void plot_point(Image<I>& ima, Image<L>& ima_labels, point2d point, const char* desc)
{
util::array<float> arr;
- label_16 prev_lbl;
+ mln_value(L) prev_lbl;
int start = 0;
int count = 1;
+ int nslices = geom::nslis(ima);
- for (unsigned sli = 0; sli < geom::nslis(ima); ++sli)
+ for (unsigned sli = 0; sli < nslices; ++sli)
{
- image2d<int_u12> ima_slice = duplicate(slice(ima, sli));
- image2d<label_16> lbl_slice = duplicate(slice(ima_labels, sli));
+ image2d<mln_value(I)> ima_slice = duplicate(slice(ima, sli));
+ image2d<mln_value(L)> lbl_slice = duplicate(slice(ima_labels, sli));
if (sli == 0)
prev_lbl = lbl_slice(point);
if (lbl_slice(point) != prev_lbl)
@@ -166,13 +167,13 @@
start = sli + 1;
}
// Taking the median value of the region.
- accu::median_h<int_u12> accu_med;
- int_u12 median = level::compute(accu_med, ima_slice | pw::value(lbl_slice) == pw::cst(lbl_slice(point)));
- arr.append(median);
+ accu::mean<mln_value(I)> accu_mean;
+ mln_value(I) mean = level::compute(accu_mean, ima_slice | pw::value(lbl_slice) == pw::cst(lbl_slice(point)));
+ arr.append(mean);
prev_lbl = lbl_slice(point);
// Saving a image of the selected label in the current slice for debug.
- data::fill((ima_slice | pw::value(lbl_slice) == pw::cst(prev_lbl)).rw(), 1750);
+ /*data::fill((ima_slice | pw::value(lbl_slice) == pw::cst(prev_lbl)).rw(), 1750);
std::ostringstream str_ima;
str_ima << "debug_" << desc << "_";
if (sli < 100)
@@ -180,7 +181,7 @@
if (sli < 10)
str_ima << "0";
str_ima << sli << ".pgm";
- io::pgm::save(level::stretch(int_u8(), ima_slice), str_ima.str());
+ io::pgm::save(level::stretch(int_u8(), ima_slice), str_ima.str());*/
}
if (!arr.is_empty())
@@ -198,6 +199,7 @@
int main(int argc, char *argv[])
{
typedef label_16 L;
+ typedef float I;
if (argc != 4)
{
@@ -208,8 +210,8 @@
L nlabels = atoi(argv[3]);
- point2d p_tumeur(156, 114);
- point2d p_air(34, 94);
+ point2d p_tumeur(163, 114);
+ point2d p_air(54, 94);
point2d p_poumon(122, 115);
image3d<L> ima_labels;
io::dump::load(ima_labels, argv[1]);
@@ -220,15 +222,15 @@
//plot_all_labels(ima, ima_labels, nlabels);
- L l = 0;
+ /*L l = 0;
for (unsigned i = 0; i < nlabels; ++i, l = i)
- plot_label(ima, ima_labels, l);
+ plot_label(ima, ima_labels, l);*/
io::dump::save(ima_labels, "labels.dump");
- //plot_point(ima, ima_labels, p_tumeur, "tumeur");
- //plot_point(ima, ima_labels, p_air, "air");
- //plot_point(ima, ima_labels, p_poumon, "poumon");
+ plot_point(ima, ima_labels, p_tumeur, "tumeur");
+ plot_point(ima, ima_labels, p_air, "air");
+ plot_point(ima, ima_labels, p_poumon, "poumon");
/*util::set<L> lbl_set;
for (int sli = 0; sli < geom::nslis(ima_labels); ++sli)
Index: trunk/milena/sandbox/fabien/igr/norm.cc
===================================================================
--- trunk/milena/sandbox/fabien/igr/norm.cc (revision 3694)
+++ trunk/milena/sandbox/fabien/igr/norm.cc (revision 3695)
@@ -18,6 +18,8 @@
#include <mln/data/paste.hh>
// DEBUG
+#include <mln/core/var.hh>
+#include <mln/estim/min_max.hh>
/*#include <mln/accu/min.hh>
#include <mln/accu/max.hh>
#include <mln/level/compute.hh>*/
@@ -60,18 +62,10 @@
image2d<float> ima_ini = mean_slices(ima_f, first, last);
image3d<float> ima_result;
- initialize(ima_result, ima_f);
+ initialize(ima_result, ima);
for (int i = min_sli; i <= max_sli; ++i)
- data::paste((slice(ima_f, i) - ima_ini), slice(ima_result, i).rw());
-
- // DEBUG
- /*accu::min<float> accu_min;
- accu::max<float> accu_max;
- float min = level::compute(accu_min, ima_ini);
- float max = level::compute(accu_max, ima_ini);
- std::cout << "min = " << min << std::endl;
- std::cout << "max = " << max << std::endl;*/
+ data::paste((slice(ima_f, i) - ima_ini) / ima_ini, slice(ima_result, i).rw());
return ima_result;
}
Index: trunk/milena/sandbox/fabien/igr/thres.cc
===================================================================
--- trunk/milena/sandbox/fabien/igr/thres.cc (revision 3694)
+++ trunk/milena/sandbox/fabien/igr/thres.cc (revision 3695)
@@ -34,7 +34,7 @@
using value::int_u12;
using value::label_16;
using value::label_32;
- typedef label_32 L;
+ typedef label_16 L;
if (argc != 4)
{
Index: trunk/milena/sandbox/fabien/igr/Makefile
===================================================================
--- trunk/milena/sandbox/fabien/igr/Makefile (revision 3694)
+++ trunk/milena/sandbox/fabien/igr/Makefile (revision 3695)
@@ -28,7 +28,7 @@
${CXX} -I../../../ ${DICOM} ${CXXFLAGS} $^ -o graph
med: med.cc
- ${CXX} -I../../../ ${DICOM} ${CXXFLAGS} $^ -o med
+ ${CXX} -I../../../ ${CXXFLAGS} $^ -o med
thres: thres.cc
${CXX} -I../../../ ${CXXFLAGS} $^ -o thres
@@ -39,6 +39,9 @@
time_max: time_max.cc
${CXX} -I../../../ ${DICOM} ${MAGICK} ${CXXFLAGS} -lm $^ -o time_max
+time_max_norm: time_max_norm.cc
+ ${CXX} -I../../../ ${CXXFLAGS} -lm $^ -o time_max_norm
+
first_slice_dicom: first_slice_dicom.cc
${CXX} -I../../../ ${DICOM} ${MAGICK} ${CXXFLAGS} -lm $^ -o first_slice_dicom
@@ -57,6 +60,13 @@
norm: norm.cc
${CXX} -I../../../ ${CXXFLAGS} $^ -o norm
+#####################
+
+seg_fixed: seg_fixed.cc
+ ${CXX} -I../../../ ${CXXFLAGS} $^ -o seg_fixed
+
+#####################
+
clean:
rm -rf *.dump *.p?m *.plot *.log *.csv *.dSYM
rm seg2d seg3d wsd2d wsd3d nbasins_finder grad clo_vol wst graph med thres matlab time_max first_slice_dicom
Index: trunk/milena/sandbox/fabien/igr/fun_labels.sh
===================================================================
--- trunk/milena/sandbox/fabien/igr/fun_labels.sh (revision 3694)
+++ trunk/milena/sandbox/fabien/igr/fun_labels.sh (revision 3695)
@@ -1,5 +1,9 @@
#!/bin/zsh
+#########
+# Plots #
+#########
+
reconstruct_plot ()
{
rm -f ${1}_${2}.plot
@@ -10,11 +14,16 @@
rename_label_plots ()
{
- for i in label_*.plot; do
+ for i in *_label_*.plot; do
mv $i ${1}_$i
done
}
+
+#############
+# Animation #
+#############
+
create_anim ()
{
echo " Creating ${1} animation..."
@@ -43,15 +52,25 @@
rm debug_${1}_*.png
}
+
+
+
+
+
+
+
+
+
process_file ()
{
- echo "Processing $3..."
+ echo "Processing $1..." | cowsay
input=$1
dim=$2
./crop $input 0 50 90 149 230 170 crop.dump
+ ./norm crop.dump norm.dump
./grad crop.dump $dim
- for lambda_closing in 10000; do
+ for lambda_closing in 1000; do
echo " for lambda_closing = ${lambda_closing}";
./clo_vol grad.dump $dim ${lambda_closing}
nbasins=`./wst clo_vol.dump $dim`
@@ -61,24 +80,25 @@
#../bin/dumpi12_to_png mean_slices.dump $dim mean_slices_${3}_${lambda_closing}.png
#../bin/dumpi12_to_pgm mean_slices.dump $dim mean_slices_${3}_${lambda_closing}.pgm
- ./norm crop.dump norm.dump
./fun_labels wst.dump norm.dump $nbasins
- rename_label_plots ${lambda_closing}
#./all_labels2gif.sh crop.dump labels.dump $nbasins ${lambda_closing}
#mv *.gif results/
#mv *.plot results/plots/
-#reconstruct_plot tumeur ${lambda_closing}
+ reconstruct_plot tumeur ${lambda_closing}
+ reconstruct_plot air ${lambda_closing}
+ reconstruct_plot poumon ${lambda_closing}
+ rename_label_plots ${lambda_closing}
#create_anim tumeur ${lambda_closing}
-#reconstruct_plot air ${lambda_closing}
#create_anim air ${lambda_closing}
-#reconstruct_plot poumon ${lambda_closing}
#create_anim poumon ${lambda_closing}
done
}
+make crop grad clo_vol fun_labels norm label2gif
+
# 3D (2D + t) images only
process_file "/Users/HiSoKa/Work/IGR/souris18/irm/IM_0052.dcm" 3 52
Index: trunk/milena/sandbox/fabien/igr/space_smooth/Makefile
===================================================================
--- trunk/milena/sandbox/fabien/igr/space_smooth/Makefile (revision 3694)
+++ trunk/milena/sandbox/fabien/igr/space_smooth/Makefile (revision 3695)
@@ -2,7 +2,7 @@
linear: linear.cc
- ${CXX} -I../../../../ ${DICOM} ${CXXFLAGS} $^ -o linear
+ ${CXX} -I../../../../ ${CXXFLAGS} $^ -o linear
median: median.cc
${CXX} -I../../../../ ${DICOM} ${CXXFLAGS} $^ -o median
Index: trunk/milena/sandbox/fabien/igr/space_smooth/linear.cc
===================================================================
--- trunk/milena/sandbox/fabien/igr/space_smooth/linear.cc (revision 3694)
+++ trunk/milena/sandbox/fabien/igr/space_smooth/linear.cc (revision 3695)
@@ -7,7 +7,7 @@
#include <mln/value/int_u12.hh>
-#include <mln/io/dicom/load.hh>
+#include <mln/io/dump/load.hh>
#include <mln/io/plot/save.hh>
#include <mln/accu/median_h.hh>
@@ -29,17 +29,19 @@
return 1;
}
+ typedef float I;
+
///////////////////
// //
// Image loading //
// //
///////////////////
- image3d<int_u12> input;
- io::dicom::load(input, argv[1]);
- util::array<image2d<int_u12> > arr_ima;
- for (int i = 0; i < input.nslices(); ++i)
+ image3d<I> input;
+ io::dump::load(input, argv[1]);
+ util::array<image2d<I> > arr_ima;
+ for (unsigned int i = 0; i < input.nslices(); ++i)
{
- image2d<int_u12> tmp_slice = duplicate(slice(input, i));
+ image2d<I> tmp_slice = duplicate(slice(input, i));
arr_ima.append(tmp_slice);
}
@@ -61,14 +63,15 @@
// Outputs //
// //
/////////////
- image2d<util::array<float> > ima_result(input.nrows(), input.ncols());
+ image2d<util::array<float> > ima_result;
+ initialize(ima_result, slice(input, 0));
mln_piter_(image2d<util::array<float> >) p(ima_linear[0].domain());
for_all(p)
- for (int i = 0; i < ima_linear.nelements(); ++i)
+ for (unsigned int i = 0; i < ima_linear.nelements(); ++i)
ima_result(p).append(ima_linear[i](p));
io::plot::save(ima_result(point2d(156, 114)), "linear_tumeur.plot");
- io::plot::save(ima_result(point2d(34, 94)), "linear_air.plot");
+ io::plot::save(ima_result(point2d(54, 94)), "linear_air.plot");
io::plot::save(ima_result(point2d(122, 115)), "linear_poumon.plot");
return 0;
Index: trunk/milena/sandbox/fabien/igr/time_smooth/Makefile
===================================================================
--- trunk/milena/sandbox/fabien/igr/time_smooth/Makefile (revision 3694)
+++ trunk/milena/sandbox/fabien/igr/time_smooth/Makefile (revision 3695)
@@ -2,7 +2,7 @@
linear: linear.cc
- ${CXX} -I../../../../ ${DICOM} ${CXXFLAGS} $^ -o linear
+ ${CXX} -I../../../../ ${CXXFLAGS} $^ -o linear
median: median.cc
${CXX} -I../../../../ ${DICOM} ${CXXFLAGS} $^ -o median
Index: trunk/milena/sandbox/fabien/igr/time_smooth/linear.cc
===================================================================
--- trunk/milena/sandbox/fabien/igr/time_smooth/linear.cc (revision 3694)
+++ trunk/milena/sandbox/fabien/igr/time_smooth/linear.cc (revision 3695)
@@ -7,11 +7,13 @@
#include <mln/value/int_u12.hh>
-#include <mln/io/dicom/load.hh>
+#include <mln/io/dump/all.hh>
#include <mln/io/plot/save.hh>
#include <mln/accu/median_h.hh>
#include <mln/util/array.hh>
+#include <mln/linear/convolve.hh>
+#include <mln/make/w_window3d.hh>
using namespace mln;
@@ -26,33 +28,48 @@
return 1;
}
+ typedef float I;
+
///////////////////
// //
// Image loading //
// //
///////////////////
- image3d<int_u12> input;
- io::dicom::load(input, argv[1]);
- image2d<util::array<int_u12> > ima_arr(input.nrows(), input.ncols());
- for (int i = 0; i < input.nslices(); ++i)
+ image3d<I> input;
+ io::dump::load(input, argv[1]);
+ image2d<util::array<I> > ima_arr;
+ initialize(ima_arr, duplicate(slice(input, 0)));
+ for (unsigned int i = 0; i < input.nslices(); ++i)
{
- image2d<int_u12> tmp_slice = duplicate(slice(input, i));
- mln_piter_(image2d<int_u12>) p(tmp_slice.domain());
+ image2d<I> tmp_slice = duplicate(slice(input, i));
+ mln_piter_(image2d<I>) p(tmp_slice.domain());
for_all(p)
{
ima_arr(p).append(tmp_slice(p));
}
}
+ /*image3d<I> output;
+ initialize(output, input);*/
////////////////////////
// //
// Linear convolution //
// //
////////////////////////
- image2d<util::array<int_u12> > ima_linear;
+ /*float ws[][] = {{0, 0, 0,
+ 0, 0.25, 0,
+ 0, 0, 0},
+ {0, 0, 0,
+ 0, 0.5, 0,
+ 0, 0, 0},
+ {0, 0, 0,
+ 0, 0.25, 0,
+ 0, 0, 0}};
+
+ output = linear::convolve(input, make::w_window3d(ws));*/
+ image2d<util::array<I> > ima_linear;
initialize(ima_linear, ima_arr);
- mln_piter_(image2d<int_u12>) p(ima_linear.domain());
- accu::median_h<int_u12> accu_med;
+ mln_piter_(image2d<I>) p(ima_linear.domain());
for_all(p)
{
ima_linear(p).append(ima_arr(p)[0]);
@@ -66,10 +83,11 @@
// Outputs //
// //
/////////////
+ //io::dump::save(output, "time_linear.dump");
io::plot::save(ima_arr(point2d(156, 114)), "ref_tumeur.plot");
io::plot::save(ima_linear(point2d(156, 114)), "linear_tumeur.plot");
- io::plot::save(ima_arr(point2d(34, 94)), "ref_air.plot");
- io::plot::save(ima_linear(point2d(34, 94)), "linear_air.plot");
+ io::plot::save(ima_arr(point2d(54, 94)), "ref_air.plot");
+ io::plot::save(ima_linear(point2d(54, 94)), "linear_air.plot");
io::plot::save(ima_arr(point2d(122, 115)), "ref_poumon.plot");
io::plot::save(ima_linear(point2d(122, 115)), "linear_poumon.plot");
Index: trunk/milena/sandbox/fabien/igr/med.cc
===================================================================
--- trunk/milena/sandbox/fabien/igr/med.cc (revision 3694)
+++ trunk/milena/sandbox/fabien/igr/med.cc (revision 3695)
@@ -9,7 +9,6 @@
#include <mln/core/alias/window3d.hh>
#include <mln/io/dump/all.hh>
-#include <mln/io/dicom/load.hh>
#include <mln/value/int_u8.hh>
#include <mln/value/int_u12.hh>
@@ -45,7 +44,7 @@
using value::int_u12;
using value::label_16;
using value::label_32;
- typedef label_32 L;
+ typedef label_16 L;
if (argc != 5)
{
@@ -70,12 +69,12 @@
{
image2d<L> labels;
io::dump::load(labels, argv[1]);
- image2d<int_u12> dcm;
- io::dicom::load(dcm, argv[3]);
+ image2d<int_u12> input;
+ io::dump::load(input, argv[3]);
mln_VAR(wst_dilate, morpho::elementary::dilation(extend(labels | (pw::value(labels) == 0u), labels), c8()));
data::fill((labels | (pw::value(labels) == 0u)).rw(), wst_dilate);
- mln_VAR(wst_mean, labeling::mean_values(dcm, labels, nbasins));
+ mln_VAR(wst_mean, labeling::mean_values(input, labels, nbasins));
histo::array<int_u12> histogram = histo::compute(wst_mean);
int j = 0;
@@ -106,12 +105,12 @@
{
image3d<L> labels;
io::dump::load(labels, argv[1]);
- image3d<int_u12> dcm;
- io::dicom::load(dcm, argv[3]);
+ image3d<int_u12> input;
+ io::dump::load(input, argv[3]);
mln_VAR(wst_dilate, morpho::elementary::dilation(extend(labels | (pw::value(labels) == 0u), labels), c26()));
data::fill((labels | (pw::value(labels) == 0u)).rw(), wst_dilate);
- mln_VAR(wst_mean, labeling::mean_values(dcm, labels, nbasins));
+ mln_VAR(wst_mean, labeling::mean_values(input, labels, nbasins));
histo::array<int_u12> histogram = histo::compute(wst_mean);
int j = 0;
Index: trunk/milena/sandbox/fabien/TODO
===================================================================
--- trunk/milena/sandbox/fabien/TODO (revision 3694)
+++ trunk/milena/sandbox/fabien/TODO (revision 3695)
@@ -47,6 +47,20 @@
[ ] Fix mean slices values
[X] Compatibility Windows
[X] Fix spatial smooth
-[ ] Crop volume 52
-[ ] Plot all labels (3, 4 labels for tumeur)
+[X] Crop volume 52
+[X] Plot all labels (3, 4 labels for tumeur)
[ ] Prepare data for IGR
+ [X] crop->norm->tmax
+ [X] crop->norm->space_smooth->tmax
+
+ (comparo normalisé)
+ 1)brut
+ 2)time_smooth
+ 3)space_smooth
+ 4)current_label_smooth (lambda faible, pas de ligne watershed)
+
+ [X] plot label
+ [X] gif animés labels
+
+ [X] fausses couleurs watershed
+ [X] images moyennes
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog:
2009-04-21 Etienne FOLIO <folio(a)lrde.epita.fr>
Closure with flat element.
* inim/2010/morpho/morpho.cc: New test algorithm.
* inim/2010/morpho/test.sh: New build tests file.
* inim/2010/morpho: New directory for mini-project.
---
morpho.cc | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
test.sh | 5 ++++
2 files changed, 76 insertions(+)
Index: trunk/milena/sandbox/inim/2010/morpho/morpho.cc
===================================================================
--- trunk/milena/sandbox/inim/2010/morpho/morpho.cc (revision 0)
+++ trunk/milena/sandbox/inim/2010/morpho/morpho.cc (revision 3694)
@@ -0,0 +1,71 @@
+#include <iostream>
+#include <sstream>
+#include <string>
+#include <mln/debug/println.hh>
+
+#include <mln/io/pbm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+#include <mln/data/fill.hh>
+#include <mln/literal/all.hh>
+#include <mln/arith/revert.hh>
+#include <mln/level/convert.hh>
+#include <mln/level/stretch.hh>
+#include <mln/morpho/closing/structural.hh>
+#include <mln/core/alias/window2d.hh>
+#include <mln/make/win_chamfer.hh>
+
+int main(int argc, char** argv)
+{
+ using namespace mln;
+
+ // check arguments
+ if (argc != 4)
+ {
+ std::cerr << "Usage:" << std::endl
+ << " ./a.out <in.pbm> <k> <out.pbm>" << std::endl;
+ exit(1);
+ }
+
+ // build test image
+ std::cout << " => loading " << argv[1] << "..." << std::endl;
+ image2d<bool> in;
+ io::pbm::load(in, argv[1]);
+
+ value::int_u8 k = 1;
+ image2d<value::int_u8> out = level::convert(k, in);
+ out = level::stretch(k, out);
+
+ std::cout << " => revert image..." << std::endl;
+ out = arith::revert(out);
+
+ // closure
+/* int ws[] = { 0, 1, 0,
+ 1, 0, 1,
+ 0, 1, 0 };
+*/
+ // w_window2d_int == w_window<dpoint2d, int>
+
+
+ for (unsigned j = 20; j <= 40; j += 10)
+ {
+ window2d it;
+ it.insert(0, 0);
+
+ for (unsigned i = 0; i < j; ++i)
+ {
+ it.insert(0, -i);
+ it.insert(0, i);
+ }
+
+ out = morpho::closing::structural(out, it);
+
+ // export out image
+ std::stringstream ss;
+ ss << "../" << j << '/' << argv[3];
+ std::string s;
+ ss >> s;
+ std::cout << " => saving " << s << "..." << std::endl;
+ io::pgm::save(out, s.c_str());
+ }
+}
Index: trunk/milena/sandbox/inim/2010/morpho/test.sh
===================================================================
--- trunk/milena/sandbox/inim/2010/morpho/test.sh (revision 0)
+++ trunk/milena/sandbox/inim/2010/morpho/test.sh (revision 3694)
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+for i in `ls *.tif`; do
+ ../closure $i.pbm 1 $i.pbm ;
+done
Property changes on: trunk/milena/sandbox/inim/2010/morpho/test.sh
___________________________________________________________________
Name: svn:executable
+ *
1
0
Re: [Olena-patches] [Olena] #3: Migrate Olena 0.11 (and previous revisions) from PRCS to Git
by Olena Trac 21 Apr '09
by Olena Trac 21 Apr '09
21 Apr '09
#3: Migrate Olena 0.11 (and previous revisions) from PRCS to Git
-----------------------+----------------------------------------------------
Reporter: levill_r | Owner: levill_r
Type: task | Status: reopened
Priority: blocker | Milestone: Olena 0.11.1
Component: other | Version: 0.11
Resolution: | Keywords: prcs subversion svn git
-----------------------+----------------------------------------------------
Changes (by levill_r):
* type: enhancement => task
--
Ticket URL: <https://trac.lrde.org/olena/ticket/3#comment:9>
Olena <http://olena.lrde.epita.fr>
Olena, a generic and efficient C++ image processing library.
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Update use of transposition.
* icdar/2009/hsc/input_to_lines.hh: Update.
* icdar/2009/hsc/input_to_ws.hh: Add log.
Update.
* icdar/2009/hsc/ws_to_wsl.hh: Likewise.
* jardonnet/registration/cov.hh: Update.
* jardonnet/registration/quat7.hh: Update.
icdar/2009/hsc/input_to_lines.hh | 5 ++-
icdar/2009/hsc/input_to_ws.hh | 51 ++++++++++++++++++++++++++++++++++++++-
icdar/2009/hsc/ws_to_wsl.hh | 48 ++++++++++++------------------------
jardonnet/registration/cov.hh | 2 -
jardonnet/registration/quat7.hh | 4 +--
5 files changed, 72 insertions(+), 38 deletions(-)
Index: icdar/2009/hsc/input_to_lines.hh
--- icdar/2009/hsc/input_to_lines.hh (revision 3691)
+++ icdar/2009/hsc/input_to_lines.hh (working copy)
@@ -6,9 +6,10 @@
#include <mln/world/binary_2d/subsample.hh>
#include <mln/value/int_u8.hh>
#include <mln/value/label.hh>
-#include <mln/labeling/relabel.hh>
+#include <mln/labeling/pack.hh>
#include <mln/core/image/violent_cast_image.hh>
+#include <mln/io/pgm/save.hh>
namespace mln
@@ -38,7 +39,7 @@
// Clean lines
wsl = clean_lines(input, wsl, tau);
- return labeling::relabel(violent_cast_image_<L>(wsl),
+ return labeling::pack(violent_cast_image_<L>(wsl),
n_lines);
}
Index: icdar/2009/hsc/input_to_ws.hh
--- icdar/2009/hsc/input_to_ws.hh (revision 3691)
+++ icdar/2009/hsc/input_to_ws.hh (working copy)
@@ -10,10 +10,18 @@
#include <sandbox/theo/exec/gaussian_directional_2d.hh>
#include <mln/win/rectangle2d.hh>
-
#include <mln/morpho/closing/structural.hh>
#include <mln/morpho/watershed/flooding.hh>
+#include <mln/io/pgm/save.hh>
+#include <mln/io/ppm/save.hh>
+#include <mln/literal/colors.hh>
+#include <mln/debug/colorize.hh>
+#include <mln/level/convert.hh>
+#include <mln/labeling/wrap.hh>
+#include <mln/pw/all.hh>
+#include <mln/core/image/image_if.hh>
+
namespace mln
{
@@ -52,6 +60,12 @@
out = linear::gaussian_directional_2d(out, 0, v_sigma, 0);
fuzzy = level::saturate(value::int_u8(), out);
+
+#ifdef LOG
+ io::pgm::save(small, "temp_small.pgm");
+ io::pgm::save(fuzzy, "temp_fuzzy.pgm");
+#endif // LOG
+
}
// Closing.
@@ -60,6 +74,41 @@
// Watershed transform.
image2d<L> ws = morpho::watershed::flooding(clo, c4(), n_lines);
+
+# ifdef LOG
+ {
+ // Watershed line (red) over small image.
+ image2d<value::rgb8> cool = level::convert(value::rgb8(), small);
+ data::fill((cool | (pw::value(ws) == pw::cst(0))).rw(),
+ literal::red);
+ io::ppm::save(cool, "temp_small_ws.ppm");
+ }
+ {
+ // Watershed line (red) over fuzzy image.
+ image2d<value::rgb8> cool = level::convert(value::rgb8(), fuzzy);
+ data::fill((cool | (pw::value(ws) == pw::cst(0))).rw(),
+ literal::red);
+ io::ppm::save(cool, "temp_fuzzy_ws.ppm");
+ }
+ {
+ // Watershed basins colorize the small image.
+ image2d<value::rgb8> cool = debug::colorize(value::rgb8(), ws, n_lines);
+ data::fill((cool | (pw::value(ws) == pw::cst(0))).rw(),
+ literal::white);
+ mln_piter(box2d) p(small.domain());
+ for_all(p)
+ {
+ if (small(p) == 255)
+ continue;
+ float f = float(small(p)) / 255;
+ cool(p).red() = cool(p).red() * f;
+ cool(p).green() = cool(p).green() * f;
+ cool(p).blue() = cool(p).blue() * f;
+ }
+ io::ppm::save(cool, "temp_ws.ppm");
+ }
+# endif
+
return ws;
}
Index: icdar/2009/hsc/ws_to_wsl.hh
--- icdar/2009/hsc/ws_to_wsl.hh (revision 3691)
+++ icdar/2009/hsc/ws_to_wsl.hh (working copy)
@@ -44,25 +44,6 @@
{
- algebra::mat<1,2,float>
- trans(const algebra::vec<2,float>& v)
- {
- algebra::mat<1,2,float> tmp;
- tmp(0,0) = v[0];
- tmp(0,1) = v[1];
- return tmp;
- }
-
- algebra::mat<2,1,float>
- to_mat(const algebra::vec<2,float>& v)
- {
- algebra::mat<2,1,float> tmp;
- tmp(0,0) = v[0];
- tmp(1,0) = v[1];
- return tmp;
- }
-
-
struct mahalanobis : public mln::accu::internal::base< unsigned , mahalanobis >
{
typedef point2d argument;
@@ -113,7 +94,7 @@
if (n_ == 0)
return;
mean_ /= n_;
- cov_ = cov_ / n_ - to_mat(mean_) * trans(mean_);
+ cov_ = cov_ / n_ - mean_ * mean_.t();
float
a = cov_(0, 0), b = cov_(0, 1),
@@ -174,7 +155,7 @@
{
mln_invariant(valid_);
algebra::vec<2,float> v_ = v - mean_;
- return (trans(v_) * cov_1_ * v_)[0];
+ return v_.t() * cov_1_ * v_;
}
/// Get the number of items.
@@ -397,29 +378,32 @@
#ifdef LOG
{
- io::pgm::save(small, "tmp_small.pgm");
- io::pgm::save(ws, "tmp_ws.pgm");
-
using value::rgb8;
- image2d<rgb8> small_ws = level::convert(rgb8(), small);
- data::fill((small_ws | (pw::value(ws) == pw::cst(0))).rw(),
- literal::red);
- io::ppm::save(small_ws, "tmp_small_ws.ppm");
-
fun::i2v::array<L> f_relab(n_basins + 1);
f_relab(0) = 0;
for (L l = 1; l <= n_basins; ++l)
f_relab(l) = parent[l];
image2d<L> ws_ = level::transform(ws, f_relab);
- io::ppm::save(debug::colorize(rgb8(), ws_, n_basins), "tmp_ws.ppm");
+ image2d<rgb8> cool = debug::colorize(rgb8(), ws_, n_basins);
+ data::fill((cool | (pw::value(ws) == pw::cst(0))).rw(),
+ literal::white);
+ mln_piter(box2d) p(small.domain());
+ for_all(p)
+ {
+ if (small(p) == 255)
+ continue;
+ float f = float(small(p)) / 255;
+ cool(p).red() = cool(p).red() * f;
+ cool(p).green() = cool(p).green() * f;
+ cool(p).blue() = cool(p).blue() * f;
+ }
+ io::ppm::save(cool, "temp_wsl.ppm");
}
#endif // LOG
-
-
// Outputing.
image2d<L> output(input.domain());
Index: jardonnet/registration/cov.hh
--- jardonnet/registration/cov.hh (revision 3691)
+++ jardonnet/registration/cov.hh (working copy)
@@ -66,7 +66,7 @@
// FIXME: ugly cast.
algebra::vec<P::dim,float> a1i = a1[i];
algebra::vec<P::dim,float> a2i = a2[i];
- Mk += make::mat(a1i - mu_a1) * trans(make::mat(a2i - mu_a2));
+ Mk += (a1i - mu_a1) * (a2i - mu_a2).t();
}
return Mk / a1.nsites();
Index: jardonnet/registration/quat7.hh
--- jardonnet/registration/quat7.hh (revision 3691)
+++ jardonnet/registration/quat7.hh (working copy)
@@ -145,8 +145,8 @@
algebra::vec<P::dim,float> Ci = C[i];
algebra::vec<P::dim,float> Xki = map(Ck[i]);
- Mk += make::mat(Ci - mu_C) * trans(make::mat(Xki - mu_Xk));
- // or Mk += make::mat(Ci) * trans(make::mat(Xki)) - make::mat(mu_C) * trans(make::mat(mu_Xk))
+ Mk += (Ci - mu_C) * (Xki - mu_Xk).t();
+ // or Mk += Ci * Xki.t() - mu_C * mu_Xk.t()
}
Mk /= c_length;
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Improve vector and matrix interoperability.
* mln/algebra/mat.hh (t): New method to transpose; replace...
(trans): Remove procedure.
(operator*): New overloads to improve interoperatibility
between vectors and matrices.
* mln/registration/get_rot.hh: Update.
* mln/registration/icp.hh: Update.
* mln/algebra/vec.hh (mat<n, 1, U>): New conversion op, ctor,
and assignment; declarations only, definitions are...
* mln/algebra/mat.hh (mat<n, 1, U>): ...new.
* tests/algebra/op_times.cc: New.
* mln/labeling/compute.hh: Disable check to run on int_u.
* mln/accu/sum.hh (take_as_init): New.
* mln/accu/image/take_as_init.hh: New overload for image as arg.
* tests/accu/image/take_as_init.cc: Augment.
mln/accu/image/take_as_init.hh | 110 ++++++++++++++++++++++++++-
mln/accu/sum.hh | 12 ++
mln/algebra/mat.hh | 158 ++++++++++++++++++++++++++++++++++-----
mln/algebra/vec.hh | 18 ++++
mln/labeling/compute.hh | 2
mln/registration/get_rot.hh | 5 -
mln/registration/icp.hh | 4
tests/accu/image/take_as_init.cc | 3
tests/algebra/op_times.cc | 72 +++++++++++++++++
9 files changed, 357 insertions(+), 27 deletions(-)
Index: mln/accu/image/take_as_init.hh
--- mln/accu/image/take_as_init.hh (revision 3690)
+++ mln/accu/image/take_as_init.hh (working copy)
@@ -50,6 +50,11 @@
take_as_init(Image<I>& input,
const mln_deduce(I, value, argument)& v);
+ template <typename I, typename J>
+ void
+ take_as_init(Image<I>& input,
+ const Image<J>& values);
+
# ifndef MLN_INCLUDE_ONLY
@@ -57,7 +62,7 @@
namespace impl
{
- // Generic version.
+ // Generic versions.
namespace generic
{
@@ -79,10 +84,29 @@
trace::exiting("accu::impl::image::generic::take_as_init");
}
+ template <typename I, typename J>
+ void
+ take_as_init(Image<I>& input_,
+ const Image<J>& values_)
+ {
+ trace::entering("accu::impl::image::generic::take_as_init");
+
+ I& input = exact(input_);
+ const I& values = exact(values_);
+ mln_precondition(input.is_valid());
+ mln_precondition(values.is_valid());
+
+ mln_piter(I) p(input.domain());
+ for_all(p)
+ input(p).take_as_init(values(p));
+
+ trace::exiting("accu::impl::image::generic::take_as_init");
+ }
+
} // end of namespace mln::accu::image::impl::generic
- // Fastest version.
+ // Fastest versions.
template <typename I>
void
@@ -101,6 +125,26 @@
trace::exiting("accu::impl::image::take_as_init_fastest");
}
+ template <typename I, typename J>
+ void
+ take_as_init_fastest(Image<I>& input_,
+ const Image<J>& values_)
+ {
+ trace::entering("accu::impl::image::take_as_init_fastest");
+
+ I& input = exact(input_);
+ const I& values = exact(values_);
+ mln_precondition(input.is_valid());
+ mln_precondition(values.is_valid());
+
+ mln_pixter(I) p_in(input);
+ mln_pixter(const J) p_v(values);
+ for_all_2(p_in, p_v)
+ p_in.val().take_as_init(p_v.val());
+
+ trace::exiting("accu::impl::image::take_as_init_fastest");
+ }
+
} // end of namespace mln::accu::image::impl
@@ -110,7 +154,10 @@
namespace internal
{
+ // With a single value.
+
template <typename I, typename V>
+ inline
void
take_as_init_dispatch(trait::image::speed::any,
Image<I>& input, const V& v)
@@ -119,6 +166,7 @@
}
template <typename I, typename V>
+ inline
void
take_as_init_dispatch(trait::image::speed::fastest,
Image<I>& input, const V& v)
@@ -127,6 +175,7 @@
}
template <typename I, typename V>
+ inline
void
take_as_init_dispatch(Image<I>& input, const V& v)
{
@@ -134,12 +183,46 @@
input, v);
}
+ // With an image of values.
+
+ template <typename I, typename J>
+ inline
+ void
+ take_as_init_dispatch(trait::image::speed::any,
+ trait::image::speed::any,
+ Image<I>& input, const Image<J>& values)
+ {
+ impl::generic::take_as_init(input, values);
+ }
+
+ template <typename I, typename J>
+ inline
+ void
+ take_as_init_dispatch(trait::image::speed::fastest,
+ trait::image::speed::fastest,
+ Image<I>& input, const Image<J>& values)
+ {
+ impl::take_as_init_fastest(input, values);
+ }
+
+ template <typename I, typename J>
+ inline
+ void
+ take_as_init_dispatch(Image<I>& input,
+ const Image<J>& values)
+ {
+ take_as_init_dispatch(mln_trait_image_speed(I)(),
+ mln_trait_image_speed(J)(),
+ input, values);
+ }
+
} // end of namespace mln::accu::image::internal
- // Facade.
+ // Facades.
template <typename I>
+ inline
void
take_as_init(Image<I>& input,
const mln_deduce(I, value, argument)& v)
@@ -154,6 +237,27 @@
trace::exiting("accu::image::take_as_init");
}
+ template <typename I, typename J>
+ inline
+ void
+ take_as_init(Image<I>& input,
+ const Image<J>& values)
+ {
+ trace::entering("accu::image::take_as_init");
+
+ typedef mln_value(I) A;
+ mlc_is_a(A, Accumulator)::check();
+ mlc_converts_to(mln_value(J), mln_argument(A))::check();
+
+ mln_precondition(exact(input).is_valid());
+ mln_precondition(exact(values).is_valid());
+ // mln_precondition(exact(values).domain() == exact(input).domain());
+
+ internal::take_as_init_dispatch(input, values);
+
+ trace::exiting("accu::image::take_as_init");
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::accu::image
Index: mln/accu/sum.hh
--- mln/accu/sum.hh (revision 3690)
+++ mln/accu/sum.hh (working copy)
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
-// (LRDE)
+// 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
@@ -67,6 +67,7 @@
/// \{
void init();
void take(const argument& t);
+ void take_as_init(const argument& t);
void take(const sum<T,S>& other);
/// \}
@@ -128,6 +129,13 @@
template <typename T, typename S>
inline
+ void sum<T,S>::take_as_init(const argument& t)
+ {
+ s_ = static_cast<S>(t);
+ }
+
+ template <typename T, typename S>
+ inline
void
sum<T,S>::take(const sum<T,S>& other)
{
Index: mln/algebra/mat.hh
--- mln/algebra/mat.hh (revision 3690)
+++ mln/algebra/mat.hh (working copy)
@@ -82,6 +82,7 @@
namespace algebra
{
+
template <unsigned n, unsigned m, typename T>
class mat : public Object< mat<n,m,T> >
{
@@ -118,6 +119,9 @@
static mat identity();
+ /// Return the transpose of the matrix.
+ mat<m,n,T> t() const;
+
private:
T data_[n][m];
};
@@ -229,6 +233,11 @@
mat<n, m, mln_sum_product(T,U)>
operator*(const mat<n,o,T>& lhs, const mat<o,m,U>& rhs);
+ template <unsigned o, typename T,
+ typename U>
+ mln_sum_product(T,U)
+ operator*(const mat<1,o,T>& lhs, const mat<o,1,U>& rhs);
+
// mat * vec
template <unsigned n, unsigned m, typename T,
@@ -236,6 +245,17 @@
vec<n, mln_sum_product(T,U)>
operator*(const mat<n,m,T>& lhs, const vec<m,U>& rhs);
+ template <unsigned m, typename T,
+ typename U>
+ mln_sum_product(T,U) // scalar
+ operator*(const mat<1,m,T>& lhs, const vec<m,U>& rhs);
+
+ // vec * mat
+
+ template <unsigned m, typename T, typename U>
+ mat<m, m, mln_trait_op_times(T,U)>
+ operator*(const vec<m,T>& lhs, const mat<1,m,U>& rhs);
+
// mat * s
template <unsigned n, unsigned m, typename T,
@@ -255,11 +275,6 @@
std::ostream&
operator<<(std::ostream& ostr, const mat<n,m,T>& v);
- // transpose
-
- template<unsigned n, unsigned m, typename T>
- mat<m,n,T>
- trans(const mat<n,m,T>& matrix);
// trace
@@ -267,14 +282,61 @@
float tr(const mat<n,n,T>& m);
+
# ifndef MLN_INCLUDE_ONLY
+
+ // vec -> mat
+
+ template <unsigned n, typename T>
+ template <typename U>
+ inline
+ vec<n,T>::operator mat<n,1,U>() const
+ {
+ mlc_converts_to(T, U)::check();
+ mat<n,1,U> tmp;
+ for (unsigned i = 0; i < n; ++i)
+ tmp(i, 0) = data_[i];
+ return tmp;
+ }
+
+
+ // mat -> vec
+
+ template <unsigned n, typename T>
+ template <typename U>
+ inline
+ vec<n,T>::vec(const mat<n, 1, U>& rhs)
+ {
+ mlc_converts_to(T, U)::check();
+ for (unsigned i = 0; i < n; ++i)
+ data_[i] = rhs(i, 0);
+ }
+
+ template <unsigned n, typename T>
+ template <typename U>
+ inline
+ vec<n,T>&
+ vec<n,T>::operator=(const mat<n, 1, U>& rhs)
+ {
+ mlc_converts_to(T, U)::check();
+ for (unsigned i = 0; i < n; ++i)
+ data_[i] = rhs(i, 0);
+ return *this;
+ }
+
+
+
+ // Id
+
template <unsigned n, unsigned m, typename T>
- const mat<n,m,T> mat<n,m,T>::Id = mat<n,m,T>::identity();
+ const mat<n,m,T>
+ mat<n,m,T>::Id = mat<n,m,T>::identity();
template <unsigned n, unsigned m, typename T>
inline
- mat<n,m,T> mat<n,m,T>::identity()
+ mat<n,m,T>
+ mat<n,m,T>::identity()
{
static mat<n,m,T> id_;
static bool flower = true;
@@ -369,6 +431,18 @@
return n * m;
}
+ template <unsigned n, unsigned m, typename T>
+ inline
+ mat<m,n,T>
+ mat<n,m,T>::t() const
+ {
+ mat<m,n,T> tmp;
+ for (unsigned i = 0; i < n; ++i)
+ for (unsigned j = 0; j < m; ++j)
+ tmp(j,i) = data_[i][j];
+ return tmp;
+ }
+
// Operators.
@@ -421,6 +495,8 @@
return tmp;
}
+ // mat * mat
+
template <unsigned n, unsigned o, typename T,
unsigned m, typename U>
inline
@@ -438,6 +514,20 @@
return tmp;
}
+ template <unsigned o, typename T,
+ typename U>
+ inline
+ mln_sum_product(T,U)
+ operator*(const mat<1,o,T>& lhs, const mat<o,1,U>& rhs)
+ {
+ mln_sum_product(T,U) tmp(literal::zero);
+ for (unsigned k = 0; k < o; ++k)
+ tmp += lhs(0, k) * rhs(k, 0);
+ return tmp;
+ }
+
+ // mat * vec
+
template <unsigned n, unsigned m, typename T,
typename U>
inline
@@ -455,6 +545,35 @@
return tmp;
}
+ template <unsigned m, typename T,
+ typename U>
+ inline
+ mln_sum_product(T,U) // scalar
+ operator*(const mat<1,m,T>& lhs, const vec<m,U>& rhs)
+ {
+ mln_sum_product(T,U) tmp(literal::zero);
+ for (unsigned j = 0; j < m; ++j)
+ tmp += lhs(0, j) * rhs[j];
+ return tmp;
+ }
+
+ // vec * mat
+
+ template <unsigned m, typename T,
+ typename U>
+ inline
+ mat<m, m, mln_trait_op_times(T,U)>
+ operator*(const vec<m,T>& lhs, const mat<1,m,U>& rhs)
+ {
+ mat<m, m, mln_trait_op_times(T,U)> tmp;
+ for (unsigned i = 0; i < m; ++i)
+ for (unsigned j = 0; j < m; ++j)
+ tmp(i, j) = lhs[i] * rhs(0, j);
+ return tmp;
+ }
+
+ // mat * s
+
template <unsigned n, unsigned m, typename T, typename S>
inline
mat<n, m, mln_trait_op_times(T,S)>
@@ -499,16 +618,7 @@
}
- template<unsigned n, unsigned m, typename T>
- mat<m,n,T>
- trans(const mat<n,m,T>& matrix)
- {
- mat<m,n,T> tmp;
- for (unsigned i = 0; i < n; ++i)
- for (unsigned j = 0; j < m; ++j)
- tmp(j,i) = matrix(i,j);
- return tmp;
- }
+ // Trace.
template<unsigned n, typename T> inline
float tr(const mat<n,n,T>& m)
@@ -519,6 +629,20 @@
return f;
}
+
+ // vec methods.
+
+ template <unsigned n, typename T>
+ inline
+ mat<1,n,T>
+ vec<n,T>::t() const
+ {
+ mat<1,n,T> tmp;
+ for (unsigned i = 0; i < n; ++i)
+ tmp(0,i) = data_[i];
+ return tmp;
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::algebra
Index: mln/algebra/vec.hh
--- mln/algebra/vec.hh (revision 3690)
+++ mln/algebra/vec.hh (working copy)
@@ -59,6 +59,7 @@
namespace algebra {
template <unsigned n, typename T> class vec;
template <unsigned d, typename C> class h_vec;
+ template <unsigned n, unsigned m, typename T> class mat;
}
namespace literal {
@@ -235,6 +236,9 @@
lower (sic) to zero. */
const vec<n, T>& normalize();
+ /// Transposition.
+ mat<1, n, T> t() const;
+
/// Constructor; coordinates are set by function \p f.
template <typename F>
vec(const Function_i2v<F>& f);
@@ -244,6 +248,19 @@
/// Origin value.
static const vec<n, T> origin;
+
+
+ /// Conversion to a matrix.
+ template <typename U>
+ operator mat<n, 1, U>() const;
+
+ /// Construction from a matrix.
+ template <typename U>
+ vec(const mat<n, 1, U>& rhs);
+
+ /// Assignment from a matrix.
+ template <typename U>
+ vec& operator=(const mat<n, 1, U>& rhs);
};
} // end of namespace mln::algebra
@@ -632,6 +649,7 @@
# include <mln/make/vec.hh>
+# include <mln/algebra/mat.hh>
#endif // ! MLN_ALGEBRA_VEC_HH
Index: mln/registration/get_rot.hh
--- mln/registration/get_rot.hh (revision 3690)
+++ mln/registration/get_rot.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory
// (LRDE)
//
// This file is part of the Olena Library. This library is free
@@ -35,6 +35,7 @@
# include <mln/algebra/vec.hh>
# include <mln/math/jacobi.hh>
+
namespace mln
{
@@ -97,7 +98,7 @@
{
algebra::vec<3u,float> ci = convert::to< algebra::vec<3u,float> >(c[i]);
algebra::vec<3u,float> xki = convert::to< algebra::vec<3u,float> >(map(ck[i]));
- Mk += make::mat(ci - mu_c) * trans(make::mat(xki - mu_xk));
+ Mk += (ci - mu_c) * (xki - mu_xk).t();
}
Mk /= c.nsites();
Index: mln/registration/icp.hh
--- mln/registration/icp.hh (revision 3690)
+++ mln/registration/icp.hh (working copy)
@@ -78,10 +78,10 @@
# include <mln/io/cloud/save.hh>
+
namespace mln
{
-
namespace registration
{
@@ -530,7 +530,7 @@
vec3d_f P_i = p;
vec3d_f Pk_i = qR.rotate(P_i) + qT;
vec3d_f Yk_i = closest_point(Pk_i);
- Spx += make::mat(P_i - mu_P) * trans(make::mat(Yk_i - mu_Yk));
+ Spx += (P_i - mu_P) * (Yk_i - mu_Yk).t();
}
Spx /= P_.nsites();
Index: mln/labeling/compute.hh
--- mln/labeling/compute.hh (revision 3690)
+++ mln/labeling/compute.hh (working copy)
@@ -145,7 +145,7 @@
{
mln_precondition(exact(input).is_valid());
mln_precondition(exact(label).is_valid());
- mlc_is_a(mln_value(L), mln::value::Symbolic)::check();
+ // mlc_is_a(mln_value(L), mln::value::Symbolic)::check();
(void) a;
(void) input;
(void) label;
Index: tests/accu/image/take_as_init.cc
--- tests/accu/image/take_as_init.cc (revision 3690)
+++ tests/accu/image/take_as_init.cc (working copy)
@@ -45,4 +45,7 @@
accu::image::take_as_init(ima, 3);
debug::println(ima);
+
+ accu::image::take_as_init(ima, ima);
+ debug::println(ima);
}
Index: tests/algebra/op_times.cc
--- tests/algebra/op_times.cc (revision 0)
+++ tests/algebra/op_times.cc (revision 0)
@@ -0,0 +1,72 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/// \file tests/algebra/op_times.cc
+///
+/// Tests on mln::algebra::operator *.
+
+#include <iostream>
+#include <mln/algebra/mat.hh>
+
+
+
+int main()
+{
+ using namespace mln;
+
+ using algebra::vec;
+ using algebra::mat;
+
+ // Debase tests.
+ {
+ algebra::vec<3, float> v3;
+ algebra::mat<2,3,float> m23;
+ algebra::mat<3,2,float> m32;
+
+ algebra::mat<2,2,float> m22 = m23 * m32;
+ algebra::vec<2, float> v2 = m23 * v3;
+
+ m22 = v2 * v2.t();
+ }
+
+ // Tests with horizontal and/or vertical matrices and/or vectors.
+ {
+ float f;
+ algebra::vec<3, float> v3;
+ algebra::mat<1,3,float> m13;
+ algebra::mat<3,1,float> m31;
+
+ f = m13 * m31;
+ f = m31.t() * m13.t();
+ f = m13 * v3;
+ f = v3.t() * v3;
+
+ v3 = m31;
+ m31 = v3;
+ }
+
+}
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog:
2009-04-20 Vincent Ordy <ordy(a)lrde.epita.fr>
Fix configure.
* configure:
Add rules to Makefile.rules without erasing the old file.
---
configure | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
Index: trunk/milena/sandbox/inim/2010/boxes/configure
===================================================================
--- trunk/milena/sandbox/inim/2010/boxes/configure (revision 3689)
+++ trunk/milena/sandbox/inim/2010/boxes/configure (revision 3690)
@@ -19,9 +19,9 @@
touch Makefile.rules
if [ "$debug" ]; then
- echo 'DEBUG = 1' > Makefile.rules
+ echo 'DEBUG = 1' >> Makefile.rules
fi
if [ "$release" ]; then
- echo 'RELEASE = 1' > Makefile.rules
+ echo 'RELEASE = 1' >> Makefile.rules
fi
-echo "MLN_DIR = $MLN_DIR" > Makefile.rules
+echo "MLN_DIR = $MLN_DIR" >> Makefile.rules
1
0