Commit 738511d2 authored by Guillaume Lazzara's avatar Guillaume Lazzara
Browse files

Improve image cropping in xml_transform.

	* arthur/xml_transform/image_crop.cc,
	* arthur/xml_transform/image_crop.hh: Load the input image only
	once.

	* arthur/xml_transform/main.cc: Undef MLN_WO_GLOBAL_VARS macro.

	* arthur/xml_transform/xml_transform.pro: Enable
	MLN_WO_GLOBAL_VARS macro.
parent 24d74ffb
2010-11-18 Guillaume Lazzara <z@lrde.epita.fr>
Improve image cropping in xml_transform.
* arthur/xml_transform/image_crop.cc,
* arthur/xml_transform/image_crop.hh: Load the input image only
once.
* arthur/xml_transform/main.cc: Undef MLN_WO_GLOBAL_VARS macro.
* arthur/xml_transform/xml_transform.pro: Enable
MLN_WO_GLOBAL_VARS macro.
2010-09-02 Guillaume Lazzara <z@lrde.epita.fr>
* arthur/xml_transform/xml_transform.pro: Define NDEBUG at compile
......
......@@ -23,11 +23,7 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
# include "image_crop.hh"
# include "loader.hh"
# include "common.hh"
# include <limits.h>
#include <limits.h>
#include <scribo/preprocessing/crop.hh>
#include <mln/value/rgb8.hh>
......@@ -37,12 +33,18 @@
#include <mln/io/magick/load.hh>
#include <mln/io/ppm/all.hh>
#include "image_crop.hh"
#include "loader.hh"
#include "common.hh"
ImageCrop::ImageCrop(const QString& xml, const QString& img,
const QString& output)
: xml_(xml),
image_(img),
output_dir_(output)
{
mln::io::magick::load(ima_, image_.toStdString());
}
ImageCrop::~ImageCrop()
......@@ -53,12 +55,7 @@ ImageCrop::~ImageCrop()
/* Save image to PNG format in output_dir/img. */
void ImageCrop::save_image(const QString& out)
{
using namespace mln;
image2d<value::rgb8> ima;
io::magick::load(ima, image_.toStdString());
io::magick::save(ima, out.toStdString());
mln::io::magick::save(ima_, out.toStdString());
}
/* Return the image in base 64. */
......@@ -315,9 +312,7 @@ bool ImageCrop::crop_regions(bool temp)
using namespace mln;
box2d box = make::box2d(y_min, x_min, y_max, x_max);
image2d<value::rgb8> ima;
io::magick::load(ima, image_.toStdString());
ima = scribo::preprocessing::crop(ima, box);
image2d<value::rgb8> crop = scribo::preprocessing::crop(ima_, box);
if (temp)
{
......@@ -325,10 +320,10 @@ bool ImageCrop::crop_regions(bool temp)
tmp.open();
region_map_[id] = tmp.fileName();
tmp.setAutoRemove(false);
io::magick::save(ima, tmp.fileName().toStdString());
io::magick::save(crop, tmp.fileName().toStdString());
}
else
io::magick::save(ima, QString(output_dir_ + id + ".png").toStdString());
io::magick::save(crop, QString(output_dir_ + id + ".png").toStdString());
}
region = region.nextSibling();
}
......
......@@ -23,12 +23,16 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
#ifndef IMAGE_CROP_HH
# define IMAGE_CROP_HH
#ifndef IMAGE_CROP_HH
# define IMAGE_CROP_HH
#include <QDomDocument>
# include <QDomDocument>
# include <QtCore>
# include <mln/value/rgb8.hh>
# include <mln/core/image/image2d.hh>
class DomModel;
class ImageCrop : public QObject
......@@ -36,17 +40,6 @@ class ImageCrop : public QObject
Q_OBJECT
public:
<<<<<<< HEAD
ImageCrop(QString, QString, QString);
~ImageCrop();
void save_image(QString);
bool crop_regions(bool temp = false);
QString img_to_base64();
bool img_from_base64(QString, QString);
void to_base64(QString, bool);
=======
ImageCrop(const QString&, const QString&, const QString&);
~ImageCrop();
......@@ -56,7 +49,6 @@ class ImageCrop : public QObject
QString img_to_base64();
bool img_from_base64(const QString&, const QString&);
void to_base64(const QString&, bool);
>>>>>>> 6f0918c... Add missing const references to function arguments.
void from_base64();
......@@ -65,6 +57,7 @@ private:
QString image_;
QString output_dir_;
QMap<QString, QString> region_map_;
mln::image2d<mln::value::rgb8> ima_;
};
#endif /* !IMAGE_CROP_HH */
......@@ -3,6 +3,10 @@
#include <string>
#include <cstdlib>
#include <Magick++.h>
#undef MLN_WO_GLOBAL_VARS
#include <mln/core/image/image2d.hh>
#include "xml_transform.hh"
int main(int argc, char **argv)
......
......@@ -6,12 +6,12 @@ TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += .
QMAKE_CXXFLAGS += -I/amd/beyrouth/home/lrde/stage/crepin/git/olena/milena -I/amd/beyrouth/home/lrde/stage/crepin/git/olena/
DEFINES += NDEBUG
QMAKE_CXXFLAGS += -I../../../../milena -I../../../../scribo
DEFINES += NDEBUG MLN_WO_GLOBAL_VARS
QT += xml
LIBS += `Magick++-config --libs`
# Input
HEADERS += common.hh image_crop.hh loader.hh xml_transform.hh
SOURCES += common.cc image_crop.cc loader.cc main.cc xml_transform.cc
PWD +=
QMAKE_POST_LINK += cp -r $$PWD/templates $$OUT_PWD
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment