ChangeLog | 12 ++++++++++++
oln/convert/conversion.hh | 21 +++++++++++++++++++++
oln/core/pw/image.hh | 2 +-
tests/convert/tests/force | 2 +-
tests/convert/tests/stretch | 31 +++++++++++++++++++++++++++++++
tests/convert/tests/stretch-balance | 27 +++++++++++++++++++++++++++
6 files changed, 93 insertions(+), 2 deletions(-)
Index: olena/ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Add tests on stretch conversions.
* oln/convert/conversion.hh (apply): New.
* tests/convert/tests/stretch,
* tests/convert/tests/stretch-balance: New tests.
* oln/core/pw/image.hh
(set_props <category::image, image_from_pwf<F> >::ch_value_type):
Fix definition.
2005-07-04 Roland Levillain <roland(a)lrde.epita.fr>
Index: olena/tests/convert/tests/stretch-balance
--- olena/tests/convert/tests/stretch-balance (révision 0)
+++ olena/tests/convert/tests/stretch-balance (révision 0)
@@ -0,0 +1,27 @@
+ // -*- C++ -*-
+#include "data.hh"
+#include <oln/utils/md5.hh>
+
+#include <ntg/int.hh>
+#include <oln/io/read_image.hh>
+#include <oln/convert/stretch.hh>
+
+using namespace oln;
+
+bool check()
+{
+ utils::key::value_type data_key[16] =
+ {0x17, 0x33, 0x35, 0x20, 0x34, 0xf, 0x21, 0x14,
+ 0xb1, 0x8f, 0xe5, 0x78, 0xee, 0x7d, 0xb5, 0x83};
+ utils::key key(data_key);
+
+ image2d<ntg::int_u8> input;
+ input = io::read(rdata("16x16.pgm"));
+ image2d<ntg::int_u8> output =
+ convert::stretch_balance<ntg::int_u8>(input);
+
+ if (utils::md5(output) != key)
+ return true;
+
+ return false;
+}
Index: olena/tests/convert/tests/stretch
--- olena/tests/convert/tests/stretch (révision 0)
+++ olena/tests/convert/tests/stretch (révision 0)
@@ -0,0 +1,31 @@
+ // -*- C++ -*-
+#include "data.hh"
+#include <oln/utils/md5.hh>
+
+#include <ntg/int.hh>
+#include <oln/io/read_image.hh>
+#include <oln/convert/conversion.hh>
+#include <oln/convert/stretch.hh>
+
+using namespace oln;
+
+bool check()
+{
+ utils::key::value_type data_key[16] =
+ {0x3d, 0xc9, 0x0, 0x7c, 0x2b, 0x92, 0x38, 0x43,
+ 0x68, 0xd7, 0x6a, 0x3c, 0xa8, 0xd7, 0x90, 0x60};
+ utils::key key(data_key);
+
+ typedef ntg::int_u8 input_value_type;
+ typedef ntg::int_u<2> output_value_type;
+
+ image2d<input_value_type> input;
+ input = io::read(rdata("16x16.pgm"));
+ convert::stretch<output_value_type> f_stretch;
+ image2d<output_value_type> output = convert::apply(f_stretch, input);
+
+ if (utils::md5(output) != key)
+ return true;
+
+ return false;
+}
Index: olena/tests/convert/tests/force
--- olena/tests/convert/tests/force (révision 231)
+++ olena/tests/convert/tests/force (copie de travail)
@@ -10,7 +10,7 @@
{
typedef ntg::int_u8 value_type;
f_::plus_<value_type, value_type> f_plus;
- oln::convert::force<value_type> f_force;
+ convert::force<value_type> f_force;
value_type a = 1;
value_type b = 2;
Index: olena/oln/convert/conversion.hh
--- olena/oln/convert/conversion.hh (révision 231)
+++ olena/oln/convert/conversion.hh (copie de travail)
@@ -34,6 +34,9 @@
# include <oln/funobj/abstract/binary.hh>
# include <oln/convert/abstract/conversion.hh>
+# include <oln/funobj/compose.hh>
+# include <oln/core/apply.hh>
+
namespace oln {
/*!
** \brief Conversion implementation (for example cast, color, or
@@ -163,6 +166,24 @@
return internal::compconv2_<C, BF>(conv.exact(), func);
}
+
+ // FIXME: Should't abstract::conversion be an Olena (or Metalic)
+ // functor, and use the standard apply() instead?
+
+ /// Apply procedure of an abstract conversion on an image.
+ template<class C, class B, class I>
+ typename ch_value_type<I, typename convoutput<C, B, oln_type_of(I,
value)>::ret>::ret
+ apply(const abstract::conversion<C, B>& conv,
+ const oln::abstract::image<I>& input)
+ {
+ /* CONV can now be wrapped as an Adaptable Unary Function
+ because we know the input type. Composing CONV with the
+ identity for the input type will cause such wrapping to
+ happen. */
+ return apply(compconv1(conv, f_::identity_<oln_type_of(I, value)>()),
+ input);
+ }
+
} // end of namespace oln::convert
// Export conversion and convouput into oln:: to simplify the
Index: olena/oln/core/pw/image.hh
--- olena/oln/core/pw/image.hh (révision 231)
+++ olena/oln/core/pw/image.hh (copie de travail)
@@ -74,7 +74,7 @@
template <typename U>
struct ch_value_type
{
- typedef concrete_type<U> ret;
+ typedef image2d<U> ret;
};
};