* mln/io/magick/load.hh
(mln::io::magick::load(Image<I>&, const std::string&))
* mln/io/magick/save.hh
(mln::io::magick::impl::get_color(const value::int_u8&))
(mln::io::magick::impl::get_color(const value::rgb8&)):
Properly convert values between Magick::Quantum and
mln::value::int_u8, and vice versa.
---
milena/ChangeLog | 12 ++++++++++++
milena/mln/io/magick/load.hh | 17 +++++++++++------
milena/mln/io/magick/save.hh | 30 ++++++++++++++++++++++--------
3 files changed, 45 insertions(+), 14 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 8e8cf88..67eefef 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,15 @@
+2010-10-28 Roland Levillain <roland(a)lrde.epita.fr>
+
+ Handle properly non 8-bit Magick::Quantum's.
+
+ * mln/io/magick/load.hh
+ (mln::io::magick::load(Image<I>&, const std::string&))
+ * mln/io/magick/save.hh
+ (mln::io::magick::impl::get_color(const value::int_u8&))
+ (mln::io::magick::impl::get_color(const value::rgb8&)):
+ Properly convert values between Magick::Quantum and
+ mln::value::int_u8, and vice versa.
+
2010-10-27 Roland Levillain <roland(a)lrde.epita.fr>
Autoconfiscate Milena.
diff --git a/milena/mln/io/magick/load.hh b/milena/mln/io/magick/load.hh
index 7004a80..60e857e 100644
--- a/milena/mln/io/magick/load.hh
+++ b/milena/mln/io/magick/load.hh
@@ -35,8 +35,6 @@
/// <em>before</em> using any of these functions, as advised by the
/// GraphicsMagick documentation
/// (http://www.graphicsmagick.org/Magick++/Image.html).
-///
-/// \fixme: re-enable quantum size check
# include <cstdlib>
@@ -142,9 +140,6 @@ namespace mln
{
trace::entering("mln::io::magick::load");
- // Ensure a Magick++'s Quantum is an 8-bit value.
- //mln::metal::equal<Magick::Quantum, unsigned char>::check();
-
I& ima = exact(ima_);
// FIXME: Handle Magick++'s exceptions (see either
@@ -166,7 +161,17 @@ namespace mln
mln_piter(I) p(ima.domain());
for_all(p)
{
- value::rgb8 c(pixels->red, pixels->green, pixels->blue);
+ /* Each channel of a Magick++ image is coded on a
+ Magick::Quantum value, which can be an 8-, 16- or 32-bit
+ integer. Load the most significant bits of each channel
+ into a component of an mln::value::rgb8 value (i.e., into
+ an mln::value::int_u8 value). */
+ value::rgb8 c(pixels->red >> 8 * (sizeof(Magick::Quantum)
+ - sizeof(value::rgb8::red_t)),
+ pixels->green >> 8 * (sizeof(Magick::Quantum)
+ - sizeof(value::rgb8::green_t)),
+ pixels->blue >> 8 * (sizeof(Magick::Quantum)
+ - sizeof(value::rgb8::blue_t)));
mln_value(I) res;
if (!impl::do_it(c, res))
{
diff --git a/milena/mln/io/magick/save.hh b/milena/mln/io/magick/save.hh
index 2c87c88..7a91ee0 100644
--- a/milena/mln/io/magick/save.hh
+++ b/milena/mln/io/magick/save.hh
@@ -35,8 +35,6 @@
/// <em>before</em> using any of these functions, as advised by the
/// GraphicsMagick documentation
/// (http://www.graphicsmagick.org/Magick++/Image.html).
-///
-/// \fixme: re-enable quantum size check
# include <cstdlib>
@@ -95,17 +93,33 @@ namespace mln
inline
Magick::Color get_color(const value::int_u8& value)
{
- // Ensure a Magick++'s Quantum is an 8-bit value.
- //mln::metal::equal<Magick::Quantum, unsigned char>::check();
- return Magick::Color(value, value, value);
+ /* Each channel of a Magick++ image is coded on a
+ Magick::Quantum value, which can be an 8-, 16- or 32-bit
+ integer. Store the data from each mln::value::int_u8
+ values into the most significant bits of Magick::Color's
+ channels. */
+ return Magick::Color
+ (value << 8 * (sizeof(Magick::Quantum) - sizeof(value::int_u8)),
+ value << 8 * (sizeof(Magick::Quantum) - sizeof(value::int_u8)),
+ value << 8 * (sizeof(Magick::Quantum) - sizeof(value::int_u8)));
}
inline
Magick::Color get_color(const value::rgb8& value)
{
- // Ensure a Magick++'s Quantum is an 8-bit value.
- //mln::metal::equal<Magick::Quantum, unsigned char>::check();
- return Magick::Color(value.red(), value.green(), value.blue());
+ /* Each channel of a Magick++ image is coded on a
+ Magick::Quantum value, which can be an 8-, 16- or 32-bit
+ integer. Store the data from each component of
+ mln::value::rgb8 values (of type mln::value::int_u8) into
+ the most significant bits of Magick::Color's
+ channels. */
+ return Magick::Color
+ (value.red() << 8 * (sizeof(Magick::Quantum)
+ - sizeof(value::rgb8::red_t)),
+ value.green() << 8 * (sizeof(Magick::Quantum)
+ - sizeof(value::rgb8::green_t)),
+ value.blue() << 8 * (sizeof(Magick::Quantum)
+ - sizeof(value::rgb8::blue_t)));
}
} // end of namespace mln::io::magick::impl
--
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 autoconfiscate-subprojects has been updated
discards 86cd9e2a9ba4e3a5941c263e0eb3a049486c3550 (commit)
discards 1e1204928dfc3b14877d139f6cc530f10cc08d3f (commit)
discards 82a8284278d46caae6e13ba9d78fc1aa67ff2f98 (commit)
via ae9a8715e6cb27af6b7f0e838953287e8fadcca6 (commit)
via e0bd3016c3669933fe34cdfd7589d7c7b837427c (commit)
via 7f1221803f2ef0af6b72c02d4b2b798d7fe03205 (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 (86cd9e2a9ba4e3a5941c263e0eb3a049486c3550)
\
N -- N -- N (ae9a8715e6cb27af6b7f0e838953287e8fadcca6)
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 -----------------------------------------------------------------
ae9a871 Add advice about the release process.
e0bd301 Have Milena be in charge of its own configuration and distribution.
7f12218 Autoconfiscate Milena.
-----------------------------------------------------------------------
Summary of changes:
milena/ChangeLog | 7 +++++++
milena/doc/Doxyfile.in | 32 ++++++++++++++++----------------
milena/doc/gen-examples-outputs-mk | 2 +-
milena/doc/gen-split-examples-mk | 2 +-
milena/doc/programs-examples.mk | 6 +++---
milena/doc/tools/data.hh.in | 2 +-
milena/doc/tutorial.tex | 17 ++++++++---------
7 files changed, 37 insertions(+), 31 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 fix-swilena-deps-tracking has been deleted
was 7924629f9a5ed75553a8fa6cee857bf59b634c0f
-----------------------------------------------------------------------
7924629f9a5ed75553a8fa6cee857bf59b634c0f Fix Swilena's dependency tracking.
-----------------------------------------------------------------------
hooks/post-receive
--
Olena, a generic and efficient image processing platform
* 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 | 39 ++----
3 files changed, 170 insertions(+), 29 deletions(-)
create mode 100644 scribo/scribo/toolchain/text_in_doc_preprocess.hh
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 5fe30ab..45ebaaf 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 fdbb018..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,28 +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();
- }
- // Convert to Gray level image.
- image2d<value::int_u8>
- input_gl = data::transform(input_rgb, mln::fun::v2v::rgb_to_int_u<8>());
+ bool remove_bg = false;
+ if (argc >= 4)
+ remove_bg = (atoi(argv[3]) == 1);
+ image2d<bool> output;
- // 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);
+ 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);
- mln::io::pbm::save(input_bin, argv[2]);
+ mln::io::pbm::save(output, argv[2]);
}
--
1.5.6.5