#197: PGM/PBM cannot be saved as ASCII-encoded images.
-------------------------+--------------------------------------------------
Reporter: lazzara | Owner: Olena Team
Type: enhancement | Status: new
Priority: minor | Milestone: Olena 1.1
Component: Milena | Version: 1.0
Keywords: |
-------------------------+--------------------------------------------------
Currently it is only possible to load ASCII-encoded images.
While saving, they are stored as RAW images.
We should let the user choose what he prefers.
--
Ticket URL: <https://trac.lrde.org/olena/ticket/197>
Olena <http://olena.lrde.epita.fr>
Olena, a generic and efficient C++ image processing library.
#144: Fix load (and maybe save) routine(s) for ASCII-encoded PBM images
-------------------------------------+--------------------------------------
Reporter: levill_r | Owner: Olena Team
Type: defect | Status: new
Priority: critical | Milestone: Olena 1.0
Component: Milena | Version: 1.0
Keywords: I/O IO input output pbm |
-------------------------------------+--------------------------------------
Théo discovered on May 28, 2008 that the load routine for ASCII-encoded
PBM (boolean) images was broken (and maybe the save routine, too).
The other ASCII-based Netpbm should be checked as well. Don't close this
ticket until all of these routine have been inspected and declared safe!
--
Ticket URL: <https://trac.lrde.org/olena/ticket/144>
Olena <http://olena.lrde.epita.fr>
Olena, a generic and efficient C++ image processing library.
* mln/io/pbm/load.hh,
* mln/value/builtin/integers.hh: make them work with ASCII encoded
images.
* tests/io/pbm/Makefile.am,
* tests/io/pgm/Makefile.am: add new tests.
* tests/io/pbm/pbm_ascii.cc,
* tests/io/pgm/pgm_ascii.cc: new tests.
---
milena/ChangeLog | 14 +++++
milena/mln/io/pbm/load.hh | 9 ++--
milena/mln/value/builtin/integers.hh | 9 +++-
milena/tests/io/pbm/Makefile.am | 4 +-
milena/tests/io/pbm/pbm_ascii.cc | 83 +++++++++++++++++++++++++++++
milena/tests/io/pgm/Makefile.am | 2 +
milena/tests/io/pgm/pgm_ascii.cc | 95 ++++++++++++++++++++++++++++++++++
7 files changed, 209 insertions(+), 7 deletions(-)
create mode 100644 milena/tests/io/pbm/pbm_ascii.cc
create mode 100644 milena/tests/io/pgm/pgm_ascii.cc
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 98e1d16..43fe289 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,19 @@
2009-05-29 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+ Fix pbm::load and pgm::load with ASCII encoded images.
+
+ * mln/io/pbm/load.hh,
+ * mln/value/builtin/integers.hh: make them work with ASCII encoded
+ images.
+
+ * tests/io/pbm/Makefile.am,
+ * tests/io/pgm/Makefile.am: add new tests.
+
+ * tests/io/pbm/pbm_ascii.cc,
+ * tests/io/pgm/pgm_ascii.cc: new tests.
+
+2009-05-29 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
* tests/linear/Makefile.am: fix conflict name between gaussian
directory and gaussian test.
diff --git a/milena/mln/io/pbm/load.hh b/milena/mln/io/pbm/load.hh
index 81ad23d..3180c3a 100644
--- a/milena/mln/io/pbm/load.hh
+++ b/milena/mln/io/pbm/load.hh
@@ -93,12 +93,11 @@ namespace mln
mln_fwd_piter(I) p(ima.domain());
for_all(p)
{
- unsigned value;
+ unsigned char value;
file >> value;
- mln_assertion(value == 0 || value == 1);
- ima(p) = (value == 0); // In pbm, '0' means 'white' so 'object', thus 'true'!
- // FIXME: Test alt code below.
- // file >> ima(p);
+
+ mln_assertion(value == '0' || value == '1');
+ ima(p) = (value == '0'); // In pbm, '0' means 'white' so 'object', thus 'true'!
}
}
diff --git a/milena/mln/value/builtin/integers.hh b/milena/mln/value/builtin/integers.hh
index 8e83fe3..efc11d3 100644
--- a/milena/mln/value/builtin/integers.hh
+++ b/milena/mln/value/builtin/integers.hh
@@ -77,7 +77,7 @@ namespace mln
nbits = n,
card = mln_value_card_from_(n)
};
-
+
typedef trait::value::nature::integer nature;
typedef trait::value::kind::data kind;
typedef mln_value_quant_from_(card) quant;
@@ -105,6 +105,13 @@ namespace mln
{ return "signed char"; }
};
+ template <> struct value_< char >
+ : internal::value_integer_< signed char >
+ {
+ static const char* name()
+ { return "char"; }
+ };
+
template <> struct value_< unsigned short >
: internal::value_integer_< unsigned short >
{
diff --git a/milena/tests/io/pbm/Makefile.am b/milena/tests/io/pbm/Makefile.am
index 91d23f0..8649de7 100644
--- a/milena/tests/io/pbm/Makefile.am
+++ b/milena/tests/io/pbm/Makefile.am
@@ -3,8 +3,10 @@
include $(top_srcdir)/milena/tests/tests.mk
check_PROGRAMS = \
- pbm
+ pbm \
+ pbm_ascii
pbm_SOURCES = pbm.cc
+pbm_ascii_SOURCES = pbm_ascii.cc
TESTS = $(check_PROGRAMS)
diff --git a/milena/tests/io/pbm/pbm_ascii.cc b/milena/tests/io/pbm/pbm_ascii.cc
new file mode 100644
index 0000000..72b51a8
--- /dev/null
+++ b/milena/tests/io/pbm/pbm_ascii.cc
@@ -0,0 +1,83 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory
+// (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library 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 this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library 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.
+
+/// \file tests/io/pbm/pbm_asci.cc
+///
+/// Test on mln::io::pbm::load and mln::io::pbm::save.
+
+
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/image/image3d.hh>
+#include <mln/core/routine/duplicate.hh>
+
+#include <mln/value/int_u8.hh>
+
+#include <mln/io/pbm/load.hh>
+#include <mln/io/pbm/save.hh>
+
+#include <mln/level/compare.hh>
+
+#include <mln/literal/colors.hh>
+
+#include "tests/data.hh"
+
+#include <mln/level/convert.hh>
+
+#include <mln/core/image/dmorph/image_if.hh>
+
+#include <mln/make/box2d.hh>
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ image2d<bool> lena_raw;
+ io::pbm::load(lena_raw, MLN_TESTS_IMG_DIR "/lena_raw.pbm");
+
+ {
+ image2d<bool> lena_ascii;
+ io::pbm::load(lena_ascii, MLN_TESTS_IMG_DIR "/lena_ascii.pbm");
+
+ mln_assertion(lena_raw == lena_ascii);
+ }
+
+ {
+ image2d<bool> lena_ascii;
+ io::pbm::load(lena_ascii, MLN_TESTS_IMG_DIR "/lena_ascii.pbm");
+ io::pbm::save(lena_ascii, "out.pbm");
+
+ image2d<bool> out;
+ io::pbm::load(out, "out.pbm");
+
+ mln_assertion(out == lena_ascii);
+ mln_assertion(out == lena_raw);
+ }
+
+}
diff --git a/milena/tests/io/pgm/Makefile.am b/milena/tests/io/pgm/Makefile.am
index 929b163..4456e61 100644
--- a/milena/tests/io/pgm/Makefile.am
+++ b/milena/tests/io/pgm/Makefile.am
@@ -6,11 +6,13 @@ check_PROGRAMS = \
pgm16 \
pgm19 \
pgm27 \
+ pgm_ascii \
pgm
pgm16_SOURCES = pgm16.cc
pgm19_SOURCES = pgm19.cc
pgm27_SOURCES = pgm27.cc
+pgm_ascii_SOURCES = pgm_ascii.cc
pgm_SOURCES = pgm.cc
TESTS = $(check_PROGRAMS)
diff --git a/milena/tests/io/pgm/pgm_ascii.cc b/milena/tests/io/pgm/pgm_ascii.cc
new file mode 100644
index 0000000..f80774f
--- /dev/null
+++ b/milena/tests/io/pgm/pgm_ascii.cc
@@ -0,0 +1,95 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory
+// (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library 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 this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library 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.
+
+/// \file tests/io/pgm/pgm_asci.cc
+///
+/// Test on mln::io::pgm::load and mln::io::pgm::save.
+
+
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/image/image3d.hh>
+#include <mln/core/routine/duplicate.hh>
+
+#include <mln/value/int_u8.hh>
+
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+#include <mln/level/compare.hh>
+
+#include <mln/literal/colors.hh>
+
+#include "tests/data.hh"
+
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ image2d<int_u8> lena_raw;
+ io::pgm::load(lena_raw, MLN_TESTS_IMG_DIR "/lena_raw.pgm");
+
+ {
+ image2d<unsigned char> lena_ascii;
+ io::pgm::load(lena_ascii, MLN_TESTS_IMG_DIR "/lena_ascii.pgm");
+ mln_assertion(lena_raw == lena_ascii);
+ }
+ {
+ image2d<unsigned char> lena_ascii;
+ io::pgm::load(lena_ascii, MLN_TESTS_IMG_DIR "/lena_ascii.pgm");
+ io::pgm::save(lena_ascii, "out.pgm");
+
+ image2d<unsigned char> out;
+ io::pgm::load(out, "out.pgm");
+
+ mln_assertion(out == lena_ascii);
+ mln_assertion(lena_raw == out);
+ }
+
+
+
+ {
+ image2d<int_u8> lena_ascii;
+ io::pgm::load(lena_ascii, MLN_TESTS_IMG_DIR "/lena_ascii.pgm");
+ mln_assertion(lena_raw == lena_ascii);
+ }
+ {
+ image2d<int_u8> lena_ascii;
+ io::pgm::load(lena_ascii, MLN_TESTS_IMG_DIR "/lena_ascii.pgm");
+ io::pgm::save(lena_ascii, "out.pgm");
+
+ image2d<unsigned char> out;
+ io::pgm::load(out, "out.pgm");
+
+ mln_assertion(out == lena_ascii);
+ mln_assertion(lena_raw == out);
+ }
+
+}
--
1.5.6.5
#118: Ensure Milena supports separate compilation
-----------------------+----------------------------------------------------
Reporter: levill_r | Owner: lazzara
Type: defect | Status: closed
Priority: critical | Milestone: Olena 1.0
Component: Milena | Version: 1.0
Resolution: fixed | Keywords: multiple objects separate compilation
-----------------------+----------------------------------------------------
Changes (by lazzara):
* status: new => closed
* resolution: => fixed
Comment:
A new test have been added in r3916.
This test checks that the linker correctly merges global variables in a
multiple-object context.
The test use border::thickness and modify its value.
The test is divided in two files and they are compiled with the same
options. MLN_INCLUDE_ONLY is never defined.
On Linux and MacOS duplicate global symbols seems to be handled correctly.
I consider this ticket currently fixed.
--
Ticket URL: <https://trac.lrde.org/olena/ticket/118#comment:3>
Olena <http://olena.lrde.epita.fr>
Olena, a generic and efficient C++ image processing library.