--- .../core/image/{gimp-image.hh => gimp_image.hh} | 26 +++++++++-- milena/mln/literal/colors.hh | 6 +- milena/mln/literal/grays.hh | 10 ++++- scribo/demo/scribogimpplugin/src/main.cc | 45 +++++++++----------- .../scribogimpplugin/src/preferences_dialog.cc | 16 ++++---- .../scribogimpplugin/src/preferences_dialog.hh | 13 ++---- scribo/demo/scribogimpplugin/src/runner.cc | 23 +++++++--- scribo/demo/scribogimpplugin/src/runner.hh | 16 ++++--- .../binarization/internal/sauvola_formula.hh | 4 +- 9 files changed, 93 insertions(+), 66 deletions(-) rename milena/mln/core/image/{gimp-image.hh => gimp_image.hh} (97%)
diff --git a/milena/mln/core/image/gimp-image.hh b/milena/mln/core/image/gimp_image.hh similarity index 97% rename from milena/mln/core/image/gimp-image.hh rename to milena/mln/core/image/gimp_image.hh index 112dc16..56d97bd 100644 --- a/milena/mln/core/image/gimp-image.hh +++ b/milena/mln/core/image/gimp_image.hh @@ -33,8 +33,17 @@ /// GIMP image wrapper. /// \todo Handle mln::duplicate(gimp_image)
+ +# include <iostream> +# include <sstream> + +extern "C" +{ +// Qt define this macro which collides with GTK symbols. +//# undef signals # include <libgimp/gimp.h> # include <libgimp/gimpui.h> +}
# include <mln/core/concept/proxy.hh> # include <mln/core/internal/image_primary.hh> @@ -51,9 +60,6 @@ # include <mln/core/w_window.hh>
-# include <iostream> -# include <sstream> - namespace mln {
@@ -331,7 +337,10 @@ namespace mln /// Gimp Image method
/// Give a hook to the GimpDrawable. - GimpDrawable* gimp_drawable_(); + GimpDrawable* gimp_drawable_() const; + + /// Return GimpDrawable's image ID. + gint32 gimp_image_id_() const; };
@@ -519,11 +528,18 @@ namespace mln
template <GimpImageType TI> GimpDrawable* - gimp_image<TI>::gimp_drawable_() + gimp_image<TI>::gimp_drawable_() const { return this->data_->drawable_; }
+ template <GimpImageType TI> + gint32 + gimp_image<TI>::gimp_image_id_() const + { + return gimp_drawable_get_image(this->data_->drawable_->drawable_id); + } +
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/literal/colors.hh b/milena/mln/literal/colors.hh index 099d2c7..64b059d 100644 --- a/milena/mln/literal/colors.hh +++ b/milena/mln/literal/colors.hh @@ -1,4 +1,4 @@ -// Copyright (C) 2007, 2008, 2009 EPITA Research and Development +// Copyright (C) 2007, 2008, 2009, 2011 EPITA Research and Development // Laboratory (LRDE) // // This file is part of Olena. @@ -183,9 +183,9 @@ namespace mln
const olive_t& olive = olive_t();
-# endif +# endif // ! MLN_WO_GLOBAL_VARS
-# endif +# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::literal
diff --git a/milena/mln/literal/grays.hh b/milena/mln/literal/grays.hh index 79aef78..7a7f330 100644 --- a/milena/mln/literal/grays.hh +++ b/milena/mln/literal/grays.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2007, 2008, 2009, 2011 EPITA Research and Development +// Laboratory (LRDE) // // This file is part of Olena. // @@ -61,15 +62,20 @@ namespace mln /// Literal dark gray. extern const dark_gray_t& dark_gray;
+ # ifndef MLN_INCLUDE_ONLY
+# ifndef MLN_WO_GLOBAL_VARS + const light_gray_t& light_gray = light_gray_t();
const medium_gray_t& medium_gray = medium_gray_t();
const dark_gray_t& dark_gray = dark_gray_t();
-# endif // !MLN_INCLUDE_ONLY +# endif // ! MLN_WO_GLOBAL_VARS + +# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::literal
diff --git a/scribo/demo/scribogimpplugin/src/main.cc b/scribo/demo/scribogimpplugin/src/main.cc index 855a6ad..c56d32a 100644 --- a/scribo/demo/scribogimpplugin/src/main.cc +++ b/scribo/demo/scribogimpplugin/src/main.cc @@ -1,16 +1,14 @@ #include "config.h"
-extern "C" -{ -#include <libgimp/gimp.h> -}
#include <stdlib.h> #include <stdio.h> #include <iostream>
#undef MLN_WO_GLOBAL_VARS -#include <gimp-image.hh> + +#include <mln/core/image/gimp_image.hh> +
#include <QApplication> #include <QMainWindow> @@ -27,6 +25,7 @@ extern "C"
#include <preferences_dialog.hh>
+ extern "C" { static void query_proc(void); @@ -143,26 +142,17 @@ extern "C" // Begin of GIMP2Milena image // ==========================
- // FIXME: move into the switch/case below. - GimpPixelRgn in; - gint32 x1, y1, x2, y2; + gint32 drawable_id = param[2].data.d_drawable; + GimpDrawable *drawable = gimp_drawable_get(drawable_id);
- gint32 drawable_id = param[2].data.d_drawable; - GimpDrawable *drawable = gimp_drawable_get(drawable_id); + typedef mln::gimp_image<GIMP_RGB_IMAGE> I;
- gimp_drawable_mask_bounds(drawable_id, &x1, &y1, &x2, &y2); - gint32 width = drawable->width; - gint32 height = drawable->height; - - gimp_pixel_rgn_init(&in, drawable, x1, y1, x2, y2, FALSE, FALSE); - - typedef mln::gimp_image<GIMP_RGB_IMAGE> I; - I tmp(&in); - mln::image2dmln::value::rgb8 input(height, width); - std::cout << "Paste data into Olena image" << std::endl; - mln::data::paste(tmp, input); - mln::io::ppm::save(input, "/tmp/gimp_out.ppm"); - std::cout << "Paste data into Olena image: Done." << std::endl; + mln::util::timer t; + t.start(); + I input(drawable); + t.stop(); + std::cout << "Milena Gimp image built in " << t << "s" << std::endl; + t.restart();
// // Create a new image // gint32 new_image_id = gimp_image_new(width, @@ -170,7 +160,7 @@ extern "C" // gimp_image_base_type(param[1].data.d_image)); // /* create new layer */ // gint32 new_layer_id = gimp_layer_new(new_image_id, - // "titi", + // "DIA Output", // width, height, // gimp_drawable_type(drawable_id), // 100, @@ -210,7 +200,7 @@ extern "C" case GIMP_RUN_INTERACTIVE: { preferences_dialog dialog; - dialog.set_current_image(input, param[1].data.d_image); + dialog.set_current_image(input); dialog.show();
// Run application. @@ -238,7 +228,12 @@ extern "C" } break; } + + t.stop(); + std::cout << "Gimp image processed in " << t << "s" << std::endl; + } + }
diff --git a/scribo/demo/scribogimpplugin/src/preferences_dialog.cc b/scribo/demo/scribogimpplugin/src/preferences_dialog.cc index 8daea32..b5253c6 100644 --- a/scribo/demo/scribogimpplugin/src/preferences_dialog.cc +++ b/scribo/demo/scribogimpplugin/src/preferences_dialog.cc @@ -28,6 +28,7 @@ #include <mln/data/convert.hh> #include <mln/data/paste_without_localization.hh> #include <mln/core/image/dmorph/image_if.hh> +#include <mln/data/paste.hh>
preferences_dialog::preferences_dialog(QWidget *parent) @@ -75,10 +76,10 @@ preferences_dialog::~preferences_dialog() }
-void preferences_dialog::set_current_image(const mln::image2dmln::value::rgb8& ima, gint32 image_id) +void preferences_dialog::set_current_image(const mln::gimp_image<GIMP_RGB_IMAGE>& ima) { current_image_ = ima; - image_id_ = image_id; + image_id_ = ima.gimp_image_id_(); }
@@ -192,17 +193,16 @@ void preferences_dialog::diplay_result() { std::cout << "Creating result image" << std::endl;
- // Make sure there is not border in input image. - mln::border::resize(current_image_, 0); - // Getting retrieved document. const scribo::document<L>& doc = runner_.result();
- image2dvalue::qt::rgb32 in_32 = data::convert(value::qt::rgb32(), current_image_); + image2dvalue::rgb8 in_24; // FIXME: to be removed! + data::paste(current_image_, in_24); + image2dvalue::qt::rgb32 in_32 = data::convert(value::qt::rgb32(), in_24);
int - width = current_image_.bbox().width(), - height = current_image_.bbox().height(); + width = current_image_.domain().width(), + height = current_image_.domain().height();
// Get active drawable in input image. gint32 drawable_id = gimp_image_get_active_drawable(image_id_); diff --git a/scribo/demo/scribogimpplugin/src/preferences_dialog.hh b/scribo/demo/scribogimpplugin/src/preferences_dialog.hh index 1e6f163..c6e172c 100644 --- a/scribo/demo/scribogimpplugin/src/preferences_dialog.hh +++ b/scribo/demo/scribogimpplugin/src/preferences_dialog.hh @@ -18,20 +18,15 @@ #ifndef SCRIBO_DEMO_VIEWER_PREFERENCES_DIALOG_HH # define SCRIBO_DEMO_VIEWER_PREFERENCES_DIALOG_HH
-extern "C" -{ -#include <libgimp/gimp.h> -} - +# include <mln/core/image/gimp_image.hh>
-# include <QtGui> # include <preferences_dialog.ui.h>
# include <runner.hh>
# include <mln/core/image/image2d.hh> # include <scribo/core/def/lbl_type.hh> - +# include <QtGui>
class preferences_dialog : public QDialog, private Ui::PreferencesDialog { @@ -43,7 +38,7 @@ public: preferences_dialog(QWidget *parent = 0); ~preferences_dialog();
- void set_current_image(const mln::image2dmln::value::rgb8& ima, gint32 image_id); + void set_current_image(const mln::gimp_image<GIMP_RGB_IMAGE>& ima);
private slots: void on_optionList_currentRowChanged(int row); @@ -63,7 +58,7 @@ private: // Attributes runner runner_; QProgressDialog pdialog_;
- mln::image2dmln::value::rgb8 current_image_; + mln::gimp_image<GIMP_RGB_IMAGE> current_image_; gint32 image_id_; };
diff --git a/scribo/demo/scribogimpplugin/src/runner.cc b/scribo/demo/scribogimpplugin/src/runner.cc index 82e83e2..e91d15c 100644 --- a/scribo/demo/scribogimpplugin/src/runner.cc +++ b/scribo/demo/scribogimpplugin/src/runner.cc @@ -16,7 +16,6 @@ // along with Olena. If not, see http://www.gnu.org/licenses/.
#include "runner.hh" - #include <mln/core/image/image2d.hh> #include <mln/value/rgb8.hh> #include <mln/io/magick/load.hh> @@ -68,7 +67,7 @@ void runner::stop() // Demat related stuff
void -runner::start_demat(const image2dvalue::rgb8& image) +runner::start_demat(const gimp_image<GIMP_RGB_IMAGE>& image) { args_.clear(); args_ << image; @@ -90,7 +89,7 @@ runner::progress_value() }
image2d<bool> -runner::preprocess(const image2dvalue::rgb8& ima) +runner::preprocess(const gimp_image<GIMP_RGB_IMAGE>& ima) { emit new_step("Preprocessing");
@@ -114,15 +113,21 @@ runner::preprocess(const image2dvalue::rgb8& ima)
emit new_progress_max_value(f.nsteps());
+ + // FIXME : to be removed. Used to convert gimp_image + image2dvalue::rgb8 ima_; + mln::initialize(ima_, ima); + data::paste(ima, ima_); + // Perform preprocessing. - f(ima); + f(ima_);
qDebug() << "Preprocess Done."; return f.output; }
-void runner::process(const image2dvalue::rgb8& original_ima, +void runner::process(const gimp_image<GIMP_RGB_IMAGE>& original_ima, const image2d<bool>& processed_ima) { emit new_step("Page segmentation"); @@ -150,8 +155,14 @@ void runner::process(const image2dvalue::rgb8& original_ima,
emit new_progress_max_value(f.nsteps());
+ // FIXME : to be removed. Used to convert gimp_image + image2dvalue::rgb8 ima_; + mln::initialize(ima_, original_ima); + data::paste(original_ima, ima_); + + // Perform text detection. - f(original_ima, processed_ima); + f(ima_, processed_ima);
doc_ = f.doc;
diff --git a/scribo/demo/scribogimpplugin/src/runner.hh b/scribo/demo/scribogimpplugin/src/runner.hh index d08e1a0..6611b71 100644 --- a/scribo/demo/scribogimpplugin/src/runner.hh +++ b/scribo/demo/scribogimpplugin/src/runner.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2010, 2011 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -17,8 +18,10 @@ #ifndef SCRIBO_DEMO_VIEWER_RUNNER_HH # define SCRIBO_DEMO_VIEWER_RUNNER_HH
-# include <QtGui> +# include <mln/core/image/gimp_image.hh>
+# include <QtCore> +# include <QtGui> # include <mln/core/image/image2d.hh> # include <mln/value/rgb8.hh> # include <mln/value/int_u16.hh> @@ -27,6 +30,7 @@
using namespace mln;
+ enum RunMode { Demat, @@ -42,7 +46,7 @@ public:
runner(QObject *parent = 0);
- void start_demat(const image2dvalue::rgb8& filename); + void start_demat(const gimp_image<GIMP_RGB_IMAGE>& filename);
const doc_t& result() const;
@@ -58,14 +62,14 @@ signals: void finished();
private: // members - image2d<bool> preprocess(const image2dvalue::rgb8& ima); - void process(const image2dvalue::rgb8& original_ima, + image2d<bool> preprocess(const gimp_image<GIMP_RGB_IMAGE>& ima); + void process(const gimp_image<GIMP_RGB_IMAGE>& original_ima, const image2d<bool>& processed_ima);
virtual void run();
private: // attributes - QList<image2dvalue::rgb8 > args_; + QList<gimp_image<GIMP_RGB_IMAGE> > args_; RunMode mode_; int step_;
diff --git a/scribo/scribo/binarization/internal/sauvola_formula.hh b/scribo/scribo/binarization/internal/sauvola_formula.hh index 3251abd..adbef13 100644 --- a/scribo/scribo/binarization/internal/sauvola_formula.hh +++ b/scribo/scribo/binarization/internal/sauvola_formula.hh @@ -83,8 +83,8 @@ namespace scribo
# ifndef MLN_INCLUDE_ONLY
- bool b; - double skewness_; + // bool b; + // double skewness_;
inline double