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
June 2010
----- 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
9 participants
276 discussions
Start a n
N
ew thread
last-svn-commit-177-gef48505 configure.ac: Set HAVE_QT correctly.
by Guillaume Lazzara
--- ChangeLog | 4 ++++ configure.ac | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4bd09b2..ac87741 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2010-06-25 Guillaume Lazzara <z(a)lrde.epita.fr> + + * configure.ac: Set HAVE_QT correctly. + 2010-06-15 Guillaume Lazzara <z(a)lrde.epita.fr> * configure.ac: Configure scribo/demo. diff --git a/configure.ac b/configure.ac index 330a2fa..0826019 100644 --- a/configure.ac +++ b/configure.ac @@ -170,8 +170,8 @@ OLN_WITH_LIB([TESSERACT], [tesseract/baseapi.h], [tesseract_full], [tesseract], # Qt. AT_WITH_QT([+xml], [], [], - AC_DEFINE([HAVE_QT], 1, [Define to 1 if we can use Qt]), - AC_DEFINE([HAVE_QT], 0)) + AC_DEFINE([HAVE_QT], 0, [Define to 1 if we can use Qt]), + AC_DEFINE([HAVE_QT], 1)) AM_CONDITIONAL([HAVE_QT], [test x$QT_PATH != x]) -- 1.5.6.5
14 years, 6 months
1
0
0
0
last-svn-commit-176-gbe8a948 Fix conversion routines towards qimage.
by Guillaume Lazzara
* mln/convert/to_qimage.hh: Fix invalid conversions. * mln/convert/to_qimage_nocopy.hh: Avoid a warning. --- milena/ChangeLog | 8 +++++ milena/mln/convert/to_qimage.hh | 53 ++++++++++++++++++++++++-------- milena/mln/convert/to_qimage_nocopy.hh | 2 +- 3 files changed, 49 insertions(+), 14 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index e584a23..a4fe97b 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,13 @@ 2010-06-25 Guillaume Lazzara <z(a)lrde.epita.fr> + Fix conversion routines towards qimage. + + * mln/convert/to_qimage.hh: Fix invalid conversions. + + * mln/convert/to_qimage_nocopy.hh: Avoid a warning. + +2010-06-25 Guillaume Lazzara <z(a)lrde.epita.fr> + * mln/accu/count_value.hh: Add properties. 2010-06-18 Guillaume Lazzara <z(a)lrde.epita.fr> diff --git a/milena/mln/convert/to_qimage.hh b/milena/mln/convert/to_qimage.hh index 2995ab4..c87771e 100644 --- a/milena/mln/convert/to_qimage.hh +++ b/milena/mln/convert/to_qimage.hh @@ -55,6 +55,17 @@ namespace mln namespace convert { + /// \brief Convert a Milena image to a Qimage. + /// + // + template <typename I> + inline + QImage + to_qimage(const Image<I>& ima); + + +# ifndef MLN_INCLUDE_ONLY + // Implementation namespace impl @@ -68,26 +79,30 @@ namespace mln const I& ima = exact(ima_); mln_precondition(ima.is_valid()); - const int + const unsigned nrows = geom::nrows(ima), ncols = geom::ncols(ima); # if QT_VERSION >= 0x040000 && QT_VERSION < 0x040400 QImage qima(ncols, nrows, QImage::Format_RGB32); - uchar * ptr_qima = qima.scanLine(0); + uchar * ptr_qima = qima.bits(); + unsigned offset = ima.delta_index(dpoint2d(+1, - ncols)); + unsigned padding = 0; # if Q_BYTE_ORDER == Q_LITTLE_ENDIAN ++ptr_qima; # endif // ! Q_BYTE_ORDER # else QImage qima(ncols, nrows, QImage::Format_RGB888); - uchar * ptr_qima = qima.scanLine(0); + uchar * ptr_qima = qima.bits(); + unsigned padding = ncols % 4; # endif // ! QT_VERSION const mln_value(I)* ptr_ima = &ima(ima.domain().pmin()); - unsigned row_offset = ima.delta_index(dpoint2d(+1, - ncols)); + unsigned offset = ima.delta_index(dpoint2d(+1, - ncols)); // Data is stored as ABGR so we skip the first value which is ignored. - for (unsigned row = 0; row < nrows; ++row, ptr_ima += row_offset) + for (unsigned row = 0; row < nrows; ++row, ptr_ima += offset) + { for (unsigned col = 0; col < ncols; ++col) { const mln_value(I)& v = *ptr_ima++; @@ -99,6 +114,8 @@ namespace mln ptr_qima += 3; # endif // ! QT_VERSION } + ptr_qima += padding; + } return qima; } @@ -121,9 +138,10 @@ namespace mln QImage qima(ncols, nrows, QImage::Format_RGB32); uchar * ptr_qima = qima.scanLine(0); const mln_value(I)* ptr_ima = &ima(ima.domain().pmin()); - unsigned row_offset = ima.delta_index(dpoint2d(+1, - ncols)); + unsigned offset = ima.delta_index(dpoint2d(+1, - ncols)); - for (unsigned row = 0; row < nrows; ++row, ptr_ima += row_offset) + for (unsigned row = 0; row < nrows; ++row, ptr_ima += offset) + { for (unsigned col = 0; col < ncols; ++col) { const mln::value::rgb8& v = *ptr_ima++; @@ -141,6 +159,7 @@ namespace mln *ptr_qima = v.blue(); # endif // ! Q_BYTE_ORDER } + } return qima; } @@ -158,13 +177,21 @@ namespace mln ncols = geom::ncols(ima); + typedef mln_site(I) P; + typedef mln_dpsite(P) DP; + // Required by a one-shot data copy: mln::border::resize(ima, 0); + unsigned + offset = ima.delta_index(DP(+1, 0)), + line_offset = 0; + QImage qima(ncols, nrows, QImage::Format_RGB888); - std::memcpy(qima.scanLine(0), - ima.buffer(), - ima.nelements() * 3); + for (int i = 0 ; i < qima.height(); ++i, line_offset += offset) + std::memcpy(qima.scanLine(i), + ima.buffer() + line_offset, + ima.ncols() * 3); return qima; } @@ -187,9 +214,7 @@ namespace mln mln::border::resize(ima, 0); QImage qima(ncols, nrows, QImage::Format_RGB32); - std::memcpy(qima.scanLine(0), - ima.buffer(), - ima.nelements() * 4); + std::memcpy(qima.bits(), ima.buffer(), ima.nelements() * 4); return qima; } @@ -263,6 +288,8 @@ namespace mln } +# endif // ! MLN_INCLUDE_ONLY + } // end of namespace mln::convert } // end of namespace mln diff --git a/milena/mln/convert/to_qimage_nocopy.hh b/milena/mln/convert/to_qimage_nocopy.hh index 5842468..fbae2f6 100644 --- a/milena/mln/convert/to_qimage_nocopy.hh +++ b/milena/mln/convert/to_qimage_nocopy.hh @@ -136,7 +136,7 @@ namespace mln template <typename I, typename V> inline - QImage to_qimage_nocopy_dispatch(const Image<I>& ima, V&) + QImage to_qimage_nocopy_dispatch(const Image<I>&, V&) { // Not supported yet! mlc_abort(I)::check(); -- 1.5.6.5
14 years, 6 months
1
0
0
0
last-svn-commit-175-g76ed491 bench/fastest.cc: New. Add a bench for the best fastest iteration.
by Guillaume Lazzara
--- milena/sandbox/ChangeLog | 5 + .../{fastest_forall_p_browsing.cc => fastest.cc} | 175 ++++++++------------ 2 files changed, 76 insertions(+), 104 deletions(-) copy milena/sandbox/bench/{fastest_forall_p_browsing.cc => fastest.cc} (76%) diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog index ba20fec..5cb9a9c 100644 --- a/milena/sandbox/ChangeLog +++ b/milena/sandbox/ChangeLog @@ -1,3 +1,8 @@ +2010-06-25 Guillaume Lazzara <z(a)lrde.epita.fr> + + * bench/fastest.cc: New. Add a bench for the best fastest + iteration. + 2010-03-30 Guillaume Lazzara <z(a)lrde.epita.fr> Improve the usability of AFP's GUI. diff --git a/milena/sandbox/bench/fastest_forall_p_browsing.cc b/milena/sandbox/bench/fastest.cc similarity index 76% copy from milena/sandbox/bench/fastest_forall_p_browsing.cc copy to milena/sandbox/bench/fastest.cc index 5560f70..c77b3c2 100644 --- a/milena/sandbox/bench/fastest_forall_p_browsing.cc +++ b/milena/sandbox/bench/fastest.cc @@ -26,7 +26,7 @@ #include <mln/core/image/image2d.hh> #include <mln/util/timer.hh> - +#include <mln/core/box_runend_piter.hh> # define loop(n) for (unsigned i = 0; i < n; ++i) @@ -36,18 +36,6 @@ namespace mln { - // (r, c) - - template <typename I> - void bench_00(I& ima) - { - const unsigned nr = ima.nrows(), nc = ima.ncols(); - for (int r = 0; r < nr; ++r) - for (int c = 0; c < nc; ++c) - ima.at_(r, c) = 0; - } - - // ptr template <typename I> @@ -161,7 +149,7 @@ namespace mln } - // box_runstart_piter -> (ptr, point) + // box_runstart_piter -> point template <typename I> void bench_6(I& ima) @@ -203,6 +191,30 @@ namespace mln } + // box_runend_piter -> point + + template <typename I> + void bench_7(I& ima) + { + typedef mln_site(I) P; + const unsigned dim_1 = P::dim - 1; + mln_box_runend_piter(I) s(ima.domain()); + const unsigned n = s.run_length(); + for_all(s) + { + mln_value(I)* ptr = & ima(s); + P p = s; + for (unsigned i = 0; i < n; ++i) + { + *ptr-- = 0; + --p[dim_1]; + } + } + } + + + + // template <typename I> // void bench_6_alt(I& ima1, const I& ima2) // { @@ -222,31 +234,6 @@ namespace mln // } - - // box_runstart_piter -> (offset, point) - - template <typename I> - void bench_7(I& ima) - { - typedef mln_site(I) P; - const unsigned dim_1 = P::dim - 1; - mln_box_runstart_piter(I) s(ima.domain()); - const unsigned n = s.run_length(); - for_all(s) - { - unsigned offset = ima.index_of_point(s); - P p = s; - for (unsigned i = 0; i < n; ++i) - { - ima.element(offset) = 0; - ++offset; - ++p[dim_1]; - } - } - } - - - } // end of namespace mln @@ -262,24 +249,14 @@ int main() util::timer t; - // (r, c) - - { - t.start(); - loop(n) bench_00(ima); - float ts = t.stop(); - std::cout << "(r, c) " << ts << std::endl; - } - - - // ptr +// // ptr - { - t.start(); - loop(n) bench_0(ima); - float ts = t.stop(); - std::cout << "ptr " << ts << std::endl; - } +// { +// t.start(); +// loop(n) bench_0(ima); +// float ts = t.stop(); +// std::cout << "ptr " << ts << std::endl; +// } // { // t.start(); @@ -289,23 +266,23 @@ int main() // } - // piter +// // piter - { - t.start(); - loop(n) bench_1(ima); - std::cout << "piter " << t.stop() << std::endl; - } +// { +// t.start(); +// loop(n) bench_1(ima); +// std::cout << "piter " << t.stop() << std::endl; +// } - // pixter +// // pixter - { - t.start(); - loop(n) bench_2(ima); - float ts = t.stop(); - std::cout << "pixter " << ts << std::endl; - } +// { +// t.start(); +// loop(n) bench_2(ima); +// float ts = t.stop(); +// std::cout << "pixter " << ts << std::endl; +// } // { // t.start(); @@ -315,13 +292,13 @@ int main() // } - // pixter -> offset +// // pixter -> offset - { - t.start(); - loop(n) bench_3(ima); - std::cout << "pixter -> offset " << t.stop() << std::endl; - } +// { +// t.start(); +// loop(n) bench_3(ima); +// std::cout << t.stop() << std::endl; +// } // { // t.start(); @@ -330,32 +307,32 @@ int main() // } - // pixter -> point +// // pixter -> point - { - t.start(); - loop(n) bench_4(ima); - std::cout << "pixter -> point " << t.stop() << std::endl; - } +// { +// t.start(); +// loop(n) bench_4(ima); +// std::cout << t.stop() << std::endl; +// } - // box_runstart_piter -> ptr +// // box_runstart_piter -> ptr - { - t.start(); - loop(n) bench_5(ima); - std::cout << "box_runstart_piter -> ptr " << t.stop() << std::endl; - } +// { +// t.start(); +// loop(n) bench_5(ima); +// std::cout << t.stop() << std::endl; +// } // box_runstart_piter -> (ptr, point) - { - t.start(); - loop(n) bench_6(ima); - float ts = t.stop(); - std::cout << "runstart -> (ptr, point) " << ts << std::endl; - } +// { +// t.start(); +// loop(n) bench_6(ima); +// float ts = t.stop(); +// std::cout << "runstart -> (ptr, point) " << ts << std::endl; +// } // { // t.start(); @@ -364,21 +341,11 @@ int main() // std::cout << "runstart -> (2 ptrs, point) " << ts << std::endl; // } - - // box_runstart_piter -> (offset, point) - { t.start(); loop(n) bench_7(ima); float ts = t.stop(); - std::cout << "runstart -> (offset, point) " << ts << std::endl; + std::cout << "runend -> (2 ptrs, point) " << ts << std::endl; } -// { -// t.start(); -// loop(n) bench_7(ima, ima2); -// float ts = t.stop(); -// std::cout << "runstart -> (2 offsets, point) " << ts << std::endl; -// } - } -- 1.5.6.5
14 years, 6 months
1
0
0
0
last-svn-commit-174-g5d3b9da Add algorithms to retrieve white spaces.
by Guillaume Lazzara
* white_space/white_spaces.cc: Move... * z/white_space/white_spaces.cc: ... Here. Improve speed. * z/white_spaces/hom_sep.cc, * z/white_space/white_space_closing.cc: New. Other approaches. --- scribo/sandbox/ChangeLog | 9 + scribo/sandbox/z/white_spaces/hom_sep.cc | 133 ++++++++++++ .../sandbox/z/white_spaces/white_space_closing.cc | 123 +++++++++++ .../sandbox/{ => z}/white_spaces/white_spaces.cc | 220 ++++++++++++-------- 4 files changed, 400 insertions(+), 85 deletions(-) create mode 100644 scribo/sandbox/ChangeLog create mode 100644 scribo/sandbox/z/white_spaces/hom_sep.cc create mode 100644 scribo/sandbox/z/white_spaces/white_space_closing.cc rename scribo/sandbox/{ => z}/white_spaces/white_spaces.cc (84%) diff --git a/scribo/sandbox/ChangeLog b/scribo/sandbox/ChangeLog new file mode 100644 index 0000000..f428dce --- /dev/null +++ b/scribo/sandbox/ChangeLog @@ -0,0 +1,9 @@ +2010-06-25 Guillaume Lazzara <z(a)lrde.epita.fr> + + Add algorithms to retrieve white spaces. + + * white_space/white_spaces.cc: Move... + * z/white_space/white_spaces.cc: ... Here. Improve speed. + + * z/white_spaces/hom_sep.cc, + * z/white_space/white_space_closing.cc: New. Other approaches. diff --git a/scribo/sandbox/z/white_spaces/hom_sep.cc b/scribo/sandbox/z/white_spaces/hom_sep.cc new file mode 100644 index 0000000..53e8c45 --- /dev/null +++ b/scribo/sandbox/z/white_spaces/hom_sep.cc @@ -0,0 +1,133 @@ +#include <mln/core/image/image2d.hh> +#include <mln/core/image/dmorph/image_if.hh> +#include <mln/pw/all.hh> + +#include <mln/draw/line.hh> + +#include <mln/data/wrap.hh> +#include <mln/data/fill.hh> +#include <mln/data/convert.hh> + + +#include <mln/labeling/colorize.hh> + +#include <mln/morpho/closing/structural.hh> +#include <mln/morpho/closing/area.hh> +#include <mln/morpho/opening/structural.hh> +#include <mln/win/rectangle2d.hh> +#include <mln/win/vline2d.hh> + +#include <mln/logical/not.hh> +#include <mln/io/pbm/all.hh> +#include <mln/io/pgm/all.hh> +#include <mln/io/ppm/save.hh> + +#include <mln/literal/colors.hh> + +#include <mln/value/label_16.hh> +#include <mln/value/int_u8.hh> +#include <mln/value/int_u12.hh> +#include <mln/value/int_u16.hh> +#include <mln/value/rgb8.hh> + +#include <mln/draw/box_plain.hh> + +#include <mln/transform/influence_zone_geodesic.hh> + +#include <mln/data/stretch.hh> + +#include <mln/util/timer.hh> + +#include <mln/norm/l1.hh> + +#include <scribo/core/object_groups.hh> +#include <scribo/core/component_set.hh> +#include <scribo/primitive/extract/components.hh> + +#include <scribo/primitive/extract/lines_h_pattern.hh> +#include <scribo/primitive/remove/separators.hh> +#include <scribo/primitive/group/from_single_link.hh> +#include <scribo/preprocessing/denoise_fg.hh> +#include <scribo/preprocessing/rotate_90.hh> + +#include <scribo/primitive/link/with_single_right_link_dmax_ratio.hh> +#include <scribo/primitive/link/with_single_right_link_dmax_ratio_aligned.hh> + +#include <scribo/filter/object_links_top_aligned.hh> +#include <scribo/filter/object_groups_small.hh> +#include <scribo/filter/object_links_bottom_aligned.hh> +#include <scribo/debug/save_linked_bboxes_image.hh> +#include <scribo/debug/decision_image.hh> + +int main(int argc, char *argv[]) +{ + using namespace scribo; + using namespace mln; + + image2d<bool> separators; + mln::io::pbm::load(separators, argv[1]); + + float val = atof(argv[2]); + + util::timer t; + + t.start(); + + // Hit or miss + { + unsigned length = 100; + + unsigned space = atoi(argv[3]); + + window2d win; + dpoint2d + dp1(-space, 0), + dp2( space, 0); + win.insert(dp1); + win.insert(dp2); + + + // Adjusting extension. + extension::adjust_fill(separators, length / 2, 0); + + accu::count_value<bool> accu(true); + typedef image2d<unsigned> I; + + I tmp = accu::transform_line(accu, separators, length, 1); + + image2d<bool> output; + initialize(output, separators); + + mln_piter_(I) p(separators.domain()); +// mln_qiter(window2d) q(win, p); + bool is_foreground; + for_all(p) + { + + if (tmp(p) > unsigned(0.95f * length) + 1) + { + output(p) = false; + continue; + } + + is_foreground = true; + + unsigned + top_count = tmp(p + dp1), + bot_count = tmp(p + dp2); + + if ((top_count >= unsigned(length * val) + 1 + && bot_count <= unsigned(length * 0.1) + 1) + || + (top_count <= unsigned(length * 0.1) + 1 + && bot_count >= unsigned(length * val) + 1)) + is_foreground = false; + + output(p) = is_foreground; + + } + + io::pbm::save(output, "separators_hom.pbm"); + } + +} diff --git a/scribo/sandbox/z/white_spaces/white_space_closing.cc b/scribo/sandbox/z/white_spaces/white_space_closing.cc new file mode 100644 index 0000000..6e645bd --- /dev/null +++ b/scribo/sandbox/z/white_spaces/white_space_closing.cc @@ -0,0 +1,123 @@ +#include <mln/core/image/image2d.hh> +#include <mln/core/image/dmorph/image_if.hh> +#include <mln/pw/all.hh> + +#include <mln/draw/line.hh> + +#include <mln/data/wrap.hh> +#include <mln/data/fill.hh> +#include <mln/data/paste.hh> +#include <mln/data/convert.hh> + +#include <mln/subsampling/antialiased.hh> + +#include <mln/labeling/colorize.hh> + +#include <mln/morpho/closing/structural.hh> +#include <mln/morpho/closing/area.hh> +#include <mln/morpho/opening/structural.hh> +#include <mln/win/rectangle2d.hh> +#include <mln/win/vline2d.hh> + +#include <mln/logical/not.hh> +#include <mln/io/pbm/all.hh> +#include <mln/io/pgm/all.hh> +#include <mln/io/ppm/save.hh> + +#include <mln/literal/colors.hh> + +#include <mln/value/label_16.hh> +#include <mln/value/int_u8.hh> +#include <mln/value/int_u12.hh> +#include <mln/value/int_u16.hh> +#include <mln/value/rgb8.hh> + +#include <mln/draw/box_plain.hh> + +#include <mln/transform/influence_zone_geodesic.hh> + +#include <mln/data/stretch.hh> + +#include <mln/util/timer.hh> + +#include <scribo/core/object_groups.hh> +#include <scribo/primitive/extract/components.hh> + +#include <scribo/primitive/extract/vertical_separators.hh> +#include <scribo/primitive/remove/separators.hh> +#include <scribo/primitive/group/from_single_link.hh> +#include <scribo/preprocessing/denoise_fg.hh> + +#include <scribo/primitive/link/with_single_right_link_dmax_ratio.hh> + +#include <scribo/filter/object_links_top_aligned.hh> +#include <scribo/filter/object_groups_small.hh> +#include <scribo/filter/object_links_bottom_aligned.hh> +#include <scribo/debug/save_linked_bboxes_image.hh> + + +namespace mln +{ + + void process(image2d<bool> input, unsigned scale, unsigned l) + { + win::hline2d vl(l); + image2d<bool> input_op_line = morpho::opening::structural(input, vl); + + if (scale == 1) + io::pbm::save(input_op_line, "input_op_line_1.pbm"); + if (scale == 2) + io::pbm::save(input_op_line, "input_op_line_2.pbm"); + if (scale == 3) + io::pbm::save(input_op_line, "input_op_line_3.pbm"); + + win::rectangle2d rect(11, 11); + image2d<bool> input_op = morpho::opening::structural(input_op_line, rect); + + if (scale == 1) + io::pbm::save(input_op, "input_op_rect_1.pbm"); + if (scale == 2) + io::pbm::save(input_op, "input_op_rect_2.pbm"); + if (scale == 3) + io::pbm::save(input_op, "input_op_rect_3.pbm"); + + + image2d<value::rgb8> output = data::convert(value::rgb8(), logical::not_(input)); + data::fill((output | pw::value(input_op)).rw(), literal::red); + + if (scale == 1) + io::ppm::save(output, "output_1.ppm"); + if (scale == 2) + io::ppm::save(output, "output_2.ppm"); + if (scale == 3) + io::ppm::save(output, "output_3.ppm"); + } + +} + +int main(int argc, char *argv[]) +{ + using namespace scribo; + using namespace mln; + + typedef image2d<bool> I; + I input; + mln::io::pbm::load(input, argv[1]); + + logical::not_inplace(input); + + unsigned l = atoi(argv[2]); + + process(input, 1, l); + + + typedef image2d<value::int_u8> J; + J input_pgm = data::convert(value::int_u8(), input); + + I input_x2 = data::convert(bool(), subsampling::antialiased(input_pgm, 2)); + process(input_x2, 2, l / 2); + + + I input_x4 = data::convert(bool(), subsampling::antialiased(input_pgm, 4)); + process(input_x4, 3, l / 4); +} diff --git a/scribo/sandbox/white_spaces/white_spaces.cc b/scribo/sandbox/z/white_spaces/white_spaces.cc similarity index 84% rename from scribo/sandbox/white_spaces/white_spaces.cc rename to scribo/sandbox/z/white_spaces/white_spaces.cc index 1026569..d832d58 100644 --- a/scribo/sandbox/white_spaces/white_spaces.cc +++ b/scribo/sandbox/z/white_spaces/white_spaces.cc @@ -72,6 +72,11 @@ namespace mln using namespace scribo; + + // Enable debug. + bool _debug_; + + template <typename L> void filter_bad_groups(object_groups<L>& top_groups, object_groups<L>& bot_groups) @@ -181,6 +186,11 @@ namespace mln ++p.col(); } + void compute_next_site_f_(unsigned& p) + { + ++p; + } + mln_site(L) start_point_(unsigned current_object, anchor::Type anchor) @@ -211,14 +221,10 @@ namespace mln dist = math::abs(p[this->direction_] - b.pmin()[this->direction_]); -// int ldist = std::max(this->components_(current_object).bbox().width() / 2, -// this->components_(this->labeled_image_(p)).bbox().width() / 2); - int ldist = this->components_(current_object).bbox().width(); // Components are really close, so the angle is more permissive. if (dist < 3 * ldist) -// if (dist < (ldist + 0.7 * ldist)) { return filter::internal::component_aligned_rad(this->components_, @@ -245,40 +251,13 @@ namespace mln { super_::validate_link_(current_object, start_point, p, anchor); - mln_site(L) - p1 = mln::my_anchors(this->components_, current_object, anchor), - p2 = mln::my_anchors(this->components_, this->labeled_image_(p), - anchor); - draw::line(debug_, p1, p2, literal::green); - - - float - angle = filter::internal::alignment_angle(this->components_, - current_object, - this->labeled_image_(p), - anchor); - angle = (angle * 180.0f) / math::pi; - angle = angle * 20.0f + 1.0f; - draw::line(debug_angle_, p1, p2, value::rgb8(angle, angle, angle)); - } - - void invalidate_link_(unsigned current_object, - const P& start_point, - const P& p, - anchor::Type anchor) - { - super_::invalidate_link_(current_object, start_point, p, anchor); - - if (this->labeled_image_.domain().has(p) && this->labeled_image_(p) != 0) + if (_debug_) { mln_site(L) p1 = mln::my_anchors(this->components_, current_object, anchor), p2 = mln::my_anchors(this->components_, this->labeled_image_(p), anchor); - if (this->labeled_image_.domain().has(p2) && norm::l1_distance(p1.to_vec(), p2.to_vec()) < 300) - { - draw::line(debug_, p1, p2, literal::red); - } + draw::line(debug_, p1, p2, literal::green); float @@ -292,6 +271,39 @@ namespace mln } } + void invalidate_link_(unsigned current_object, + const P& start_point, + const P& p, + anchor::Type anchor) + { + super_::invalidate_link_(current_object, start_point, p, anchor); + + if (_debug_) + { + if (this->labeled_image_.domain().has(p) && this->labeled_image_(p) != 0) + { + mln_site(L) + p1 = mln::my_anchors(this->components_, current_object, anchor), + p2 = mln::my_anchors(this->components_, this->labeled_image_(p), + anchor); + if (this->labeled_image_.domain().has(p2) && norm::l1_distance(p1.to_vec(), p2.to_vec()) < 300) + { + draw::line(debug_, p1, p2, literal::red); + } + + + float + angle = filter::internal::alignment_angle(this->components_, + current_object, + this->labeled_image_(p), + anchor); + angle = (angle * 180.0f) / math::pi; + angle = angle * 20.0f + 1.0f; + draw::line(debug_angle_, p1, p2, value::rgb8(angle, angle, angle)); + } + } + } + float min_alpha_rad; float max_alpha_rad; @@ -329,6 +341,11 @@ namespace mln ++p.col(); } + void compute_next_site_f_(unsigned& p) + { + ++p; + } + }; @@ -358,6 +375,12 @@ namespace mln --p.col(); } + void compute_next_site_f_(unsigned& p) + { + --p; + } + + }; } @@ -374,7 +397,7 @@ int main(int argc, char *argv[]) return 1; }; - bool debug = (argc == 7); + _debug_ = (argc == 7); util::timer t; util::timer gt; @@ -399,7 +422,7 @@ int main(int argc, char *argv[]) t_ = t; std::cout << "closing_structural - " << t_ << std::endl; - if (debug) + if (_debug_) { // Restore input orientation. input = scribo::preprocessing::rotate_90(input, false); @@ -427,7 +450,7 @@ int main(int argc, char *argv[]) t_ = t; std::cout << "extract::components - " << t_ << std::endl; - if (debug) + if (_debug_) io::pgm::save(data::convert(value::int_u8(), components.labeled_image()), "lbl.pgm"); @@ -447,12 +470,12 @@ int main(int argc, char *argv[]) // Right mln::single_right_dmax_ratio_aligned_functor<L> functor(input_clo, components, dmax, min_angle, max_angle, anchor::Top); - top_right = primitive::link::compute(functor, anchor::Top); + top_right = primitive::link::impl::compute_fastest(functor, anchor::Top); t.stop(); - if (debug) + if (_debug_) { io::ppm::save(functor.debug_, "right_top.ppm"); io::ppm::save(functor.debug_angle_, "right_top_angle.ppm"); @@ -468,7 +491,7 @@ int main(int argc, char *argv[]) t.stop(); - if (debug) + if (_debug_) { io::ppm::save(lfunctor.debug_, "left_top.ppm"); io::ppm::save(lfunctor.debug_angle_, "left_top_angle.ppm"); @@ -491,7 +514,7 @@ int main(int argc, char *argv[]) bot_right = primitive::link::compute(functor, anchor::Bottom); t.stop(); - if (debug) + if (_debug_) { io::ppm::save(functor.debug_, "right_bot.ppm"); io::ppm::save(functor.debug_angle_, "right_bot_angle.ppm"); @@ -505,13 +528,13 @@ int main(int argc, char *argv[]) bot_left = primitive::link::compute(lfunctor, anchor::Bottom); t.stop(); - if (debug) + if (_debug_) { io::ppm::save(lfunctor.debug_, "left_bot.ppm"); io::ppm::save(lfunctor.debug_angle_, "left_bot_angle.ppm"); } - if (debug) + if (_debug_) { image2d<value::rgb8> output = duplicate(functor.debug_); data::paste((lfunctor.debug_ | (pw::value(lfunctor.debug_) != pw::cst(literal::black))) | (pw::value(lfunctor.debug_) != pw::cst(literal::white)), output); @@ -555,7 +578,7 @@ int main(int argc, char *argv[]) - if (debug) + if (_debug_) { image2d<value::rgb8> @@ -628,7 +651,7 @@ int main(int argc, char *argv[]) image2d<value::rgb8> both; - if (debug) + if (_debug_) both = data::convert(value::rgb8(), input); @@ -640,7 +663,7 @@ int main(int argc, char *argv[]) { if (top_accu(d).is_valid()) { - if (debug) + if (_debug_) mln::draw::line(both, top_accu(d).to_result().pmin(), point2d(top_accu(d).to_result().pmin().row(), @@ -654,7 +677,7 @@ int main(int argc, char *argv[]) true); } else - if (debug && btop_accu(d).is_valid()) + if (_debug_ && btop_accu(d).is_valid()) mln::draw::line(both, btop_accu(d).to_result().pmin(), point2d(btop_accu(d).to_result().pmin().row(), @@ -666,7 +689,7 @@ int main(int argc, char *argv[]) { if (bot_accu(d).is_valid()) { - if (debug) + if (_debug_) mln::draw::line(both, point2d(bot_accu(d).to_result().pmax().row(), bot_accu(d).to_result().pmin().col()), @@ -680,7 +703,7 @@ int main(int argc, char *argv[]) true); } else - if (debug && bbot_accu(d).is_valid()) + if (_debug_ && bbot_accu(d).is_valid()) mln::draw::line(both, point2d(bbot_accu(d).to_result().pmax().row(), bbot_accu(d).to_result().pmin().col()), @@ -693,7 +716,7 @@ int main(int argc, char *argv[]) std::cout << "Drawing output image - " << t_ << std::endl; - if (debug) + if (_debug_) { io::ppm::save(both, argv[5]); io::pbm::save(separators, "separators.pbm"); @@ -702,17 +725,13 @@ int main(int argc, char *argv[]) // Hit or miss { - t.restart(); - image2d<bool> input_with_seps = duplicate(input_clo); - data::paste(separators | pw::value(separators), input_with_seps); - t.stop(); - - t_ = t; - std::cout << "input with seps - " << t_ << std::endl; - + if (_debug_) + { + image2d<bool> input_with_seps = duplicate(input_clo); + data::paste(separators | pw::value(separators), input_with_seps); - if (debug) io::pbm::save(input_with_seps, "input_with_seps.pbm"); + } t.restart(); unsigned length = 25; @@ -722,45 +741,63 @@ int main(int argc, char *argv[]) dp2( 21, 0); // Adjusting extension. - extension::adjust_fill(separators, length / 2, 0); + t.restart(); + extension::adjust_fill(input_clo, length / 2, 0); accu::count_value<bool> accu(true); typedef image2d<unsigned> I; - I tmp = accu::transform_line(accu, input_with_seps, length, 1); + I tmp = accu::transform_line(accu, input_clo, length, 1); + t_ = t; + std::cout << "* accu::transform_line - " << t_ << std::endl; - if (debug) + if (_debug_) io::pgm::save(data::convert(value::int_u8(), tmp), "tmp.pgm"); - image2d<bool> output; - initialize(output, separators); - data::fill(output, false); + t.restart(); value::int_u8 nlabels; image2d<value::int_u8> - sep_lbl = labeling::blobs(separators, c8(), nlabels); + sep_lbl = labeling::value(separators, true, c8(), nlabels); + t_ = t; + std::cout << "* labeling seps - " << t_ << std::endl; - mln_piter_(I) p(separators.domain()); - util::array<unsigned> lcard(unsigned(nlabels) + 1, 0); - util::array<unsigned> lfalse(unsigned(nlabels) + 1, 0); + t.restart(); +// util::array<unsigned> lcard(unsigned(nlabels) + 1, 0); +// util::array<unsigned> lfalse(unsigned(nlabels) + 1, 0); util::array<bool> relbl(unsigned(nlabels) + 1, true); relbl(0) = false; - for_all(p) + +// unsigned +// tmp_next_line_dp1 = tmp.delta_index(dp1), +// tmp_next_line_dp2 = tmp.delta_index(dp2); + +// const mln_value(I)* val_sep = &separators(separators.domain().pmin()); +// const value::int_u8* val_lbl = &sep_lbl(sep_lbl.domain().pmin()); + +// bool go_next = false; + unsigned invalid_ratio = unsigned(length * 0.30f); + +// for (unsigned row = 0; i < nrows; ++row) +// { +// for (unsigned col = 0; col < ncols; ++col) +// { + +// } + +// val_sep += ; +// val_lbl += ; +// } + + mln_piter_(I) p(separators.domain()); + for_all(p) if (separators(p)) { unsigned lbl = sep_lbl(p); - ++lcard(lbl); - -// Useless since we already work on selected lines (separators image). -// -// if (tmp(p) > unsigned(0.95f * length) + 1) -// { -// output(p) = false; -// continue; -// } +// ++lcard(lbl); unsigned top_count = tmp(p + dp1), @@ -768,19 +805,32 @@ int main(int argc, char *argv[]) // This site is wrapped between two lines of text so we don't // want it. - if (top_count >= unsigned(length * 0.30f) + 1 - && bot_count >= unsigned(length * 0.30f) + 1) - ++lfalse(lbl); + if (top_count >= invalid_ratio + 1 + && bot_count >= invalid_ratio + 1) + { + relbl(lbl) = false; +// go_next = true; + } +// ++lfalse(lbl); } - for_all_comps(i, relbl) - relbl(i) = (lfalse(i) / (float) lcard(i)) < 0.02f; +// for_all_comps(i, relbl) +// relbl(i) = (lfalse(i) / (float) lcard(i)) < 0.02f; + t_ = t; + std::cout << "* reading data - " << t_ << std::endl; + t.restart(); labeling::relabel_inplace(sep_lbl, nlabels, relbl); - data::paste(sep_lbl | (pw::value(sep_lbl) != pw::cst(0)), output); + t_ = t; + std::cout << "* relabel_inplace - " << t_ << std::endl; + + image2d<bool> output = data::convert(bool(), sep_lbl); - if (debug) + if (_debug_) + { io::pbm::save(output, "separators_hom.pbm"); + io::pbm::save(separators, "separators_filtered.pbm"); + } } t_ = t; -- 1.5.6.5
14 years, 6 months
1
0
0
0
last-svn-commit-173-g5824c18 mln/accu/count_value.hh: Add properties.
by Guillaume Lazzara
--- milena/ChangeLog | 4 ++++ milena/mln/accu/count_value.hh | 26 +++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index a3b5d0a..e584a23 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,3 +1,7 @@ +2010-06-25 Guillaume Lazzara <z(a)lrde.epita.fr> + + * mln/accu/count_value.hh: Add properties. + 2010-06-18 Guillaume Lazzara <z(a)lrde.epita.fr> Fix a bug in conversions from vec to point. diff --git a/milena/mln/accu/count_value.hh b/milena/mln/accu/count_value.hh index f85f5d8..833f075 100644 --- a/milena/mln/accu/count_value.hh +++ b/milena/mln/accu/count_value.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -37,6 +38,29 @@ namespace mln { + // Forward declaration. + namespace accu { + template <typename V> struct count_value; + } + + + // Traits. + + namespace trait + { + + template <typename V> + struct accumulator_< accu::count_value<V> > + { + typedef accumulator::has_untake::yes has_untake; + typedef accumulator::has_set_value::yes has_set_value; + typedef accumulator::has_stop::no has_stop; + typedef accumulator::when_pix::use_v when_pix; + }; + + } // end of namespace mln::trait + + namespace accu { -- 1.5.6.5
14 years, 6 months
1
0
0
0
last-svn-commit-172-gd7850db Improve text recognition.
by Guillaume Lazzara
* text/clean.hh: Use upsampling::eagle. * text/recognition.hh: Make sure there is a border around the text even after having resized images. --- scribo/ChangeLog | 9 +++++++++ scribo/text/clean.hh | 3 ++- scribo/text/recognition.hh | 32 ++++++++++++++++++++------------ 3 files changed, 31 insertions(+), 13 deletions(-) diff --git a/scribo/ChangeLog b/scribo/ChangeLog index 7b779f7..f4fce54 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,5 +1,14 @@ 2010-06-25 Guillaume Lazzara <z(a)lrde.epita.fr> + Improve text recognition. + + * text/clean.hh: Use upsampling::eagle. + + * text/recognition.hh: Make sure there is a border around the + text even after having resized images. + +2010-06-25 Guillaume Lazzara <z(a)lrde.epita.fr> + * binarization/sauvola_ms.hh: Fix an invalid test. 2010-06-25 Guillaume Lazzara <z(a)lrde.epita.fr> diff --git a/scribo/text/clean.hh b/scribo/text/clean.hh index 341d64c..1a9e458 100644 --- a/scribo/text/clean.hh +++ b/scribo/text/clean.hh @@ -68,6 +68,7 @@ #include <scribo/core/line_info.hh> #include <scribo/upsampling/bs2x.hh> +#include <scribo/upsampling/eagle.hh> #include <scribo/subsampling/bilinear.hh> @@ -119,7 +120,7 @@ namespace scribo << fact << std::endl; while (fact < 0.90) { - output = scribo::upsampling::bs2x(output); // 2x upsampling + output = scribo::upsampling::eagle(output); // 2x upsampling fact *= 2.0f; // std::cout << "fact = " << fact // << " - output.domain = " << output.domain() diff --git a/scribo/text/recognition.hh b/scribo/text/recognition.hh index a3ccd50..35d343a 100644 --- a/scribo/text/recognition.hh +++ b/scribo/text/recognition.hh @@ -43,6 +43,7 @@ # include <mln/util/array.hh> # include <mln/data/fill.hh> # include <mln/data/paste.hh> +# include <mln/data/paste_without_localization.hh> # include <mln/pw/all.hh> # include <mln/core/alias/w_window2d_int.hh> @@ -125,6 +126,7 @@ namespace scribo std::cout << "x_height = " << lines(i).x_height() << std::endl; mln_domain(I) box = lines(i).bbox(); + // Make sure characters are isolated from the borders. // Help Tesseract. box.enlarge(2); @@ -146,23 +148,29 @@ namespace scribo /// Improve text quality. - /// text_ima_cleaned domain is larger than text_ima's. - I text_ima_cleaned = text::clean(lines(i), text_ima); -// mln::io::pbm::save(text_ima_cleaned, mln::debug::filename("line.pbm", debug_id++)); + /// text_ima_cleaned domain may be larger than text_ima's. + text::clean_inplace(lines(i), text_ima); +// mln::io::pbm::save(text_ima_cleaned, mln::debug::filename("line.pbm", debug_id++)); + // Make sure characters are isolated from the borders. + // Help Tesseract. + mln_domain(I) lbox = text_ima.domain(); + lbox.enlarge(lines(i).char_space() + 2); + I line_image(lbox, 0); // Make sure there is no border! + data::fill(line_image, false); + data::paste_without_localization(text_ima, line_image); - // Make sure there is no border. - border::resize(text_ima_cleaned, 0); +// mln::io::pbm::save(line_image, mln::debug::filename("line_image.pbm", debug_id++)); // Recognize characters. char* s = TessBaseAPI::TesseractRect( - (unsigned char*) text_ima_cleaned.buffer(), - sizeof (bool), // Pixel size. - text_ima_cleaned.ncols() * sizeof (bool), // Row_offset - 0, // Left - 0, // Top - text_ima_cleaned.ncols(), // n cols - text_ima_cleaned.nrows()); // n rows + (unsigned char*) line_image.buffer(), + sizeof (bool), // Pixel size. + line_image.ncols() * sizeof (bool), // Row_offset + 0, // Left + 0, // Top + line_image.ncols(), // n cols + line_image.nrows()); // n rows if (s != 0) -- 1.5.6.5
14 years, 6 months
1
0
0
0
last-svn-commit-171-gf8b5117 binarization/sauvola_ms.hh: Fix an invalid test.
by Guillaume Lazzara
--- scribo/ChangeLog | 4 ++++ scribo/binarization/sauvola_ms.hh | 2 +- 2 files changed, 5 insertions(+), 1 deletions(-) diff --git a/scribo/ChangeLog b/scribo/ChangeLog index b03b8e4..7b779f7 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,5 +1,9 @@ 2010-06-25 Guillaume Lazzara <z(a)lrde.epita.fr> + * binarization/sauvola_ms.hh: Fix an invalid test. + +2010-06-25 Guillaume Lazzara <z(a)lrde.epita.fr> + * upsampling/eagle.hh: Add a new upsampling algorithm. 2010-06-23 Arthur Crepin-Leblond <crepin(a)stockholm.lrde.epita.fr> diff --git a/scribo/binarization/sauvola_ms.hh b/scribo/binarization/sauvola_ms.hh index 0390180..8964324 100644 --- a/scribo/binarization/sauvola_ms.hh +++ b/scribo/binarization/sauvola_ms.hh @@ -158,7 +158,7 @@ namespace scribo w_local_w = w_local; // Make sure the window fits in the image domain. - if (w >= static_cast<const unsigned>(integral_sum_sum_2.ncols())) + if (w_local_w >= static_cast<const unsigned>(integral_sum_sum_2.ncols())) { w_local_w = std::min(integral_sum_sum_2.ncols(), integral_sum_sum_2.nrows()) - integral_sum_sum_2.border(); w_local_h = w_local_w; -- 1.5.6.5
14 years, 6 months
1
0
0
0
last-svn-commit-170-g9f19274 upsampling/eagle.hh: Add a new upsampling algorithm.
by Guillaume Lazzara
--- scribo/ChangeLog | 12 ++- scribo/upsampling/{bs2x.hh => eagle.hh} | 108 +++++++++++++++---------------- 2 files changed, 61 insertions(+), 59 deletions(-) copy scribo/upsampling/{bs2x.hh => eagle.hh} (50%) diff --git a/scribo/ChangeLog b/scribo/ChangeLog index 609abf5..b03b8e4 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,11 +1,15 @@ +2010-06-25 Guillaume Lazzara <z(a)lrde.epita.fr> + + * upsampling/eagle.hh: Add a new upsampling algorithm. + 2010-06-23 Arthur Crepin-Leblond <crepin(a)stockholm.lrde.epita.fr> Add extensions to ICDAR XML format. - + * io/xml/save_text_lines.hh: Rename as... * io/xml/save.hh: ...this. - - * src/pbm_text_in_doc.cc: update call to io::xml::save. + + * src/pbm_text_in_doc.cc: update call to io::xml::save. 2010-06-18 green <jacquelet(a)lrde.epita.fr> @@ -14,7 +18,7 @@ * sandbox: New experimental directory. * sandbox/green: New green'work. * sandbox/green/ChangeLog: New ChangeLog file. - + 2010-06-15 Guillaume Lazzara <z(a)lrde.epita.fr> Small fixes. diff --git a/scribo/upsampling/bs2x.hh b/scribo/upsampling/eagle.hh similarity index 50% copy from scribo/upsampling/bs2x.hh copy to scribo/upsampling/eagle.hh index c701e47..eab1989 100644 --- a/scribo/upsampling/bs2x.hh +++ b/scribo/upsampling/eagle.hh @@ -23,34 +23,32 @@ // exception does not however invalidate any other reasons why the // executable file might be covered by the GNU General Public License. -#ifndef SCRIBO_UPSAMPLING_BS2X_HH -# define SCRIBO_UPSAMPLING_BS2X_HH +#ifndef SCRIBO_UPSAMPLING_EAGLE_HH_ +# define SCRIBO_UPSAMPLING_EAGLE_HH_ /// \file /// /// Scale 2x algorithm for binary images. # include <mln/core/concept/image.hh> -# include <mln/core/alias/box2d.hh> +# include <mln/core/def/coord.hh> # include <mln/opt/at.hh> -# include <mln/geom/all.hh> - - +# include <mln/make/box2d.hh> namespace scribo { namespace upsampling { - using namespace mln; + using namespace mln; /// \brief Scale 2x algorithm for binary images. /// // template <typename I> mln_concrete(I) - bs2x(const Image<I>& input); + eagle(const Image<I>& ima); @@ -59,80 +57,81 @@ namespace scribo template <typename I> mln_concrete(I) - bs2x(const mln::Image<I>& input_) + eagle(const Image<I>& input_) { - trace::entering("scribo::upsampling::bs2x"); + trace::entering("scribo::upsampling::eagle"); + typedef mln_value(I) V; const I& input = exact(input_); - mlc_is(mln_domain(I), mln::box2d)::check(); - mlc_is(mln_value(I), bool)::check(); - mln_precondition(input.is_valid()); - typedef mln_value(I) V; - mln::def::coord mrow = geom::min_row(input), - mcol = geom::min_col(input); + mcol = geom::min_col(input), + mxrow = geom::max_row(input), + mxcol = geom::max_col(input); mln_piter(I) p(input.domain()); - mln_concrete(I) output(mln::make::box2d(mrow, mcol, - mrow + 2 * input.nrows() - 1, - mcol + 2 * input.ncols() - 1)); + mln_concrete(I) + output(mln::make::box2d(mrow, mcol, + mrow + 2 * input.nrows() - 1, + mcol + 2 * input.ncols() - 1)); + for_all(p) { mln::def::coord - row = mrow + 2 * (p.row() - mrow), - col = mcol + 2 * (p.col() - mcol); + prow = p.row() - mrow, + pcol = p.col() - mcol; - if(p.row() == geom::min_row(input) - || p.col() == geom::min_col(input) - || p.row() == geom::max_row(input) - || p.col() == geom::max_col(input)) + if (p.row() == mrow + || p.col() == mcol + || p.row() == mxrow + || p.col() == mxcol) { - mln::box2d b = mln::make::box2d(row, col, - row + 1, col + 1); + box2d b = mln::make::box2d(2 * prow, 2 * pcol, + 2 * prow + 1, 2 * pcol + 1); + mln_piter_(box2d) pb(b); V value = opt::at(input, p.row(), p.col()); - data::fill((output | b).rw(), value); + for_all(pb) + opt::at(output, mrow + pb.row(), mcol + pb.col()) = value; } else { - // nw n ne - // - // w value e - // - // sw s se - - V n = input(p + mln::up), - s = input(p + mln::down), - e = input(p + mln::right), - w = input(p + mln::left), - nw = input(p + mln::up_left), - ne = input(p + mln::up_right), - sw = input(p + mln::down_left), - se = input(p + mln::down_right), - value = input(p); - - if(e != w && n != s) + V + n = opt::at(input, p.row() - 1, p.col()), + s = opt::at(input, p.row() + 1, p.col()), + e = opt::at(input, p.row(), p.col() + 1), + w = opt::at(input, p.row(), p.col() - 1), + nw = opt::at(input, p.row() - 1, p.col() - 1), + ne = opt::at(input, p.row() - 1, p.col() + 1), + sw = opt::at(input, p.row() + 1, p.col() - 1), + se = opt::at(input, p.row() + 1, p.col() + 1), + value = opt::at(input, p.row(), p.col()); + + if (e != w || n != s || e != n) { - opt::at(output, row, col) = (w == n &&((se != nw) || !value)) ? w : value; - opt::at(output, row, col + 1) = (e == n &&((sw != ne) || !value)) ? e : value; - opt::at(output, row + 1, col) = (w == s &&((ne != sw) || !value)) ? w : value; - opt::at(output, row + 1, col + 1) = (e == s &&((nw != se) || !value)) ? e : value; + opt::at(output, mrow + 2 * prow, mcol + 2 * pcol) = ((w == n && w == nw && nw == n) ? nw : value); + opt::at(output, mrow + 2 * prow, mcol + 2 * pcol + 1) = ((e == n && e == ne && ne == n) ? ne : value); + opt::at(output, mrow + 2 * prow + 1, mcol + 2 * pcol) = ((w == s && w == sw && sw == s) ? sw : value); + opt::at(output, mrow + 2 * prow + 1, mcol + 2 * pcol + 1) = ((e == s && e == se && se == s) ? se : value); } else { - mln::box2d b = mln::make::box2d(row, col, - row + 1, col + 1); - data::fill((output | b).rw(), value); + box2d b = mln::make::box2d(2 * prow, 2 * pcol, + 2 * prow + 1, 2 * pcol + 1); + mln_piter_(box2d) pb(b); + V value = opt::at(input, p.row(), p.col()); + + for_all(pb) + opt::at(output, mrow + pb.row(), mcol + pb.col()) = value; } } } - trace::exiting("scribo::upsampling::bs2x"); + trace::exiting("scribo::upsampling::eagle"); return output; } @@ -143,5 +142,4 @@ namespace scribo } // end of namespace scribo - -#endif // ! SCRIBO_UPSAMPLING_BS2X_HH +#endif // ! SCRIBO_UPSAMPLING_EAGLE_HH_ -- 1.5.6.5
14 years, 6 months
1
0
0
0
last-svn-commit-184-g068f539 Clean up and new FIXMES in in apps/mesh-segm-skel.
by Roland Levillain
* apps/mesh-segm-skel/mesh-complex-max-curv.cc: Remove dead code. * apps/mesh-segm-skel/mesh-complex-skel.cc: Typo. * apps/mesh-segm-skel/Makefile.am: Add titles and FIXMES. --- milena/ChangeLog | 8 ++++ milena/apps/mesh-segm-skel/Makefile.am | 36 ++++++++++++++++++-- .../apps/mesh-segm-skel/mesh-complex-max-curv.cc | 13 +------ milena/apps/mesh-segm-skel/mesh-complex-skel.cc | 2 +- 4 files changed, 44 insertions(+), 15 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index f0064f7..b22b7bf 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,13 @@ 2010-05-11 Roland Levillain <roland(a)lrde.epita.fr> + Clean up and new FIXMES in in apps/mesh-segm-skel. + + * apps/mesh-segm-skel/mesh-complex-max-curv.cc: Remove dead code. + * apps/mesh-segm-skel/mesh-complex-skel.cc: Typo. + * apps/mesh-segm-skel/Makefile.am: Add titles and FIXMES. + +2010-05-11 Roland Levillain <roland(a)lrde.epita.fr> + New application: mesh-complex-max-curv-extrema. * apps/mesh-segm-skel/mesh-complex-max-curv-extrema.cc: New. diff --git a/milena/apps/mesh-segm-skel/Makefile.am b/milena/apps/mesh-segm-skel/Makefile.am index 230ef0a..3114055 100644 --- a/milena/apps/mesh-segm-skel/Makefile.am +++ b/milena/apps/mesh-segm-skel/Makefile.am @@ -79,11 +79,13 @@ endif ENABLE_TRIMESH if ENABLE_TRIMESH bin_PROGRAMS += mesh-pinv-curv mesh-max-curv + # FIXME: Rename as mesh-trimesh-pinv-curv? mesh_pinv_curv_SOURCES = mesh-pinv-curv.cc io.hh mesh_pinv_curv_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_trimesh) mesh_pinv_curv_LDFLAGS = $(LDFLAGS_trimesh) mesh_pinv_curv_LDADD = $(LDADD_trimesh) + # FIXME: Rename as mesh-trimesh-max-curv? mesh_max_curv_SOURCES = mesh-max-curv.cc io.hh mesh_max_curv_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_trimesh) mesh_max_curv_LDFLAGS = $(LDFLAGS_trimesh) @@ -93,17 +95,34 @@ if ENABLE_TRIMESH endif ENABLE_TRIMESH ## ---------------------------------------------------- ## +## Graph-based applications, independent of Trimesh. ## +## ---------------------------------------------------- ## + +# FIXME: To be written (and factored, of course): +# +# mesh-graph-{max,pinv}-curv +# +# mesh-graph-segm +# mesh-graph-{max,pinv}-curv-segm +# +# mesh-graph-skel +# mesh-graph-{max,pinv}-curv-skel +# +# ... + +## ---------------------------------------------------- ## ## Complex-based applications, independent of Trimesh. ## ## ---------------------------------------------------- ## # A Milena re-implementation of some features from Trimesh. This code # is completely independent from the Trimesh library. # FIXME: Change the name of this directory, as it is confusing. +# FIXME: Integrate this header into Milena. noinst_HEADERS = trimesh/misc.hh EXTRA_DIST = trimesh/README -## Segmentation. -## ------------ +## Curvature computation. +## ---------------------- # A small program exercising the curvature computation routines ported # from Trimesh to Milena. @@ -112,6 +131,7 @@ mesh_complex_max_curv_SOURCES = mesh-complex-max-curv.cc TESTS += test-mesh-complex-max-curv MOSTLYCLEANFILES += teapot-complex-max-curv.off +# FIXME: Implement (and exercise) mesh-complex-pinv-curv. # A program computing the max curvature at each (2-)face of the # surface of a triangle mesh and displaying its local minima @@ -123,7 +143,14 @@ MOSTLYCLEANFILES += \ socket-complex-max-curv-extrema.off \ teapot-complex-max-curv-extrema.off -# Segmentation program working on precomputed meshes with curvatures data. +# FIXME: Implement (and exercise) mesh-complex-pinv-curv-extrema. + +## Segmentation. +## ------------- + +# Segmentation program working on precomputed meshes with curvature +# data. Less accurate, since curvature is stored on triangles +# (polygons), whereas the segmentation is performed on edges. bin_PROGRAMS += mesh-complex-segm mesh_complex_segm_SOURCES = mesh-complex-segm.cc TESTS += test-mesh-complex-segm @@ -159,3 +186,6 @@ MOSTLYCLEANFILES += \ socket-max-curv-skel.off \ teapot-max-curv.off \ three-triangles-skel.off + +# FIXME: Implement `mesh-complex-{max,pinv}-curv-skel'. +# ... diff --git a/milena/apps/mesh-segm-skel/mesh-complex-max-curv.cc b/milena/apps/mesh-segm-skel/mesh-complex-max-curv.cc index 8d79839..79ac4ea 100644 --- a/milena/apps/mesh-segm-skel/mesh-complex-max-curv.cc +++ b/milena/apps/mesh-segm-skel/mesh-complex-max-curv.cc @@ -1,4 +1,5 @@ -// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2008, 2009, 2010 EPITA Research and Development +// Laboratory (LRDE) // // This file is part of the Milena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -86,16 +87,6 @@ int main(int argc, char* argv[]) mln::bin_2complex_image3df input; mln::io::off::load(input, input_filename); -// // ------------------------------------------------------------ -// // FIXME: TEST. -// mln::complex_image< 2, mln::space_2complex_geometry, mln::algebra::vec<3, float> > -// normal = mesh_normal(input.domain()); -// mln::p_n_faces_fwd_piter<D, G> v_(normal.domain(), 0); -// for_all(v_) -// std::cout << normal(v_) << std::endl; -// std::exit(0); -// // ------------------------------------------------------------ - std::pair<ima_t, ima_t> curv = mln::geom::mesh_curvature(input.domain()); // Compute the max curvature at each vertex. diff --git a/milena/apps/mesh-segm-skel/mesh-complex-skel.cc b/milena/apps/mesh-segm-skel/mesh-complex-skel.cc index a4df815..b7e1f1f 100644 --- a/milena/apps/mesh-segm-skel/mesh-complex-skel.cc +++ b/milena/apps/mesh-segm-skel/mesh-complex-skel.cc @@ -209,7 +209,7 @@ main(int argc, char* argv[]) `---------*/ /* FIXME: This does not work (yet). - Use workaround mln::io::off::save_bin_salt instead (bad!) */ + Use workaround mln::io::off::save_bin_alt instead (bad!) */ #if 0 mln::io::off::save(skel | mln::pw::value(skel) == mln::pw::cst(true), output_filename); -- 1.5.6.5
14 years, 6 months
1
0
0
0
last-svn-commit-183-g06265bd Configure milena/apps/mesh-segm-skel/test-mesh-complex-max-curv-extrema.
by Roland Levillain
* configure.ac: Here. --- ChangeLog | 6 ++++++ configure.ac | 2 ++ 2 files changed, 8 insertions(+), 0 deletions(-) diff --git a/ChangeLog b/ChangeLog index 44386d3..bfce0d3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-05-11 Roland Levillain <roland(a)lrde.epita.fr> + + Configure milena/apps/mesh-segm-skel/test-mesh-complex-max-curv-extrema. + + * configure.ac: Here. + 2010-06-24 Roland Levillain <roland(a)lrde.epita.fr> Add `mesh-segm-skel' to the branches to be uploaded (as snapshot). diff --git a/configure.ac b/configure.ac index 20efb20..4d6bfaf 100644 --- a/configure.ac +++ b/configure.ac @@ -505,6 +505,8 @@ AC_CONFIG_FILES([milena/apps/mesh-segm-skel/test-mesh-max-curv], [chmod +x milena/apps/mesh-segm-skel/test-mesh-max-curv]) AC_CONFIG_FILES([milena/apps/mesh-segm-skel/test-mesh-complex-max-curv], [chmod +x milena/apps/mesh-segm-skel/test-mesh-complex-max-curv]) +AC_CONFIG_FILES([milena/apps/mesh-segm-skel/test-mesh-complex-max-curv-extrema], + [chmod +x milena/apps/mesh-segm-skel/test-mesh-complex-max-curv-extrema]) AC_CONFIG_FILES([milena/apps/mesh-segm-skel/test-mesh-segm], [chmod +x milena/apps/mesh-segm-skel/test-mesh-segm]) AC_CONFIG_FILES([milena/apps/mesh-segm-skel/test-mesh-complex-segm], -- 1.5.6.5
14 years, 6 months
1
0
0
0
← Newer
1
...
6
7
8
9
10
11
12
...
28
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Results per page:
10
25
50
100
200