* scribo/toolchain/text_in_doc_preprocess.hh: New.
* src/text_in_doc_preprocess.cc: Make use of this new toolchain.
---
scribo/ChangeLog | 8 +
scribo/scribo/toolchain/text_in_doc_preprocess.hh | 152 +++++++++++++++++++++
scribo/src/text_in_doc_preprocess.cc | 41 ++----
3 files changed, 170 insertions(+), 31 deletions(-)
create mode 100644 scribo/scribo/toolchain/text_in_doc_preprocess.hh
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 8b7d143..f839cc5 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,13 @@
2010-08-25 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Add a preprocessing toolchain.
+
+ * scribo/toolchain/text_in_doc_preprocess.hh: New.
+
+ * src/text_in_doc_preprocess.cc: Make use of this new toolchain.
+
+2010-08-25 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Fix namespace ambiguities.
* scribo/binarization/sauvola_ms.hh,
diff --git a/scribo/scribo/toolchain/text_in_doc_preprocess.hh b/scribo/scribo/toolchain/text_in_doc_preprocess.hh
new file mode 100644
index 0000000..cff99f7
--- /dev/null
+++ b/scribo/scribo/toolchain/text_in_doc_preprocess.hh
@@ -0,0 +1,152 @@
+// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to produce
+// an executable, this file does not by itself cause the resulting
+// executable to be covered by the GNU General Public License. This
+// exception does not however invalidate any other reasons why the
+// executable file might be covered by the GNU General Public License.
+
+#ifndef SCRIBO_TOOLCHAIN_TEXT_IN_DOC_PREPROCESS_HH
+# define SCRIBO_TOOLCHAIN_TEXT_IN_DOC_PREPROCESS_HH
+
+/// \file
+///
+/// \brief Preprocess a document before looking for its content.
+
+
+#include <mln/core/concept/image.hh>
+#include <mln/logical/not.hh>
+
+#include <scribo/binarization/sauvola_ms.hh>
+
+#include <scribo/preprocessing/split_bg_fg.hh>
+#include <scribo/preprocessing/deskew.hh>
+
+
+namespace scribo
+{
+
+ namespace toolchain
+ {
+
+ using namespace mln;
+
+ /*! \brief Preprocess a document before looking for its content.
+
+ \param[in] input An image.
+ \param[in] enable_fg_bg Enable/Disable background removal.
+
+ If \p enable_fg_bg is set to 'True' then a background removal is
+ performed. Its parameter lambda is automatically set according
+ to the input image size.
+
+ */
+ template <typename I>
+ mln_ch_value(I,bool)
+ text_in_doc_preprocess(const Image<I>& input, bool enable_fg_bg);
+
+ /*! \brief Preprocess a document before looking for its content.
+
+ \param[in] input An image.
+ \param[in] lambda Parameter to the background removal.
+
+ If lambda is set to '0' no background removal is
+ performed. Otherwise, a background removal is performed with the
+ given \p lambda value.
+
+ */
+ template <typename I>
+ mln_ch_value(I,bool)
+ text_in_doc_preprocess(const Image<I>& input, unsigned lambda);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename I>
+ mln_ch_value(I,bool)
+ text_in_doc_preprocess(const Image<I>& input_, bool enable_fg_bg)
+ {
+ trace::entering("scribo::toolchain::text_in_doc_preprocess");
+
+ const I& input = exact(input_);
+ mln_precondition(input.is_valid());
+
+ unsigned lambda = 0;
+ if (enable_fg_bg)
+ lambda = 1.2 * (input.nrows() + input.ncols());
+
+ mln_ch_value(I,bool) output = text_in_doc_preprocess(input, lambda);
+
+ trace::exiting("scribo::toolchain::text_in_doc_preprocess");
+ return output;
+ }
+
+
+ template <typename I>
+ mln_ch_value(I,bool)
+ text_in_doc_preprocess(const Image<I>& input_, unsigned lambda)
+ {
+ trace::entering("scribo::toolchain::text_in_doc_preprocess");
+
+ const I& input = exact(input_);
+ mln_precondition(input.is_valid());
+
+ mln_concrete(I) input_rgb = input;
+
+ // Extract foreground
+ if (lambda != 0)
+ {
+ std::cout << "Extracting foreground..." << std::endl;
+ input_rgb = preprocessing::split_bg_fg(input, lambda, 32).second();
+ }
+
+ // Convert to Gray level image.
+ mln_ch_value(I,value::int_u8)
+ input_gl = data::transform(input_rgb,
+ mln::fun::v2v::rgb_to_int_u<8>());
+
+
+ // Deskewing
+ std::cout << "Deskew if needed..." << std::endl;
+ input_gl = preprocessing::deskew(input_gl);
+
+ // Binarize foreground to use it in the processing chain.
+ std::cout << "Binarizing foreground..." << std::endl;
+ mln_ch_value(I,bool)
+ input_bin = scribo::binarization::sauvola_ms(input_gl, 101, 3);
+
+ logical::not_inplace(input_bin);
+
+ trace::exiting("scribo::toolchain::text_in_doc_preprocess");
+ return input_bin;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+
+ } // end of namespace scribo::toolchain
+
+} // end of namespace scribo
+
+
+#endif // SCRIBO_TOOLCHAIN_TEXT_IN_DOC_PREPROCESS_HH
+
diff --git a/scribo/src/text_in_doc_preprocess.cc b/scribo/src/text_in_doc_preprocess.cc
index 27ed9ed..b731272 100644
--- a/scribo/src/text_in_doc_preprocess.cc
+++ b/scribo/src/text_in_doc_preprocess.cc
@@ -34,17 +34,9 @@
#include <mln/value/rgb8.hh>
-#include <mln/logical/not.hh>
-
-#include <scribo/binarization/sauvola_ms.hh>
-
#include <scribo/debug/usage.hh>
-#include <scribo/preprocessing/split_bg_fg.hh>
-#include <scribo/preprocessing/deskew.hh>
-
-
-#include <mln/io/pgm/all.hh>
+#include <scribo/toolchain/text_in_doc_preprocess.hh>
const char *args_desc[][2] =
@@ -74,30 +66,17 @@ int main(int argc, char* argv[])
unsigned lambda;
if (argc == 5)
lambda = atoi(argv[4]);
- else
- lambda = 1.2 * (input_rgb.nrows() + input_rgb.ncols());
- // Extract foreground
- if (argc >= 4 && atoi(argv[3]) == 1)
- {
- std::cout << "Extracting foreground..." << std::endl;
- input_rgb = preprocessing::split_bg_fg(input_rgb, lambda, 32).second();
- }
+ bool remove_bg = false;
+ if (argc >= 4)
+ remove_bg = (atoi(argv[3]) == 1);
- // Convert to Gray level image.
- image2d<value::int_u8>
- input_gl = data::transform(input_rgb, mln::fun::v2v::rgb_to_int_u<8>());
+ image2d<bool> output;
+ if (argc == 5 && remove_bg)
+ output = toolchain::text_in_doc_preprocess(input_rgb, lambda);
+ else
+ output = toolchain::text_in_doc_preprocess(input_rgb, remove_bg);
- // Deskewing
- std::cout << "Deskew if needed..." << std::endl;
- input_gl = preprocessing::deskew(input_gl);
-
- // Binarize foreground to use it in the processing chain.
- std::cout << "Binarizing foreground..." << std::endl;
- image2d<bool> input_bin = scribo::binarization::sauvola_ms(input_gl, 101, 3);
-
- logical::not_inplace(input_bin);
-
- mln::io::pbm::save(input_bin, argv[2]);
+ mln::io::pbm::save(output, argv[2]);
}
--
1.5.6.5
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Olena, a generic and efficient image processing platform".
The branch next has been updated
via 4515a1dc6803595b389196a908ed01c18c63a804 (commit)
via db5fcd6bc95f6202aed69fd811d18584e719cdf5 (commit)
via 18262984b19ffbd72f33e37e5e208b03521513e1 (commit)
via 6e783da9ec7535fe373a5a9f90fce24495a84d93 (commit)
via 206ddb6ba62ad2cdee862db36c025761d52898af (commit)
via d2e8cf68fc8af6d5de279bb70535516f53e56df8 (commit)
from 2520689648f68e6cbd3eb47c375102053af53019 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
No new revisions were added by this update.
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 13 ++++++
configure.ac | 81 ++++++++++++++++++++++++--------------
m4/oln-with-lib.m4 | 7 ++-
milena/ChangeLog | 4 ++
milena/mln/value/int_s.hh | 11 ++++-
scribo/ChangeLog | 9 ++++
scribo/scribo/core/line_info.hh | 56 +++++++++++++++++++--------
scribo/src/Makefile.am | 53 +++++++++----------------
8 files changed, 149 insertions(+), 85 deletions(-)
hooks/post-receive
--
Olena, a generic and efficient image processing platform
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Olena, a generic and efficient image processing platform".
The branch exp/scribo-z has been updated
via 4515a1dc6803595b389196a908ed01c18c63a804 (commit)
via db5fcd6bc95f6202aed69fd811d18584e719cdf5 (commit)
from 18262984b19ffbd72f33e37e5e208b03521513e1 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
No new revisions were added by this update.
-----------------------------------------------------------------------
Summary of changes:
milena/ChangeLog | 4 +++
milena/mln/value/int_s.hh | 11 ++++++-
scribo/ChangeLog | 5 +++
scribo/scribo/core/line_info.hh | 56 +++++++++++++++++++++++++++------------
4 files changed, 57 insertions(+), 19 deletions(-)
hooks/post-receive
--
Olena, a generic and efficient image processing platform
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Olena, a generic and efficient image processing platform".
The branch exp/next-build-ok has been updated
via 4515a1dc6803595b389196a908ed01c18c63a804 (commit)
via db5fcd6bc95f6202aed69fd811d18584e719cdf5 (commit)
from 18262984b19ffbd72f33e37e5e208b03521513e1 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
No new revisions were added by this update.
-----------------------------------------------------------------------
Summary of changes:
milena/ChangeLog | 4 +++
milena/mln/value/int_s.hh | 11 ++++++-
scribo/ChangeLog | 5 +++
scribo/scribo/core/line_info.hh | 56 +++++++++++++++++++++++++++------------
4 files changed, 57 insertions(+), 19 deletions(-)
hooks/post-receive
--
Olena, a generic and efficient image processing platform
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Olena, a generic and efficient image processing platform".
The branch exp/scribo-z has been updated
discards 2434455d28293575f4bacc80f3e7bb3cd648c3c0 (commit)
via 18262984b19ffbd72f33e37e5e208b03521513e1 (commit)
via 6e783da9ec7535fe373a5a9f90fce24495a84d93 (commit)
via 206ddb6ba62ad2cdee862db36c025761d52898af (commit)
via d2e8cf68fc8af6d5de279bb70535516f53e56df8 (commit)
via 2520689648f68e6cbd3eb47c375102053af53019 (commit)
via eecd7d1ced5f4dfc8d46bccc2edc1dacddbe635e (commit)
via c6904964636040aa2cf81dbe4f0c9f26078e8fac (commit)
This update added new revisions after undoing existing revisions. That is
to say, the old revision is not a strict subset of the new revision. This
situation occurs when you --force push a change and generate a repository
containing something like this:
* -- * -- B -- O -- O -- O (2434455d28293575f4bacc80f3e7bb3cd648c3c0)
\
N -- N -- N (18262984b19ffbd72f33e37e5e208b03521513e1)
When this happens we assume that you've already had alert emails for all
of the O revisions, and so we here report only the revisions in the N
branch from the common base, B.
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
No new revisions were added by this update.
-----------------------------------------------------------------------
Summary of changes:
AUTHORS | 12 +++++-
ChangeLog | 23 ++++++++++++
configure.ac | 81 ++++++++++++++++++++++++++---------------
m4/oln-with-lib.m4 | 7 +++-
m4/swig.m4 | 9 +++--
milena/mln/io/magick/save.hh | 1 +
scribo/ChangeLog | 4 ++
scribo/src/Makefile.am | 21 +++++------
8 files changed, 109 insertions(+), 49 deletions(-)
hooks/post-receive
--
Olena, a generic and efficient image processing platform
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Olena, a generic and efficient image processing platform".
The branch exp/next-build-ok has been updated
discards 7aad3ee217c527eef754831822f2067fad7c3adb (commit)
discards 38c94688a42d132ad9b2b8d5b2ff8a7914e1f8cd (commit)
discards 79263eb8957ea0cc946d73fc71cfdfd9f6b31abe (commit)
via 18262984b19ffbd72f33e37e5e208b03521513e1 (commit)
via 6e783da9ec7535fe373a5a9f90fce24495a84d93 (commit)
via 206ddb6ba62ad2cdee862db36c025761d52898af (commit)
via d2e8cf68fc8af6d5de279bb70535516f53e56df8 (commit)
via 2520689648f68e6cbd3eb47c375102053af53019 (commit)
via eecd7d1ced5f4dfc8d46bccc2edc1dacddbe635e (commit)
via c6904964636040aa2cf81dbe4f0c9f26078e8fac (commit)
via 565a8acd20101cf22d58b674d4d1695d8e9926c6 (commit)
via 7671c7df2acc25243c83131813db612be8a654b2 (commit)
via 15a057175710227bdea5a9702dcbf5bd64704a9d (commit)
This update added new revisions after undoing existing revisions. That is
to say, the old revision is not a strict subset of the new revision. This
situation occurs when you --force push a change and generate a repository
containing something like this:
* -- * -- B -- O -- O -- O (7aad3ee217c527eef754831822f2067fad7c3adb)
\
N -- N -- N (18262984b19ffbd72f33e37e5e208b03521513e1)
When this happens we assume that you've already had alert emails for all
of the O revisions, and so we here report only the revisions in the N
branch from the common base, B.
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
No new revisions were added by this update.
-----------------------------------------------------------------------
Summary of changes:
AUTHORS | 12 ++-
ChangeLog | 14 +++
m4/oln-with-lib.m4 | 7 +-
m4/swig.m4 | 9 +-
milena/ChangeLog | 28 +++++
milena/mln/io/magick/load.hh | 202 ++++++++++++++++++------------------
milena/mln/io/magick/save.hh | 145 ++++++++++++++-----------
milena/sandbox/ChangeLog | 44 ++++----
milena/tests/io/magick/Makefile.am | 8 +-
milena/tests/io/magick/load.cc | 72 +++++++++++--
milena/tests/io/magick/save.cc | 86 +++++++++++++--
scribo/ChangeLog | 7 ++
12 files changed, 417 insertions(+), 217 deletions(-)
hooks/post-receive
--
Olena, a generic and efficient image processing platform