* text/clean.hh: Make use of text::clean_inplace.
* text/clean_inplace.hh: New.
* text/recognition.hh: Include text::clean_inplace.
---
scribo/ChangeLog | 10 ++++++
scribo/text/clean.hh | 31 ++----------------
scribo/text/{clean.hh => clean_inplace.hh} | 45 +++++++++++++---------------
scribo/text/recognition.hh | 2 +-
4 files changed, 36 insertions(+), 52 deletions(-)
copy scribo/text/{clean.hh => clean_inplace.hh} (74%)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index cbd813f..43a08c0 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,3 +1,13 @@
+2010-06-29 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Add text::clean_inplace.
+
+ * text/clean.hh: Make use of text::clean_inplace.
+
+ * text/clean_inplace.hh: New.
+
+ * text/recognition.hh: Include text::clean_inplace.
+
2010-06-25 Guillaume Lazzara <z(a)lrde.epita.fr>
Small Fixes in Scribo build system.
diff --git a/scribo/text/clean.hh b/scribo/text/clean.hh
index 1a9e458..208fe8e 100644
--- a/scribo/text/clean.hh
+++ b/scribo/text/clean.hh
@@ -71,6 +71,7 @@
#include <scribo/upsampling/eagle.hh>
#include <scribo/subsampling/bilinear.hh>
+#include <scribo/text/clean_inplace.hh>
namespace scribo
{
@@ -83,6 +84,8 @@ namespace scribo
/// Improve quality of an image with text.
///
+ /// \param[in] line Line info providing statistics about the text
+ /// in the corresponding image \p input.
/// \param[in] input_ A binary image. Object are set to 'false'
/// and backgroud to 'true'.
///
@@ -109,33 +112,7 @@ namespace scribo
mln_concrete(I) output = duplicate(input);
- if (line.x_height() < 5) // Non significative text/remaining lines...
- return output;
-
- float fact = line.x_height() / 40.0f;
- std::cout << fact << " - " << output.domain() <<
std::endl;
- if (fact < 1)
- {
- std::cout << "Upsampling..." << " - "
- << fact << std::endl;
- while (fact < 0.90)
- {
- output = scribo::upsampling::eagle(output); // 2x upsampling
- fact *= 2.0f;
-// std::cout << "fact = " << fact
-// << " - output.domain = " << output.domain()
-// << std::endl;
- }
- }
- else if (fact > 2.5f)
- {
- std::cout << "subsampling::bilinear" << " - "
- << std::ceil(fact) << std::endl;
- output = subsampling::bilinear(output, std::ceil(fact - 0.5)); // math::floor instead?
-
- }
- else
- std::cout << "not cleaning text. Seems ok." << std::endl;
+ clean_inplace(line, output);
trace::exiting("scribo::text::clean");
return output;
diff --git a/scribo/text/clean.hh b/scribo/text/clean_inplace.hh
similarity index 74%
copy from scribo/text/clean.hh
copy to scribo/text/clean_inplace.hh
index 1a9e458..2db3b73 100644
--- a/scribo/text/clean.hh
+++ b/scribo/text/clean_inplace.hh
@@ -1,5 +1,4 @@
-// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -24,8 +23,8 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef SCRIBO_TEXT_CLEAN_HH
-# define SCRIBO_TEXT_CLEAN_HH
+#ifndef SCRIBO_TEXT_CLEAN_INPLACE_HH
+# define SCRIBO_TEXT_CLEAN_INPLACE_HH
/// \file
///
@@ -83,47 +82,46 @@ namespace scribo
/// Improve quality of an image with text.
///
- /// \param[in] input_ A binary image. Object are set to 'false'
- /// and backgroud to 'true'.
- ///
- /// \return An image. The text have better quality.
+ /// \param[in] line Line info providing statistics about the text
+ /// in the corresponding image \p input.
+ /// \param[in,out] input A binary image. Object are set to 'false'
+ /// and backgroud to 'true'.
//
template <typename L, typename I>
- mln_concrete(I)
- clean(const line_info<L>& line, const Image<I>& input_);
+ void
+ clean_inplace(const line_info<L>& line, Image<I>& input);
# ifndef MLN_INCLUDE_ONLY
template <typename L, typename I>
- mln_concrete(I)
- clean(const line_info<L>& line, const Image<I>& input_)
+ void
+ clean_inplace(const line_info<L>& line, Image<I>& input_)
{
- trace::entering("scribo::text::clean");
+ trace::entering("scribo::text::clean_inplace");
- const I& input = exact(input_);
+ I& input = exact(input_);
mlc_bool(mln_site_(I)::dim == 2)::check();
mlc_equal(mln_value(I),bool)::check();
mln_precondition(input.is_valid());
mln_precondition(line.is_valid());
- mln_concrete(I) output = duplicate(input);
if (line.x_height() < 5) // Non significative text/remaining lines...
- return output;
+ return;
float fact = line.x_height() / 40.0f;
- std::cout << fact << " - " << output.domain() <<
std::endl;
+ std::cout << fact << " - " << input.domain() <<
std::endl;
if (fact < 1)
{
std::cout << "Upsampling..." << " - "
<< fact << std::endl;
while (fact < 0.90)
{
- output = scribo::upsampling::eagle(output); // 2x upsampling
+ input = scribo::upsampling::eagle(input); // 2x upsampling
fact *= 2.0f;
// std::cout << "fact = " << fact
-// << " - output.domain = " << output.domain()
+// << " - input.domain = " << input.domain()
// << std::endl;
}
}
@@ -131,14 +129,13 @@ namespace scribo
{
std::cout << "subsampling::bilinear" << " - "
<< std::ceil(fact) << std::endl;
- output = subsampling::bilinear(output, std::ceil(fact - 0.5)); // math::floor instead?
+ input = subsampling::bilinear(input, std::ceil(fact - 0.5)); // math::floor instead?
}
else
- std::cout << "not cleaning text. Seems ok." << std::endl;
+ std::cout << "not clean_inplaceing text. Seems ok." << std::endl;
- trace::exiting("scribo::text::clean");
- return output;
+ trace::exiting("scribo::text::clean_inplace");
}
# endif // ! MLN_INCLUDE_ONLY
@@ -147,4 +144,4 @@ namespace scribo
} // end of namespace scribo
-#endif // ! SCRIBO_TEXT_CLEAN_HH
+#endif // ! SCRIBO_TEXT_CLEAN_INPLACE_HH
diff --git a/scribo/text/recognition.hh b/scribo/text/recognition.hh
index 35d343a..506ed66 100644
--- a/scribo/text/recognition.hh
+++ b/scribo/text/recognition.hh
@@ -53,7 +53,7 @@
# include <scribo/core/macros.hh>
-# include <scribo/text/clean.hh>
+# include <scribo/text/clean_inplace.hh>
# include <scribo/core/line_set.hh>
--
1.5.6.5
Show replies by date