URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog:
2009-09-24 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Add benchmark for disk-mapped image and work for color types.
* fabien/igr/color/find_color.cc: Find green color in an image.
* fabien/mln/core/image/disk_ima.hh: Implement disk-mapped image.
* fabien/mln/io/pnm/load_disk_ima.hh: Implement loading of disk-
mapped image from a PNM file.
* fabien/tests/core/image/bench.sh: New script for benchmarking
disk-mapped image and tiled image.
* fabien/mln/test/conversion.hh: Implement test for evaluation of
type conversion.
* fabien/tests/test/conversion.cc: Test evalution of type conversion.
---
igr/color/find_color.cc | 34 ++++++++---
mln/core/image/disk_ima.hh | 1
mln/io/pnm/load_disk_ima.hh | 88 ++++++++++++++++++++++++++++
mln/test/conversion.hh | 136 ++++++++++++++++++++++++++++++++++++++++++++
tests/core/image/bench.sh | 12 +++
tests/test/conversion.cc | 33 ++++++++++
6 files changed, 297 insertions(+), 7 deletions(-)
Index: trunk/milena/sandbox/fabien/igr/color/find_color.cc
===================================================================
--- trunk/milena/sandbox/fabien/igr/color/find_color.cc (revision 4544)
+++ trunk/milena/sandbox/fabien/igr/color/find_color.cc (revision 4545)
@@ -1,18 +1,23 @@
#include <mln/core/image/image2d.hh>
+#include <mln/io/pgm/all.hh>
#include <mln/io/ppm/all.hh>
#include <mln/value/rgb8.hh>
#include <mln/value/hsl.hh>
+#include <mln/value/int_u8.hh>
#include <mln/convert/from_to.hh>
#include <mln/data/convert.hh>
+#include <mln/math/diff_abs.hh>
using namespace mln;
using value::rgb8;
using value::hsl_;
+using value::int_u8;
+inline
bool
is_green(hsl_<float, float, float> value)
{
@@ -24,6 +29,24 @@
return false;
}
+inline
+int_u8
+how_green(hsl_<float, float, float> value)
+{
+ float proba = 0.0;
+
+ if (value.hue() > 60 && value.hue() < 180)
+ {
+ proba += 1.f - ((math::diff_abs(120.f, value.hue()) / 100.0) / 0.6);
+ proba *= value.sat();
+ proba *= 1.f - (math::diff_abs(0.5f, value.lum()));
+ }
+
+ if (proba > 1.f)
+ proba = 1.f;
+ return (int_u8) (proba * 255);
+}
+
int main(int argc, char* argv[])
{
if (argc != 3)
@@ -34,21 +57,18 @@
image2d<rgb8> input;
io::ppm::load(input, argv[1]);
+ image2d<int_u8> output;
+ initialize(output, input);
typedef image2d<hsl_<float, float, float> > H;
H ima_hsl = data::convert(hsl_<float, float, float>(), input);
mln_piter_(H) p(ima_hsl.domain());
for_all(p)
{
- if (!is_green(ima_hsl(p)))
- {
- ima_hsl(p).sat() = 0.3;
- ima_hsl(p).lum() = 0.3;
- }
+ output(p) = how_green(ima_hsl(p));
}
- image2d<rgb8> output = data::convert(rgb8(), ima_hsl);
- io::ppm::save(output, argv[2]);
+ io::pgm::save(output, argv[2]);
return 0;
}
Index: trunk/milena/sandbox/fabien/tests/test/conversion.cc
===================================================================
--- trunk/milena/sandbox/fabien/tests/test/conversion.cc (revision 0)
+++ trunk/milena/sandbox/fabien/tests/test/conversion.cc (revision 4545)
@@ -0,0 +1,33 @@
+#include <mln/core/image/image2d.hh>
+
+#include <mln/io/pgm/all.hh>
+#include <mln/io/ppm/all.hh>
+
+#include <mln/value/rgb8.hh>
+#include <mln/value/hsl.hh>
+
+#include <mln/test/conversion.hh>
+
+using namespace mln;
+using value::rgb8;
+using value::hsl_;
+using value::int_u8;
+
+
+int main(int argc, char* argv[])
+{
+ if (argc != 2)
+ {
+ std::cout << "Usage: " << argv[0] << " input" << std::endl;
+ return 1;
+ }
+
+ image2d<rgb8> input;
+ io::ppm::load(input, argv[1]);
+
+ float delta = test::conversion(input, hsl_<float, float, float>());
+
+ std::cout << "delta conversion = " << delta << std::endl;
+
+ return 0;
+}
Index: trunk/milena/sandbox/fabien/tests/core/image/bench.sh
===================================================================
--- trunk/milena/sandbox/fabien/tests/core/image/bench.sh (revision 0)
+++ trunk/milena/sandbox/fabien/tests/core/image/bench.sh (revision 4545)
@@ -0,0 +1,12 @@
+#! /bin/sh
+
+make disk_ima
+make tiled2d
+
+echo "---"
+echo "Disk Image Performance"
+time ./disk_ima $1
+
+echo "---"
+echo "Tiled Image Performance"
+time ./tiled2d $1
Property changes on: trunk/milena/sandbox/fabien/tests/core/image/bench.sh
___________________________________________________________________
Added: svn:executable
+ *
Index: trunk/milena/sandbox/fabien/mln/test/conversion.hh
===================================================================
--- trunk/milena/sandbox/fabien/mln/test/conversion.hh (revision 0)
+++ trunk/milena/sandbox/fabien/mln/test/conversion.hh (revision 4545)
@@ -0,0 +1,136 @@
+// Copyright (C) 2009 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 MLN_TEST_CONVERSION_HH
+# define MLN_TEST_CONVERSION_HH
+
+/// \file
+///
+/// Test a conversion on the pixel values of an image.
+
+# include <mln/core/concept/image.hh>
+# include <mln/data/convert.hh>
+# include <mln/math/diff_abs.hh>
+# include <mln/value/rgb8.hh>
+
+
+namespace mln
+{
+
+ namespace test
+ {
+
+ /// Test if all pixel values of \p ima can correctly convert into
+ /// the type of \p value and then reconvert into their original
+ /// type.
+ ///
+ /// \param[in] ima The image.
+ /// \param[in] value A value of the conversion type.
+ //
+ template <typename I, typename V>
+ float conversion(const Image<I>& ima, const V& value);
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ // Implementations.
+
+ namespace impl
+ {
+
+ template <typename V>
+ inline
+ float color_distance(const V& color1, const V& color2)
+ {
+ return -1.0; // FIXME
+ }
+
+ template <>
+ inline
+ float color_distance<value::rgb8>(const value::rgb8& color1, const value::rgb8& color2)
+ {
+ float dist = 0.0;
+
+ dist += math::diff_abs(color1.red(), color2.red());
+ dist += math::diff_abs(color1.green(), color2.green());
+ dist += math::diff_abs(color1.blue(), color2.blue());
+
+ dist /= 3 * 255;
+
+ return dist;
+ }
+
+ /// \return The percentage of points which value is not preserved.
+ /// The return value is normalized ([0..1]).
+ template <typename I, typename V>
+ inline
+ float conversion_(const I& ima, const V& value)
+ {
+ float delta = 0;
+
+ typedef mln_ch_value(I, V) J;
+ J converted = data::convert(value, ima);
+ I output = data::convert(mln_value(I)(), converted);
+
+ mln_piter(I) p(ima.domain());
+ for_all(p)
+ {
+ delta += color_distance(ima(p), output(p));
+ //if (ima(p) != output(p))
+ // delta += 1.0;
+ }
+
+ delta /= ima.nelements();
+ return delta;
+ }
+
+ } // end of namespace mln::test::impl
+
+
+
+ // Facades.
+
+
+ template <typename I, typename V>
+ inline
+ float conversion(const Image<I>& ima, const V& value)
+ {
+ trace::entering("test::conversion");
+
+ float res = impl::conversion_(exact(ima), value);
+
+ trace::exiting("test::conversion");
+ return res;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::test
+
+} // end of namespace mln
+
+
+#endif // ! MLN_TEST_CONVERSION_HH
Index: trunk/milena/sandbox/fabien/mln/io/pnm/load_disk_ima.hh
===================================================================
--- trunk/milena/sandbox/fabien/mln/io/pnm/load_disk_ima.hh (revision 0)
+++ trunk/milena/sandbox/fabien/mln/io/pnm/load_disk_ima.hh (revision 4545)
@@ -0,0 +1,88 @@
+// Copyright (C) 2009 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 MLN_IO_PNM_LOAD_DISK_IMA_HH
+# define MLN_IO_PNM_LOAD_DISK_IMA_HH
+
+/// \file
+///
+/// Define a function which loads an image of kind PNM 8/16bits with
+/// given path.
+
+# include <iostream>
+# include <fstream>
+# include <string>
+
+# include <mln/io/pnm/load_header.hh>
+# include <mln/io/pnm/max_component.hh>
+# include <mln/io/pnm/macros.hh>
+
+# include <mln/metal/is_a.hh>
+
+namespace mln
+{
+
+ namespace io
+ {
+
+ namespace pnm
+ {
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ // Warning if we try to load uncontiguous 2D PNM file into a disk
+ // image, this is not currently supported.
+ template <typename V>
+ inline
+ void load_raw_2d_uncontiguous(std::ifstream& file, disk_ima<V>& ima)
+ {
+ (void) file;
+ (void) ima;
+ std::cout << "You can't load an uncontiguous 2D PNM file into ";
+ std::cout << "a disk image" << std::endl;
+ abort();
+ }
+
+ // Load raw 2d for disk images.
+ template <typename T>
+ inline
+ void load_raw_2d_contiguous(std::ifstream& file, disk_ima<T>& ima, const std::string& filename)
+ {
+ ima.pos_() = file.tellg();
+ ima.file_() = filename;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::io::pnm
+
+ } // end of namespace mln::io
+
+} // end of namespace mln
+
+
+#endif // ! MLN_IO_PNM_LOAD_DISK_IMA_HH
Index: trunk/milena/sandbox/fabien/mln/core/image/disk_ima.hh
===================================================================
--- trunk/milena/sandbox/fabien/mln/core/image/disk_ima.hh (revision 4544)
+++ trunk/milena/sandbox/fabien/mln/core/image/disk_ima.hh (revision 4545)
@@ -638,6 +638,7 @@
# include <mln/make/image.hh>
+# include <mln/io/pnm/load_disk_ima.hh>
#endif // ! MLN_CORE_IMAGE_DISK_IMA_HH
* mln/upscaling/art/scale2x.hh,
* mln/upscaling/art/scale3x.hh: New routines.
* tests/Makefile.am,
* tests/upscaling/Makefile.am,
* tests/upscaling/art/Makefile.am,
* tests/upscaling/art/scale2x.cc,
* tests/upscaling/art/scale3x.cc: New associated tests.
---
milena/ChangeLog | 13 ++
milena/mln/upscaling/art/scale2x.hh | 151 ++++++++++++++++++++++
milena/mln/upscaling/art/scale3x.hh | 218 ++++++++++++++++++++++++++++++++
milena/tests/Makefile.am | 1 +
milena/tests/upscaling/Makefile.am | 24 ++++
milena/tests/upscaling/art/Makefile.am | 32 +++++
milena/tests/upscaling/art/scale2x.cc | 59 +++++++++
milena/tests/upscaling/art/scale3x.cc | 61 +++++++++
8 files changed, 559 insertions(+), 0 deletions(-)
create mode 100644 milena/mln/upscaling/art/scale2x.hh
create mode 100644 milena/mln/upscaling/art/scale3x.hh
create mode 100644 milena/tests/upscaling/Makefile.am
create mode 100644 milena/tests/upscaling/art/Makefile.am
create mode 100644 milena/tests/upscaling/art/scale2x.cc
create mode 100644 milena/tests/upscaling/art/scale3x.cc
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 3100c37..19c3edd 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,18 @@
2009-09-22 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+ Add new upscaling algorithms.
+
+ * mln/upscaling/art/scale2x.hh,
+ * mln/upscaling/art/scale3x.hh: New routines.
+
+ * tests/Makefile.am,
+ * tests/upscaling/Makefile.am,
+ * tests/upscaling/art/Makefile.am,
+ * tests/upscaling/art/scale2x.cc,
+ * tests/upscaling/art/scale3x.cc: New associated tests.
+
+2009-09-22 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
* mln/core/alias/dpoint2d.hh: Add new dpoint2d aliases.
2009-09-22 Fabien Freling <fabien.freling(a)lrde.epita.fr>
diff --git a/milena/mln/upscaling/art/scale2x.hh b/milena/mln/upscaling/art/scale2x.hh
new file mode 100644
index 0000000..6805943
--- /dev/null
+++ b/milena/mln/upscaling/art/scale2x.hh
@@ -0,0 +1,151 @@
+// Copyright (C) 2009 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 MLN_UPSCALING_ART_SCALE2X_HH
+# define MLN_UPSCALING_ART_SCALE2X_HH
+
+/// \file
+///
+/// 2X upscaling algorithm for pixel art images.
+
+
+# include <mln/core/concept/box.hh>
+# include <mln/core/concept/image.hh>
+# include <mln/core/alias/neighb2d.hh>
+# include <mln/core/alias/dpoint2d.hh>
+
+# include <mln/extension/adjust_duplicate.hh>
+
+
+namespace mln
+{
+
+ namespace upscaling
+ {
+
+ namespace art
+ {
+
+ /*! \brief 2X upscaling algorithm for pixel art images.
+
+ \param[in] input An image.
+
+ \return An upscaled image.
+
+
+ Source:
+ http://en.wikipedia.org/wiki/Pixel_art_scaling_algorithms
+
+ */
+ template <typename I>
+ mln_concrete(I)
+ scale2x(const Image<I>& input);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename I>
+ mln_concrete(I)
+ scale2x(const Image<I>& input_)
+ {
+ trace::entering("mln::upscaling::art::scale2x");
+
+ const I& input = exact(input_);
+ mln_precondition(input.is_valid());
+ mlc_is_a(mln_domain(I), Box)::check();
+
+ extension::adjust_duplicate(input, 1);
+
+ mln_domain(I) ext_domain(input.domain().pmin() * 2,
+ input.domain().pmax() * 2
+ + mln::down_right);
+
+ mln_concrete(I) output(ext_domain);
+
+ mln_piter(I) p(input.domain());
+ for_all(p)
+ {
+
+ // A --\ 1 2
+ // C P B --/ 3 4
+ // D
+ mln_site(I)
+ pA = p + mln::up,
+ pB = p + mln::right,
+ pC = p + mln::left,
+ pD = p + mln::down,
+ pOut = p * 2;
+
+ // IF C==A AND C!=D AND A!=B => 1=A
+ if (input(pC) == input(pA)
+ && input(pC) != input(pD)
+ && input(pA) != input(pB))
+ output(pOut) = input(pA);
+ else
+ output(pOut) = input(p);
+
+ // IF A==B AND A!=C AND B!=D => 2=B
+ if (input(pA) == input(pB)
+ && input(pA) != input(pC)
+ && input(pB) != input(pD))
+ output(pOut + mln::right) = input(pB);
+ else
+ output(pOut + mln::right) = input(p);
+
+ // IF D==C AND D!=B AND C!=A => 3=C
+ if (input(pD) == input(pC)
+ && input(pD) != input(pB)
+ && input(pC) != input(pA))
+ output(pOut + mln::down) = input(pC);
+ else
+ output(pOut + mln::down) = input(p);
+
+ // IF B==D AND B!=A AND D!=C => 4=D
+ if (input(pB) == input(pD)
+ && input(pB) != input(pA)
+ && input(pD) != input(pC))
+ output(pOut + mln::down_right) = input(pD);
+ else
+ output(pOut + mln::down_right) = input(p);
+
+ }
+
+ trace::exiting("mln::upscaling::art::scale2x");
+ return output;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+
+ } // end of namespace mln::upscaling::art
+
+ } // end of namespace mln::upscaling
+
+} // end of namespace mln
+
+
+#endif // ! MLN_UPSCALING_ART_SCALE2X_HH
diff --git a/milena/mln/upscaling/art/scale3x.hh b/milena/mln/upscaling/art/scale3x.hh
new file mode 100644
index 0000000..042dd28
--- /dev/null
+++ b/milena/mln/upscaling/art/scale3x.hh
@@ -0,0 +1,218 @@
+// Copyright (C) 2009 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 MLN_UPSCALING_ART_SCALE3X_HH
+# define MLN_UPSCALING_ART_SCALE3X_HH
+
+/// \file
+///
+/// 3X upscaling algorithm for pixel art images.
+
+
+# include <mln/core/concept/box.hh>
+# include <mln/core/concept/image.hh>
+# include <mln/core/alias/neighb2d.hh>
+# include <mln/core/alias/dpoint2d.hh>
+
+# include <mln/extension/adjust_duplicate.hh>
+
+
+namespace mln
+{
+
+ namespace upscaling
+ {
+
+ namespace art
+ {
+
+ /*! \brief 3X upscaling algorithm for pixel art images.
+
+ \param[in] input An image.
+
+ \return An upscaled image.
+
+
+ Source:
+ http://en.wikipedia.org/wiki/Pixel_art_scaling_algorithms
+
+ */
+ template <typename I>
+ mln_concrete(I)
+ scale3x(const Image<I>& input);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename I>
+ mln_concrete(I)
+ scale3x(const Image<I>& input_)
+ {
+ trace::entering("mln::upscaling::art::scale3x");
+
+ const I& input = exact(input_);
+ mln_precondition(input.is_valid());
+ mlc_is_a(mln_domain(I), Box)::check();
+
+ extension::adjust_duplicate(input, 1);
+
+ mln_domain(I) ext_domain(input.domain().pmin() * 3,
+ input.domain().pmax() * 3
+ + 2 * mln::down_right);
+
+ mln_concrete(I) output(ext_domain);
+
+
+ mln_piter(I) p(input.domain());
+ for_all(p)
+ {
+
+ // A B C --\ 1 2 3
+ // D E F > 4 5 6
+ // G H I --/ 7 8 9
+ mln_site(I)
+ pA = p + mln::up_left,
+ pB = p + mln::up,
+ pC = p + mln::up_right,
+ pD = p + mln::left,
+ pE = p,
+ pF = p + mln::right,
+ pG = p + mln::down_left,
+ pH = p + mln::down,
+ pI = p + mln::down_right,
+ pOut = p * 3 + mln::down_right;
+
+ // IF D==B AND D!=H AND B!=F => 1=D
+ if (input(pD) == input(pB)
+ && input(pD) != input(pH)
+ && input(pB) != input(pF))
+ output(pOut + mln::up_left) = input(pD);
+ else
+ output(pOut + mln::up_left) = input(p);
+
+ // IF (D==B AND D!=H AND B!=F AND E!=C) OR (B==F AND B!=D
+ // AND F!=H AND E!=A) 2=B
+ if ((input(pD) == input(pB)
+ && input(pD) != input(pH)
+ && input(pB) != input(pF)
+ && input(pE) != input(pC))
+ || (input(pB) == input(pF)
+ && input(pB) != input(pD)
+ && input(pF) != input(pH)
+ && input(pE) != input(pA)))
+ output(pOut + mln::up) = input(pB);
+ else
+ output(pOut + mln::up) = input(p);
+
+ // IF B==F AND B!=D AND F!=H => 3=F
+ if (input(pB) == input(pF)
+ && input(pB) != input(pD)
+ && input(pF) != input(pH))
+ output(pOut + mln::up_right) = input(pF);
+ else
+ output(pOut + mln::up_right) = input(p);
+
+ // IF (H==D AND H!=F AND D!=B AND E!=A) OR (D==B AND D!=H
+ // AND B!=F AND E!=G) 4=D
+ if ((input(pH) == input(pD)
+ && input(pH) != input(pF)
+ && input(pD) != input(pB)
+ && input(pE) != input(pA))
+ || (input(pD) == input(pB)
+ && input(pD) != input(pH)
+ && input(pB) != input(pF)
+ && input(pE) != input(pG)))
+ output(pOut + mln::left) = input(pD);
+ else
+ output(pOut + mln::left) = input(p);
+
+ // 5=E
+ output(pOut) = input(p);
+
+ // IF (B==F AND B!=D AND F!=H AND E!=I) OR (F==H AND F!=B
+ // AND H!=D AND E!=C) 6=F
+ if ((input(pB) == input(pF)
+ && input(pB) != input(pD)
+ && input(pF) != input(pH)
+ && input(pE) != input(pI))
+ || (input(pF) == input(pH)
+ && input(pF) != input(pB)
+ && input(pH) != input(pD)
+ && input(pE) != input(pC)))
+ output(pOut + mln::right) = input(pF);
+ else
+ output(pOut + mln::right) = input(p);
+
+ // IF H==D AND H!=F AND D!=B => 7=D
+ if (input(pH) == input(pD)
+ && input(pH) != input(pF)
+ && input(pD) != input(pB))
+ output(pOut + mln::down_left) = input(pD);
+ else
+ output(pOut + mln::down_left) = input(p);
+
+
+ // IF (F==H AND F!=B AND H!=D AND E!=G) OR (H==D AND H!=F
+ // AND D!=B AND E!=I) 8=H
+ if ((input(pF) == input(pH)
+ && input(pF) != input(pB)
+ && input(pH) != input(pD)
+ && input(pE) != input(pG))
+ || (input(pH) == input(pD)
+ && input(pH) != input(pF)
+ && input(pD) != input(pB)
+ && input(pE) != input(pI)))
+ output(pOut + mln::down) = input(pH);
+ else
+ output(pOut + mln::down) = input(p);
+
+
+ // IF F==H AND F!=B AND H!=D => 9=F
+ if (input(pF) == input(pH)
+ && input(pF) != input(pB)
+ && input(pH) != input(pD))
+ output(pOut + mln::down_right) = input(pF);
+ else
+ output(pOut + mln::down_right) = input(p);
+
+ }
+
+ trace::exiting("mln::upscaling::art::scale3x");
+ return output;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+
+ } // end of namespace mln::upscaling::art
+
+ } // end of namespace mln::upscaling
+
+} // end of namespace mln
+
+
+#endif // ! MLN_UPSCALING_ART_SCALE3X_HH
diff --git a/milena/tests/Makefile.am b/milena/tests/Makefile.am
index 39987d0..562078e 100644
--- a/milena/tests/Makefile.am
+++ b/milena/tests/Makefile.am
@@ -59,6 +59,7 @@ SUBDIRS = \
trait \
transform \
unit_test \
+ upscaling \
util \
value \
win \
diff --git a/milena/tests/upscaling/Makefile.am b/milena/tests/upscaling/Makefile.am
new file mode 100644
index 0000000..dbe5a89
--- /dev/null
+++ b/milena/tests/upscaling/Makefile.am
@@ -0,0 +1,24 @@
+# Copyright (C) 2009 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/>.
+#
+
+## Process this file through Automake to create Makefile.in.
+
+include $(top_srcdir)/milena/tests/tests.mk
+
+SUBDIRS = \
+ art
+
diff --git a/milena/tests/upscaling/art/Makefile.am b/milena/tests/upscaling/art/Makefile.am
new file mode 100644
index 0000000..e001aaa
--- /dev/null
+++ b/milena/tests/upscaling/art/Makefile.am
@@ -0,0 +1,32 @@
+# Copyright (C) 2009 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/>.
+#
+
+## Process this file through Automake to create Makefile.in.
+
+include $(top_srcdir)/milena/tests/tests.mk
+
+
+check_PROGRAMS = \
+ scale2x \
+ scale3x
+
+
+scale2x_SOURCES = scale2x.cc
+scale3x_SOURCES = scale3x.cc
+
+
+TESTS = $(check_PROGRAMS)
diff --git a/milena/tests/upscaling/art/scale2x.cc b/milena/tests/upscaling/art/scale2x.cc
new file mode 100644
index 0000000..1db0298
--- /dev/null
+++ b/milena/tests/upscaling/art/scale2x.cc
@@ -0,0 +1,59 @@
+// Copyright (C) 2009 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.
+
+/// \file
+///
+/// \brief Test of the upscaling::art::scale2x routine.
+
+#include <mln/core/image/image2d.hh>
+#include <mln/data/compare.hh>
+
+#include <mln/upscaling/art/scale2x.hh>
+
+int main()
+{
+ using namespace mln;
+
+ bool rvals[4][8] = {
+ {0, 0, 0, 0, 0, 0, 1, 1},
+ {0, 0, 0, 0, 0, 0, 1, 1},
+ {1, 1, 1, 0, 0, 0, 1, 1},
+ {1, 1, 1, 1, 0, 0, 1, 1},
+ };
+
+
+ bool vals[2][4] = {
+ {0, 0, 0, 1},
+ {1, 1, 0, 1}
+ };
+
+ image2d<bool> ref = make::image(rvals);
+ image2d<bool> input = make::image(vals);
+
+
+ input = upscaling::art::scale2x(input);
+
+ mln_assertion(input == ref);
+}
diff --git a/milena/tests/upscaling/art/scale3x.cc b/milena/tests/upscaling/art/scale3x.cc
new file mode 100644
index 0000000..dbcde5c
--- /dev/null
+++ b/milena/tests/upscaling/art/scale3x.cc
@@ -0,0 +1,61 @@
+// Copyright (C) 2009 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.
+
+/// \file
+///
+/// \brief Test of the upscaling::art::scale3x routine.
+
+#include <mln/core/image/image2d.hh>
+#include <mln/data/compare.hh>
+
+#include <mln/upscaling/art/scale3x.hh>
+
+int main()
+{
+ using namespace mln;
+
+
+ bool rvals[6][12] = {
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1},
+ {1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1},
+ {1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1},
+ {1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1}
+ };
+
+
+ bool vals[2][4] = {
+ {0, 0, 0, 1},
+ {1, 1, 0, 1}
+ };
+
+ image2d<bool> ref = make::image(rvals);
+ image2d<bool> input = make::image(vals);
+
+ input = upscaling::art::scale3x(input);
+
+ mln_assertion(input == ref);
+}
--
1.5.6.5