LRE
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
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
List overview
Download
Olena-patches
April 2009
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
olena-patches@lrde.epita.fr
11 participants
187 discussions
Start a n
N
ew thread
milena r3654: Merge changes in component tree file
by Edwin Carlinet
URL:
https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog: 2009-04-10 Edwin Carlinet <carlinet(a)lrde.epita.fr> Merge changes in component tree file. * mln/morpho/tree/data.hh: Resolve conflicts between theo's and edwin's code. --- data.hh | 4 ---- 1 file changed, 4 deletions(-) Index: trunk/milena/mln/morpho/tree/data.hh =================================================================== --- trunk/milena/mln/morpho/tree/data.hh (revision 3653) +++ trunk/milena/mln/morpho/tree/data.hh (revision 3654) @@ -51,10 +51,6 @@ # define mln_leaf_piter(T) typename T::leaf_piter # define mln_preorder_piter(T) typename T::preorder_piter -# define mln_site_piter(T) typename T::up_site_piter -# define mln_node_piter(T) typename T::up_node_piter -# define mln_leaf_piter(T) typename T::up_leaf_piter - # define mln_up_site_piter_(T) T::up_site_piter # define mln_dn_site_piter_(T) T::dn_site_piter # define mln_up_node_piter_(T) T::up_node_piter
15 years, 8 months
1
0
0
0
r3653: Fix bugs related to 'glut leaves' process
by Edwin Carlinet
URL:
https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog: 2009-04-10 Edwin Carlinet <carlinet(a)lrde.epita.fr> Fix bugs related to 'glut leaves' process. * edwin/tree/propagate_node.hh: Minor changes. * edwin/tree/run.hh: Fix bugs. * edwin/tree/sharp.cc: Nothing important. --- propagate_node.hh | 3 +++ run.hh | 6 +++--- sharp.cc | 6 +++--- 3 files changed, 9 insertions(+), 6 deletions(-) Index: trunk/milena/sandbox/edwin/tree/sharp.cc =================================================================== --- trunk/milena/sandbox/edwin/tree/sharp.cc (revision 3652) +++ trunk/milena/sandbox/edwin/tree/sharp.cc (revision 3653) @@ -190,11 +190,11 @@ dsp(s.str()); } - if (sharpness != 0) { + if (nb_components) { + obj_array = morpho::tree::run_ntimes(tree, a, argmax, nb_components); + } else if (sharpness > 0) { mln_VAR(predicate, pw::value(a) > pw::cst(sharpness)); obj_array = morpho::tree::run_while(tree, a, argmax, predicate); - } else if (nb_components) { - obj_array = morpho::tree::run_ntimes(tree, a, argmax, nb_components); } else { obj_array = morpho::tree::run_until_glutted_leaves(tree, a, argmax); } Index: trunk/milena/sandbox/edwin/tree/run.hh =================================================================== --- trunk/milena/sandbox/edwin/tree/run.hh (revision 3652) +++ trunk/milena/sandbox/edwin/tree/run.hh (revision 3653) @@ -139,12 +139,9 @@ arr_values.append(a(p)); morpho::tree::propagate_node_to_descendants(p, tree, a, 0, 0); morpho::tree::propagate_node_to_ancestors(p, tree, a, 0); - if (pred(p)) // may have changed - { a(p) = 0; p = morpho::tree::run(tree, a, accu); } - } for (unsigned i = 0; i < arr_sites.nsites(); i++) a(arr_sites[i]) = arr_values[i]; return arr_sites; @@ -225,11 +222,14 @@ do { p = morpho::tree::run(tree, a, acc); + if (a(p) == 0) + break; arr_sites.insert(p); arr_values.append(a(p)); morpho::tree::propagate_node_to_descendants(p, tree, a, 0, &nb_leaves); morpho::tree::propagate_node_to_ancestors(p, tree, a, 0); a(p) = 0; + mln_assertion(nb_leaves <= n); } while ((n -= nb_leaves)); Index: trunk/milena/sandbox/edwin/tree/propagate_node.hh =================================================================== --- trunk/milena/sandbox/edwin/tree/propagate_node.hh (revision 3652) +++ trunk/milena/sandbox/edwin/tree/propagate_node.hh (revision 3653) @@ -113,6 +113,7 @@ template <typename T, typename A> + inline void propagate_node_to_descendants(mln_psite(A) n, const T& t, @@ -133,8 +134,10 @@ typename T::preorder_piter pp(t, n); pp.start(); // We don't set n to v. + if (nb_leaves) *nb_leaves = t.is_a_leaf(pp); + for (pp.next(); pp.is_valid(); pp.next()) { a(pp) = v;
15 years, 8 months
1
0
0
0
3651: Handle tiff orientation in scalar images.
by Thierry Geraud
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog from Thierry Geraud <thierry.geraud(a)lrde.epita.fr> Handle tiff orientation in scalar images. * mln/io/tiff/load.hh: Handle tiff orientation in scalar images. * tests/io/tiff: New directory. * tests/io/tiff/tiff2pbm.cc: New. mln/io/tiff/load.hh | 109 +++++++++++++++++++++++++++++++++++++++++----- tests/io/tiff/tiff2pbm.cc | 23 +++++++++ 2 files changed, 122 insertions(+), 10 deletions(-) Index: mln/io/tiff/load.hh --- mln/io/tiff/load.hh (revision 3650) +++ mln/io/tiff/load.hh (working copy) @@ -69,6 +69,56 @@ namespace internal { + inline + point2d ij2rc_1(int i, int j, int ni_1, int nj_1) + { + return point2d(ni_1 - i, j); + } + + inline + point2d ij2rc_2(int i, int j, int ni_1, int nj_1) + { + return point2d(ni_1 - i, nj_1 - j); + } + + inline + point2d ij2rc_3(int i, int j, int ni_1, int nj_1) + { + return point2d(i, nj_1 - j); + } + + inline + point2d ij2rc_4(int i, int j, int ni_1, int nj_1) + { + return point2d(i, j); + } + + inline + point2d ij2rc_5(int i, int j, int ni_1, int nj_1) + { + return point2d(j, ni_1 - i); + } + + inline + point2d ij2rc_6(int i, int j, int ni_1, int nj_1) + { + return point2d(nj_1 - j, ni_1 - i); + } + + inline + point2d ij2rc_7(int i, int j, int ni_1, int nj_1) + { + return point2d(nj_1 - j, i); + } + + inline + point2d ij2rc_8(int i, int j, int ni_1, int nj_1) + { + return point2d(j, i); + } + + + template <typename I> inline void load_header(I& ima, TIFF *file) @@ -134,6 +184,9 @@ _TIFFfree(raster); } + + + template <typename I> inline void load_data_scalar(I& ima, TIFF *file) @@ -147,25 +200,61 @@ abort(); } + uint32 npixels = ima.ncols() * ima.nrows(); uint32 *raster = (uint32 *) _TIFFmalloc(npixels * sizeof (uint32)); TIFFReadRGBAImage(file, ima.ncols(), ima.nrows(), raster, 0); - unsigned i = ima.nrows() - 1; - unsigned j = 0; - mln_piter(I) p(ima.domain()); - for_all(p) + + uint16 orientation; + TIFFGetField(file, TIFFTAG_ORIENTATION, &orientation); + + typedef point2d (*fun_t)(int, int, int, int); + fun_t funs[] = { 0, ij2rc_1, ij2rc_2, ij2rc_3, ij2rc_4, ij2rc_5, ij2rc_6, ij2rc_7, ij2rc_8 }; + fun_t fun = funs[orientation]; + + int ni_1, nj_1; + unsigned idx = 0; + + if (orientation <= 4) { - unsigned idx = i * ima.ncols() + j; - ima(p) = (unsigned char) TIFFGetR(raster[idx]); - ++j; - if (!(j%ima.ncols())) + ni_1 = ima.nrows() - 1; + nj_1 = ima.ncols() - 1; + for (unsigned i = 0; i <= ni_1; ++i) + for (unsigned j = 0; j <= nj_1; ++j) { - --i; - j = 0; + ima((*fun)(i, j, ni_1, nj_1)) = (unsigned char) TIFFGetR(raster[idx++]); } } + else + { + nj_1 = ima.nrows() - 1; + ni_1 = ima.ncols() - 1; + for (unsigned j = 0; j <= nj_1; ++j) + for (unsigned i = 0; i <= ni_1; ++i) + { + ima((*fun)(i, j, ni_1, nj_1)) = (unsigned char) TIFFGetR(raster[idx++]); + } + } + + std::cout << std::endl; + + +// unsigned i = ima.nrows() - 1; +// unsigned j = 0; +// mln_piter(I) p(ima.domain()); +// for_all(p) +// { +// unsigned idx = i * ima.ncols() + j; +// ima(p) = (unsigned char) TIFFGetR(raster[idx]); +// ++j; +// if (!(j%ima.ncols())) +// { +// --i; +// j = 0; +// } +// } _TIFFfree(raster); } Index: tests/io/tiff/tiff2pbm.cc --- tests/io/tiff/tiff2pbm.cc (revision 0) +++ tests/io/tiff/tiff2pbm.cc (revision 0) @@ -0,0 +1,23 @@ +#include <mln/core/image/image2d.hh> +#include <mln/io/tiff/load.hh> +#include <mln/io/pbm/save.hh> +// #include <mln/level/convert.hh> + + +int main(int argc, char *argv[]) +{ + using namespace mln; + + if (argc < 3) + { + std::cout << "Usage: " << argv[0] << " <input.tiff> <output.pbm>" << std::endl; + return 1; + } + + image2d<bool> ima; + io::tiff::load(ima, argv[1]); + io::pbm::save(ima, argv[2]); + +// io::ppm::save(ima, argv[2]); +// io::pbm::save(level::convert(bool(), ima), argv[2]); +}
15 years, 8 months
1
0
0
0
3650: Forget it.
by Thierry Geraud
https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
Index: ChangeLog from Thierry Geraud <thierry.geraud(a)lrde.epita.fr> Forget it. * icdar/2009/hsc/ws_to_wsl.hh: Prefer testing n() v. 0. ws_to_wsl.hh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) Index: icdar/2009/hsc/ws_to_wsl.hh --- icdar/2009/hsc/ws_to_wsl.hh (revision 3649) +++ icdar/2009/hsc/ws_to_wsl.hh (working copy) @@ -306,15 +306,16 @@ & m1 = m[i1], & m2 = m[i2]; -// if (m1.n() != 0 && m2.n() != 0) + if (m1.n() != 0 && m2.n() != 0) + d(e) = dist(m1, m2); + else + d(e) = 666.f; + +// if (m1.n() > 1000 && m2.n() > 1000) // FIXME: was 1000 // d(e) = dist(m1, m2); // else // d(e) = 666.f; - if (m1.n() > 10 && m2.n() > 10) // FIXME: was 1000 - d(e) = dist(m1, m2); - else - d(e) = 666.f; } }
15 years, 8 months
1
0
0
0
3649: Improve and fix lut_vec with fun::i2v::array and fun::l2l::relabel.
by Guillaume Lazzara
* mln/fun/internal/array_base.hh: add accessor to the underlying std vector. * mln/value/lut_vec.hh: Use directly fun::i2v::array and fun::l2l::relabel as lut. --- milena/ChangeLog | 10 +++++++ milena/mln/fun/internal/array_base.hh | 11 ++++++++ milena/mln/value/lut_vec.hh | 44 +++++++++++++++++++++++++++++++- 3 files changed, 63 insertions(+), 2 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index 87e74e0..5d91084 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,3 +1,13 @@ +2009-04-08 Guillaume Lazzara <lazzara(a)lrde.epita.fr> + + Improve and fix lut_vec with fun::i2v::array and fun::l2l::relabel. + + * mln/fun/internal/array_base.hh: add accessor to the underlying std + vector. + + * mln/value/lut_vec.hh: Use directly fun::i2v::array and + fun::l2l::relabel as lut. + 2009-04-08 Guillaume Lazzara <lazzara(a)lrde.epita.fr> Remove debug in io::tiff::load. diff --git a/milena/mln/fun/internal/array_base.hh b/milena/mln/fun/internal/array_base.hh index d288c53..577b36f 100644 --- a/milena/mln/fun/internal/array_base.hh +++ b/milena/mln/fun/internal/array_base.hh @@ -80,6 +80,9 @@ namespace mln /// Initialize an empty function. void init_(unsigned n); + /// Return the underlying std::vector. + const std::vector<T>& std_vector() const; + protected: std::vector<T> v_; @@ -222,6 +225,14 @@ namespace mln v_.resize(n); } + template <typename T> + inline + const std::vector<T>& + array_base<T>::std_vector() const + { + return v_; + } + } // end of namespace mln::fun::internal } // end of namespace mln::fun diff --git a/milena/mln/value/lut_vec.hh b/milena/mln/value/lut_vec.hh index 914eb78..6aa2e32 100644 --- a/milena/mln/value/lut_vec.hh +++ b/milena/mln/value/lut_vec.hh @@ -45,6 +45,16 @@ namespace mln { + /// Forward declarations. + namespace fun { + namespace i2v { + template <typename T> class array; + } // end of namespace mln::fun::i2v + namespace l2l { + template <typename L> class relabel; + } // end of namespace mln::fun::l2l + } // end of namespace mln::fun + namespace value { @@ -53,8 +63,8 @@ namespace mln template <typename S> struct bkd_viter_; - /*! \brief Class that defines FIXME - * + /// Class that defines FIXME + /*! * \warning This is a multi-set!!! * FIXME * @@ -90,6 +100,14 @@ namespace mln template <typename F> lut_vec(const S& vset, const Function_v2v<F>& f); + /// Ctor. FIXME! + template <typename V> + lut_vec(const S& vset, const Function_v2v< fun::i2v::array<V> >& f); + + /// Ctor. FIXME! + template <typename V> + lut_vec(const S& vset, const Function_v2v< fun::l2l::relabel<V> >& f); + protected: const S& vset_; @@ -137,6 +155,28 @@ namespace mln } template <typename S, typename T> + template <typename V> + inline + lut_vec<S,T>::lut_vec(const S& vset, const Function_v2v< fun::i2v::array<V> >& f) + : vset_(vset) + { + const fun::i2v::array<V>& f_ = exact(f); + n_ = f_.size(); + vec_ = f_.std_vector(); + } + + template <typename S, typename T> + template <typename V> + inline + lut_vec<S,T>::lut_vec(const S& vset, const Function_v2v< fun::l2l::relabel<V> >& f) + : vset_(vset) + { + const fun::l2l::relabel<V>& f_ = exact(f); + n_ = f_.size(); + vec_ = f_.std_vector(); + } + + template <typename S, typename T> inline T lut_vec<S,T>::operator()(const mln_value(S)& val) const -- 1.5.6.5
15 years, 8 months
1
0
0
0
3648: Remove debug in io::tiff::load.
by Guillaume Lazzara
* mln/io/tiff/load.hh: Remove debug. --- milena/ChangeLog | 7 +++++++ milena/mln/io/tiff/load.hh | 3 --- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index 5b19a15..87e74e0 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,4 +1,11 @@ 2009-04-08 Guillaume Lazzara <lazzara(a)lrde.epita.fr> + + Remove debug in io::tiff::load. + + * mln/io/tiff/load.hh: Remove debug. + + +2009-04-08 Guillaume Lazzara <lazzara(a)lrde.epita.fr> Fix io::tiff::load. diff --git a/milena/mln/io/tiff/load.hh b/milena/mln/io/tiff/load.hh index fcae4ac..e69685e 100644 --- a/milena/mln/io/tiff/load.hh +++ b/milena/mln/io/tiff/load.hh @@ -78,10 +78,7 @@ namespace mln TIFFGetField(file, TIFFTAG_IMAGEWIDTH, &width); TIFFGetField(file, TIFFTAG_IMAGELENGTH, &height); - std::cout << "height == " << height << " - width == " << width << std::endl; mln_concrete(I) new_ima(height, width, 0); - std::cout << "nrows == " << new_ima.nrows() << " - ncols == " << new_ima.ncols() << std::endl; - std::cout << "nrows == height and ncols == width" << std::endl; exact(ima) = new_ima; } -- 1.5.6.5
15 years, 8 months
1
0
0
0
3647: Fix io::tiff::load.
by Guillaume Lazzara
* mln/io/tiff/load.hh: Fix a bug while reading the input file. --- milena/ChangeLog | 6 ++++++ milena/mln/io/tiff/load.hh | 26 +++++++++++++++++--------- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index 7242150..5b19a15 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,3 +1,9 @@ +2009-04-08 Guillaume Lazzara <lazzara(a)lrde.epita.fr> + + Fix io::tiff::load. + + * mln/io/tiff/load.hh: Fix a bug while reading the input file. + 2009-04-08 Thierry Geraud <thierry.geraud(a)lrde.epita.fr> Minor modifications + fix. diff --git a/milena/mln/io/tiff/load.hh b/milena/mln/io/tiff/load.hh index 0cb2b86..fcae4ac 100644 --- a/milena/mln/io/tiff/load.hh +++ b/milena/mln/io/tiff/load.hh @@ -34,6 +34,7 @@ /// Load TIFF images to Milena images. /// /// \todo Add support for several tiles. +/// \todo Handle TIFFTAG_ORIENTATION (origin of the image). # include <iostream> @@ -70,16 +71,18 @@ namespace mln template <typename I> inline - void load_header(Image<I>& ima, TIFF *file) + void load_header(I& ima, TIFF *file) { uint32 width, height; TIFFGetField(file, TIFFTAG_IMAGEWIDTH, &width); TIFFGetField(file, TIFFTAG_IMAGELENGTH, &height); + std::cout << "height == " << height << " - width == " << width << std::endl; mln_concrete(I) new_ima(height, width, 0); + std::cout << "nrows == " << new_ima.nrows() << " - ncols == " << new_ima.ncols() << std::endl; + std::cout << "nrows == height and ncols == width" << std::endl; exact(ima) = new_ima; - } @@ -88,8 +91,10 @@ namespace mln void load_data_rgb8(I& ima, TIFF *file) { uint16 bits_per_sample, samples_per_pixel; + TIFFGetField(file, TIFFTAG_BITSPERSAMPLE, &bits_per_sample); TIFFGetField(file, TIFFTAG_SAMPLESPERPIXEL, &samples_per_pixel); + uint16 data_size = bits_per_sample * samples_per_pixel; if (data_size != 24 || data_size != 32) { @@ -108,19 +113,21 @@ namespace mln abort(); } - unsigned i = ima.ncols() - 1; + unsigned i = ima.nrows() - 1; unsigned j = 0; mln_piter(I) p(ima.domain()); for_all(p) { unsigned idx = i * ima.ncols() + j; value::rgb8 v; + v.red() = (unsigned char) TIFFGetR(raster[idx]); v.green() = (unsigned char) TIFFGetG(raster[idx]); v.blue() = (unsigned char) TIFFGetB(raster[idx]); ima(p) = v; + ++j; - if (!(j%ima.nrows())) + if (!(j%ima.ncols())) { --i; j = 0; @@ -148,7 +155,7 @@ namespace mln TIFFReadRGBAImage(file, ima.ncols(), ima.nrows(), raster, 0); - unsigned i = ima.ncols() - 1; + unsigned i = ima.nrows() - 1; unsigned j = 0; mln_piter(I) p(ima.domain()); for_all(p) @@ -156,7 +163,7 @@ namespace mln unsigned idx = i * ima.ncols() + j; ima(p) = (unsigned char) TIFFGetR(raster[idx]); ++j; - if (!(j%ima.nrows())) + if (!(j%ima.ncols())) { --i; j = 0; @@ -194,7 +201,7 @@ namespace mln template <typename I> inline void - load_data_dispatch(Image<I>& ima, TIFF *file) + load_data_dispatch(I& ima, TIFF *file) { load_data_dispatch(mln_value(I)(), exact(ima), file); } @@ -221,11 +228,12 @@ namespace mln abort(); } - internal::load_header(ima, file); - internal::load_data_dispatch(ima, file); + internal::load_header(exact(ima), file); + internal::load_data_dispatch(exact(ima), file); mln_postcondition(exact(ima).is_valid()); + (void) TIFFClose(file); trace::exiting("mln::io::tiff::load"); } -- 1.5.6.5
15 years, 8 months
1
0
0
0
3646: Minor modifications + fix.
by Thierry Geraud
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog from Thierry Geraud <thierry.geraud(a)lrde.epita.fr> Minor modifications + fix. * mln/morpho/tree/data.hh (mln_site_piter, mln_node_piter, mln_leaf_piter): New. * mln/morpho/attribute/height.hh: Layout. * mln/morpho/general.spe.hh (general_dispatch_for_generic): Fix unwanted trace. * mln/labeling/blobs.hh (todo): New. labeling/blobs.hh | 2 ++ morpho/attribute/height.hh | 16 ++++++++++++---- morpho/general.spe.hh | 6 ++---- morpho/tree/data.hh | 9 +++++++-- 4 files changed, 23 insertions(+), 10 deletions(-) Index: mln/morpho/tree/data.hh --- mln/morpho/tree/data.hh (revision 3645) +++ mln/morpho/tree/data.hh (working copy) @@ -31,9 +31,8 @@ /// \file mln/morpho/tree/data.hh /// -/// TODO: think about site iterator (using image site iterator instead +/// \todo Think about site iterator (using image site iterator instead /// of S container iterator) to go faster. -/// # include <mln/morpho/tree/compute_parent.hh> # include <mln/core/site_set/p_array.hh> @@ -52,6 +51,10 @@ # define mln_leaf_piter(T) typename T::leaf_piter # define mln_preorder_piter(T) typename T::preorder_piter +# define mln_site_piter(T) typename T::up_site_piter +# define mln_node_piter(T) typename T::up_node_piter +# define mln_leaf_piter(T) typename T::up_leaf_piter + # define mln_up_site_piter_(T) T::up_site_piter # define mln_dn_site_piter_(T) T::dn_site_piter # define mln_up_node_piter_(T) T::up_node_piter @@ -63,6 +66,7 @@ # define mln_leaf_piter_(T) T::leaf_piter # define mln_preorder_piter_(T) T::preorder_piter + namespace mln { @@ -134,6 +138,7 @@ typedef mln::morpho::tree::preorder_piter<self_> preorder_piter; + /// Constructor. template <typename N> data(const Image<I>& f, const Site_Set<S>& s, const Neighborhood<N>& nbh); Index: mln/morpho/attribute/height.hh --- mln/morpho/attribute/height.hh (revision 3645) +++ mln/morpho/attribute/height.hh (working copy) @@ -41,7 +41,8 @@ # include <mln/math/max.hh> -namespace mln { +namespace mln +{ // Forward declaration. namespace morpho { @@ -53,7 +54,8 @@ // Traits. - namespace trait { + namespace trait + { template <typename I> struct accumulator_< morpho::attribute::height<I> > @@ -67,8 +69,11 @@ } // end of namespace mln::trait - namespace morpho { - namespace attribute { + namespace morpho + { + + namespace attribute + { /// Height accumulator class. /// @@ -211,8 +216,11 @@ } # endif // ! MLN_INCLUDE_ONLY + } // end of namespace mln::morpho::attribute + } // end of namespace mln::morpho + } // end of namespace mln Index: mln/morpho/general.spe.hh --- mln/morpho/general.spe.hh (revision 3645) +++ mln/morpho/general.spe.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 @@ -330,12 +330,10 @@ mln_concrete(I) general_dispatch_for_generic(const Op& op, const I& input, const W& win) // Entry point. { - trace::entering("morpho::general_dispatch_for_generic"); mln_concrete(I) ima = general_dispatch_for_generic(mln_trait_image_kind(I)(), mln_trait_image_speed(I)(), op, input, win); - trace::entering("morpho::general_dispatch_for_generic"); return ima; } Index: mln/labeling/blobs.hh --- mln/labeling/blobs.hh (revision 3645) +++ mln/labeling/blobs.hh (working copy) @@ -35,6 +35,8 @@ /// image using a queue-based algorithm. /// /// \todo Handle abort in a nice way... +/// +/// \todo Add a 2nd version precising the 'level' to label. # include <mln/core/concept/image.hh> # include <mln/core/concept/neighborhood.hh>
15 years, 8 months
1
0
0
0
3645: Add a document-to-words routine based on lines.
by Thierry Geraud
https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
Index: ChangeLog from Thierry Geraud <thierry.geraud(a)lrde.epita.fr> Add a document-to-words routine based on lines. * icdar/2009/hsc/input_to_lines.hh (tau): New. * icdar/2009/hsc/input_to_lines_dat.cc: Update. * icdar/2009/hsc/input_to_words_dat.cc: New. * icdar/2009/hsc/line_to_words.hh (black_on_white, reduce): New. * icdar/2009/hsc/get_line_images.hh: Fix 1st elt, at index 0. get_line_images.hh | 13 +++++++-- input_to_lines.hh | 5 ++- input_to_lines_dat.cc | 2 - input_to_words_dat.cc | 64 ++++++++++++++++++++++++++++++++++++++++----- line_to_words.hh | 71 +++++++++++++++++++++++++++++++++++++++++++------- 5 files changed, 134 insertions(+), 21 deletions(-) Index: icdar/2009/hsc/input_to_lines.hh --- icdar/2009/hsc/input_to_lines.hh (revision 3644) +++ icdar/2009/hsc/input_to_lines.hh (working copy) @@ -16,7 +16,8 @@ template <typename L> image2d<L> - input_to_lines(const image2d<bool>& raw_input, L& n_lines) + input_to_lines(const image2d<bool>& raw_input, L& n_lines, + float tau) { // First clean. image2d<bool> input = clean_input(raw_input); @@ -35,7 +36,7 @@ wsl = ws_to_wslines(input, small, ws, n_reg); // Clean lines - wsl = clean_lines(input, wsl, 0.7f); + wsl = clean_lines(input, wsl, tau); return labeling::relabel(violent_cast_image_<L>(wsl), n_lines); Index: icdar/2009/hsc/input_to_words_dat.cc --- icdar/2009/hsc/input_to_words_dat.cc (revision 3644) +++ icdar/2009/hsc/input_to_words_dat.cc (working copy) @@ -4,12 +4,34 @@ #include <mln/io/pbm/load.hh> #include <mln/io/ppm/save.hh> #include <mln/debug/colorize.hh> +#include <mln/estim/min_max.hh> -#include <sandbox/icdar/2009/hsc/clean_input.hh> +#include <sandbox/icdar/2009/hsc/input_to_lines.hh> #include <sandbox/icdar/2009/hsc/line_to_words.hh> +#include <sandbox/icdar/2009/hsc/get_line_images.hh> #include <sandbox/icdar/2009/hsc/io/icdar/save.hh> +namespace mln +{ + + template <typename L> + void + paste_words(image2d<L>& output, + const image2d<L>& words, + L l_1st) + { + mln_piter(box2d) p(words.domain()); + for_all(p) + { + if (words(p) == 0) + continue; + output(p) = l_1st.to_enc() + words(p).to_enc(); + } + } + +} // mln + void usage(char* argv[]) @@ -27,7 +49,6 @@ int main(int argc, char* argv[]) { using namespace mln; - using value::int_u16; if (argc != 3 && argc != 4) usage(argv); @@ -35,15 +56,46 @@ trace::entering("main"); + typedef image2d<bool> I_bw; - image2d<bool> input; + I_bw input; io::pbm::load(input, argv[1]); - input = clean_input(input); + typedef value::label<12> Ll; + Ll n_lines; + image2d<Ll> lines = input_to_lines(input, n_lines, 0.501); // with majoritary + + // std::cout << "n lines = " << n_lines << std::endl; + + typedef value::int_u16 L; - int_u16 n_words; - image2d<int_u16> output = line_to_words(input, n_words); + image2d<L> output(input.domain()); + data::fill(output, 0); + + util::array<I_bw> line_ = get_line_images(lines, n_lines, 51); + + L n_words = 0; + for (unsigned l = 1; l <= n_lines; ++l) + { + I_bw line = line_[l]; // A line image. + + L n_line_words = 0; + image2d<L> words = line_to_words(line, n_line_words, false); + paste_words(output, words, /* 1st label is */ n_words); + + // std::cout << "line = " << l + // << " n_words = " << n_line_words << std::endl; + + n_words += n_line_words; + } + + { + // L l_min, l_max; + // estim::min_max(output, l_min, l_max); + // if (l_max != n_words) + // std::cout << "oops: " << l_max << ' ' << n_words << std::endl; + } io::icdar::save(output, argv[2]); Property changes on: icdar/2009/hsc/input_to_words_dat.cc ___________________________________________________________________ Added: svn:mergeinfo Index: icdar/2009/hsc/line_to_words.hh --- icdar/2009/hsc/line_to_words.hh (revision 3644) +++ icdar/2009/hsc/line_to_words.hh (working copy) @@ -12,20 +12,25 @@ #include <mln/morpho/elementary/dilation.hh> #include <mln/morpho/watershed/flooding.hh> +#include <mln/io/pbm/save.hh> +#include <mln/io/pgm/save.hh> +#include <mln/io/ppm/save.hh> +#include <mln/labeling/wrap.hh> namespace mln { - - image2d<bool> // Fwd decl. - reduce_negate(const image2d<bool>& input); + // Fwd decl. + image2d<bool> reduce (const image2d<bool>& input); + image2d<bool> reduce_negate(const image2d<bool>& input); template <typename L> image2d<L> - line_to_words(const image2d<bool>& input, L& n_words) + line_to_words(const image2d<bool>& input, L& n_words, + bool black_on_white = true) { // Parameters. @@ -37,12 +42,20 @@ // end of Parameters. - image2d<bool> - sub = reduce_negate(input), + image2d<bool> sub, clo; + + if (black_on_white) + sub = reduce_negate(input); + else + sub = reduce(input); + clo = morpho::closing::structural(sub, win::rectangle2d(height, width)); + // io::pbm::save(sub, "tmp_sub.pbm"); + // io::pbm::save(clo, "tmp_clo.pbm"); + int ww[] = { 00, 11, 0, 11, 0, 11, 7, 5, 7, 11, 00, 5, 0, 5, 0, @@ -56,11 +69,21 @@ mln_max(int_u12)), dmap_ = morpho::closing::area(dmap, c4(), l_area); - image2d<L> ws = morpho::elementary::dilation(morpho::watershed::flooding(dmap_, + + // io::pgm::save(labeling::wrap(dmap), "tmp_dmap.pgm"); + // io::pgm::save(labeling::wrap(dmap_), "tmp_dmap_.pgm"); + + + image2d<L> ws_ = morpho::watershed::flooding(dmap_, c4(), - n_words), + n_words); + image2d<L> ws = morpho::elementary::dilation(ws_, c4()); + // io::pgm::save(labeling::wrap(ws), "tmp_ws.pgm"); + // io::pgm::save(labeling::wrap(ws_), "tmp_ws_.pgm"); + + image2d<L> output(input.domain()); { @@ -70,13 +93,43 @@ mln_piter_(box2d) p(input.domain()); for_all(p) - if (input(p)) + if (input(p) == black_on_white) output(p) = 0; else output(p) = ws.at_((p.row() - min_row) / 2, (p.col() - min_col) / 2); } + // io::pgm::save(labeling::wrap(output), "tmp_output.pgm"); + + return output; + } + + + + image2d<bool> + reduce(const image2d<bool>& input) + { + const int + min_row = input.domain().pmin().row(), + min_col = input.domain().pmin().col(), + max_row = input.domain().pmax().row(), + max_col = input.domain().pmax().col(); + + image2d<bool> output(input.nrows() / 2, + input.ncols() / 2); + + for (int row = min_row; row <= max_row; row += 2) + for (int col = min_col; col <= max_col; col += 2) + { + unsigned count = 0; + if (input.at_(row, col) == true) ++count; + if (input.at_(row, col + 1) == true) ++count; + if (input.at_(row + 1, col) == true) ++count; + if (input.at_(row + 1, col + 1) == true) ++count; + output.at_((row - min_row) / 2, + (col - min_col) / 2) = (count >= 2); + } return output; } Index: icdar/2009/hsc/input_to_lines_dat.cc --- icdar/2009/hsc/input_to_lines_dat.cc (revision 3644) +++ icdar/2009/hsc/input_to_lines_dat.cc (working copy) @@ -37,7 +37,7 @@ typedef value::label<12> L; L n_lines; - image2d<L> output = input_to_lines(input, n_lines); + image2d<L> output = input_to_lines(input, n_lines, 0.7); // with 70% io::icdar::save(output, argv[2]); Index: icdar/2009/hsc/get_line_images.hh --- icdar/2009/hsc/get_line_images.hh (revision 3644) +++ icdar/2009/hsc/get_line_images.hh (working copy) @@ -39,14 +39,21 @@ util::array<box<mln_site(L)> > bboxes = labeling::compute(accu::meta::bbox(), lines, nlines); - util::array<mln_ch_value(L,bool)> result; + typedef mln_ch_value(L,bool) line_t; + util::array<line_t> result; - for (unsigned i = 1; i < nlines; ++i) { - typedef mln_ch_value(L,bool) line_t; + // Skipping index 0: + line_t dummy(1,1); + result.append(dummy); + } + + for (unsigned i = 1; i <= nlines; ++i) + { box<mln_site(L)> b = bboxes[i]; b.enlarge(bbox_line_enlarge); line_t line(b); + data::fill(line, false); data::fill(((line | bboxes[i]).rw() | (pw::value(lines) == i)).rw(), true); result.append(line);
15 years, 8 months
1
0
0
0
3644: Update ICDAR-HSC code.
by Thierry Geraud
https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
Index: ChangeLog from Thierry Geraud <thierry.geraud(a)lrde.epita.fr> Update ICDAR-HSC code. * icdar/2009/hsc/input_to_lines_dat.cc: Move code to... * icdar/2009/hsc/input_to_lines.hh: ...this new file. * icdar/2009/hsc/input_to_lines_dat.cc (main): Use the 'input_to_lines' routine. input_to_lines.hh | 79 +++++++++++--------------------------------------- input_to_lines_dat.cc | 46 +++-------------------------- 2 files changed, 24 insertions(+), 101 deletions(-) Index: icdar/2009/hsc/input_to_lines.hh --- icdar/2009/hsc/input_to_lines.hh (revision 3642) +++ icdar/2009/hsc/input_to_lines.hh (working copy) @@ -1,87 +1,44 @@ #include <sandbox/icdar/2009/hsc/clean_input.hh> #include <sandbox/icdar/2009/hsc/input_to_ws.hh> #include <sandbox/icdar/2009/hsc/ws_to_wsl.hh> -#include <sandbox/icdar/2009/hsc/io/icdar/save.hh> +#include <sandbox/icdar/2009/hsc/clean_lines.hh> #include <mln/world/binary_2d/subsample.hh> - #include <mln/value/int_u8.hh> #include <mln/value/label.hh> -#include <mln/value/rgb8.hh> -#include <mln/debug/colorize.hh> #include <mln/labeling/relabel.hh> - -#include <mln/level/transform.hh> -#include <mln/fun/v2v/enc.hh> - -#include <mln/io/pbm/load.hh> -#include <mln/io/pgm/save.hh> -#include <mln/io/ppm/save.hh> - #include <mln/core/image/violent_cast_image.hh> - - - -void usage(char* argv[]) +namespace mln { - std::cerr << "usage: " << argv[0] << " input.pbm output.dat [output.ppm]" << std::endl - << " HSC @ ICDAR'2009" << std::endl - << " input.pbm: input 2D binary image (text is black; background is white)" << std::endl - << " output.dat: line buffer (int; 0 is bg)." << std::endl; - std::abort(); -} - - -int main(int argc, char* argv[]) + template <typename L> + image2d<L> + input_to_lines(const image2d<bool>& raw_input, L& n_lines) { - using namespace mln; - using value::int_u8; - - if (argc != 3 && argc != 4) - usage(argv); - - - trace::entering("main"); - - - image2d<bool> input; - io::pbm::load(input, argv[1]); - - // First clean. - input = clean_input(input); - + image2d<bool> input = clean_input(raw_input); // Sub-sample. - image2d<int_u8> small = world::binary_2d::subsample(input, 4); + image2d<value::int_u8> small = world::binary_2d::subsample(input, 4); - typedef value::int_u<12> L; + typedef value::int_u<12> L_reg; + L_reg n_reg; + image2d<L_reg> ws, wsl; - L n_lines; - image2d<L> // Get text regions. - ws = input_to_ws(input, small, n_lines), - // Merge regions. - wsl = ws_to_wslines(input, small, ws, n_lines); + ws = input_to_ws(input, small, n_reg); - typedef value::label<12> L_; - L_ n_lines_; - image2d<L_> wsl_ = labeling::relabel(violent_cast_image_<L_>(wsl), - n_lines_); + // Merge regions. + wsl = ws_to_wslines(input, small, ws, n_reg); - io::icdar::save(wsl_, argv[2]); + // Clean lines + wsl = clean_lines(input, wsl, 0.7f); - if (argc == 4) - { - io::ppm::save(debug::colorize(value::rgb8(), - wsl_, - n_lines_), - argv[3]); + return labeling::relabel(violent_cast_image_<L>(wsl), + n_lines); } - trace::exiting("main"); -} +} // mln Property changes on: icdar/2009/hsc/input_to_lines.hh ___________________________________________________________________ Added: svn:mergeinfo Index: icdar/2009/hsc/input_to_lines_dat.cc --- icdar/2009/hsc/input_to_lines_dat.cc (revision 3643) +++ icdar/2009/hsc/input_to_lines_dat.cc (working copy) @@ -1,27 +1,13 @@ -#include <sandbox/icdar/2009/hsc/clean_input.hh> -#include <sandbox/icdar/2009/hsc/input_to_ws.hh> -#include <sandbox/icdar/2009/hsc/ws_to_wsl.hh> +#include <sandbox/icdar/2009/hsc/input_to_lines.hh> #include <sandbox/icdar/2009/hsc/io/icdar/save.hh> -#include <mln/world/binary_2d/subsample.hh> - -#include <mln/value/int_u8.hh> -#include <mln/value/label.hh> #include <mln/value/rgb8.hh> #include <mln/debug/colorize.hh> -#include <mln/labeling/relabel.hh> - -#include <mln/level/transform.hh> -#include <mln/fun/v2v/enc.hh> #include <mln/io/pbm/load.hh> #include <mln/io/pgm/save.hh> #include <mln/io/ppm/save.hh> -#include <mln/core/image/violent_cast_image.hh> - - - @@ -44,42 +30,22 @@ if (argc != 3 && argc != 4) usage(argv); - trace::entering("main"); - image2d<bool> input; io::pbm::load(input, argv[1]); - - // First clean. - input = clean_input(input); - - - // Sub-sample. - image2d<int_u8> small = world::binary_2d::subsample(input, 4); - - typedef value::int_u<12> L; - + typedef value::label<12> L; L n_lines; - image2d<L> - // Get text regions. - ws = input_to_ws(input, small, n_lines), - // Merge regions. - wsl = ws_to_wslines(input, small, ws, n_lines); - - typedef value::label<12> L_; - L_ n_lines_; - image2d<L_> wsl_ = labeling::relabel(violent_cast_image_<L_>(wsl), - n_lines_); + image2d<L> output = input_to_lines(input, n_lines); - io::icdar::save(wsl_, argv[2]); + io::icdar::save(output, argv[2]); if (argc == 4) { io::ppm::save(debug::colorize(value::rgb8(), - wsl_, - n_lines_), + output, + n_lines), argv[3]); }
15 years, 8 months
1
0
0
0
← Newer
1
...
11
12
13
14
15
16
17
18
19
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Results per page:
10
25
50
100
200