Commit a64ee524 authored by Guillaume Lazzara's avatar Guillaume Lazzara
Browse files

Small fixes.

	* milena/doc/examples/tuto3/fill_non_generic.cc.raw: fix.

	* milena/tests/unit_test/build_unit_test.sh,
	* milena/generate_dist_headers.sh: use 'sort' to be sure of the output
	lines order.

	* milena/headers.mk,
	* milena/tests/unit_test/unit-tests.mk: regenerate with the previous
	modified scripts.

	* milena/mln/core/image/vertex_image.hh: fix a wrong type declaration.

	* milena/mln/core/internal/graph_psite_base.hh: Remove comparison
	operators.

	* milena/mln/core/site_set/p_array.hh: Enforce the comparison on the
	site type.

	* milena/mln/core/site_set/p_edges_psite.hh,
	* milena/mln/core/site_set/p_vertices_psite.hh: add operator ==, !=
	and <.

	* milena/mln/fun/v2v/hsi_to_rgb.hh: reindent.

	* milena/mln/fun/v2v/hsl_to_rgb.hh: add a missing forward declaration.

	* milena/mln/io/magick/load.hh: move fixme.

	* milena/mln/io/magick/save.hh: cleanup.

	* milena/mln/value/hsl.hh: add operator==.

	* milena/tests/io/magick/Makefile.am: add ldflags to magick test.

	* milena/tests/io/magick/magick.cc: write a new test.

git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@3794 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent bec6f7e0
2009-05-12 Guillaume Lazzara <lazzara@lrde.epita.fr>
Small fixes.
* milena/doc/examples/tuto3/fill_non_generic.cc.raw: fix.
* milena/tests/unit_test/build_unit_test.sh,
* milena/generate_dist_headers.sh: use 'sort' to be sure of the output
lines order.
* milena/headers.mk,
* milena/tests/unit_test/unit-tests.mk: regenerate with the previous
modified scripts.
* milena/mln/core/image/vertex_image.hh: fix a wrong type declaration.
* milena/mln/core/internal/graph_psite_base.hh: Remove comparison
operators.
* milena/mln/core/site_set/p_array.hh: Enforce the comparison on the
site type.
* milena/mln/core/site_set/p_edges_psite.hh,
* milena/mln/core/site_set/p_vertices_psite.hh: add operator ==, !=
and <.
* milena/mln/fun/v2v/hsi_to_rgb.hh: reindent.
* milena/mln/fun/v2v/hsl_to_rgb.hh: add a missing forward declaration.
* milena/mln/io/magick/load.hh: move fixme.
* milena/mln/io/magick/save.hh: cleanup.
* milena/mln/value/hsl.hh: add operator==.
* milena/tests/io/magick/Makefile.am: add ldflags to magick test.
* milena/tests/io/magick/magick.cc: write a new test.
2009-05-15 Thierry Geraud <thierry.geraud@lrde.epita.fr>
 
Bug fixes.
// Java or C -like code
void fill(image ima, unsigned char v)
void fill(image *ima, unsigned char v)
{
for (int i = 0; i < ima->nrows; ++i)
for (int j = 0; j < ima->ncols; ++j)
......
......@@ -10,8 +10,8 @@ echo "nobase_include_HEADERS = \\" >> headers.mk
echo "mln/version.hh \\" >> headers.mk
echo "generating headers.mk"
find mln -type f -name '*.hh'| grep -v "\.svn" | sed -e 's/$/ \\/g' >> headers.mk
find mln -type f -name '*.hxx'| grep -v "\.svn" | sed -e 's/$/ \\/g' >> headers.mk
find mln -type f -name '*.hh'| grep -v "\.svn" | sed -e 's/$/ \\/g' | sort >> headers.mk
find mln -type f -name '*.hxx'| grep -v "\.svn" | sed -e 's/$/ \\/g'| sort >> headers.mk
last_line=`tail -n 1 headers.mk | sed -e 's/\\\//g'` # remove '\' in last line
sed '$d' < headers.mk > headers.mk.tmp # remove last line
......
This diff is collapsed.
......@@ -188,7 +188,7 @@ namespace mln
{
fun::i2v::array<V> f;
init_(tag::function, f, exact(model));
p_vertices<G,typename edge_image<P,V,G>::site_function_t> s;
p_vertices<G,typename vertex_image<P,V,G>::site_function_t> s;
init_(tag::domain, s, exact(model));
target.init_(f, s);
}
......
// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
// Copyright (C) 2008, 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
......@@ -343,34 +344,6 @@ namespace mln
return elt_;
}
/*--------------.
| Comparisons. |
`--------------*/
template <typename S, typename E>
bool
operator==(const graph_psite_base<S,E>& lhs, const graph_psite_base<S,E>& rhs)
{
mln_assertion(lhs.target_() == rhs.target_());
return lhs.id() == rhs.id();
}
template <typename S, typename E>
bool
operator!=(const graph_psite_base<S,E>& lhs, const graph_psite_base<S,E>& rhs)
{
mln_assertion(lhs.target_() == rhs.target_());
return lhs.id() != rhs.id();
}
template <typename S, typename E>
bool
operator< (const graph_psite_base<S,E>& lhs, const graph_psite_base<S,E>& rhs)
{
mln_assertion(lhs.target_() == rhs.target_());
return lhs.id() < rhs.id();
}
template <typename S, typename P, typename E>
inline
......
......@@ -208,6 +208,7 @@ namespace mln
bool is_valid() const;
operator mln_element(S)() const; // Does it cause ambiguities with "operator int" ?
operator util::index() const;
operator int() const; // To interoperate, e.g., with fun::i2v expecting an int.
operator unsigned() const; // To avoid ambiguity when an unsigned is expected.
......@@ -359,7 +360,7 @@ namespace mln
if (! has(p.index()))
return false;
// The type of rhs below is mln_site(p_array<P>).
mln_invariant(p.to_site() == (*this)[p.index()]);
mln_invariant(static_cast<P>(p) == static_cast<P>((*this)[p.index()]));
return true;
}
......@@ -584,6 +585,13 @@ namespace mln
p_ = (*s_)[i_];
}
template <typename S>
inline
p_indexed_psite<S>::operator mln_element(S)() const
{
return p_;
}
template <typename S>
inline
p_indexed_psite<S>::operator util::index() const
......
// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
// Copyright (C) 2008, 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
......@@ -71,6 +72,21 @@ namespace mln
};
template <typename G, typename F>
bool
operator==(const p_edges_psite<G,F>& lhs, const p_edges_psite<G,F>& rhs);
template <typename G, typename F>
bool
operator!=(const p_edges_psite<G,F>& lhs, const p_edges_psite<G,F>& rhs);
template <typename G, typename F>
bool
operator<(const p_edges_psite<G,F>& lhs, const p_edges_psite<G,F>& rhs);
namespace internal
{
......@@ -99,6 +115,9 @@ namespace mln
} // end of namespace mln::internal
# ifndef MLN_INCLUDE_ONLY
template <typename G, typename F>
......@@ -146,6 +165,36 @@ namespace mln
}
/*--------------.
| Comparisons. |
`--------------*/
template <typename G, typename F>
bool
operator==(const p_edges_psite<G,F>& lhs, const p_edges_psite<G,F>& rhs)
{
mln_assertion(lhs.target_() == rhs.target_());
return lhs.id() == rhs.id();
}
template <typename G, typename F>
bool
operator!=(const p_edges_psite<G,F>& lhs, const p_edges_psite<G,F>& rhs)
{
mln_assertion(lhs.target_() == rhs.target_());
return lhs.id() != rhs.id();
}
template <typename G, typename F>
bool
operator<(const p_edges_psite<G,F>& lhs, const p_edges_psite<G,F>& rhs)
{
mln_assertion(lhs.target_() == rhs.target_());
return lhs.id() < rhs.id();
}
namespace internal
{
......
// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
// Copyright (C) 2008, 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
......@@ -62,6 +63,19 @@ namespace mln
};
template <typename G, typename F>
bool
operator==(const p_vertices_psite<G,F>& lhs, const p_vertices_psite<G,F>& rhs);
template <typename G, typename F>
bool
operator!=(const p_vertices_psite<G,F>& lhs, const p_vertices_psite<G,F>& rhs);
template <typename G, typename F>
bool
operator<(const p_vertices_psite<G,F>& lhs, const p_vertices_psite<G,F>& rhs);
namespace internal
{
......@@ -88,6 +102,8 @@ namespace mln
} // end of namespace mln::internal
# ifndef MLN_INCLUDE_ONLY
template <typename G, typename F>
......@@ -118,6 +134,36 @@ namespace mln
return this->elt_;
}
/*--------------.
| Comparisons. |
`--------------*/
template <typename G, typename F>
bool
operator==(const p_vertices_psite<G,F>& lhs, const p_vertices_psite<G,F>& rhs)
{
mln_assertion(lhs.target_() == rhs.target_());
return lhs.id() == rhs.id();
}
template <typename G, typename F>
bool
operator!=(const p_vertices_psite<G,F>& lhs, const p_vertices_psite<G,F>& rhs)
{
mln_assertion(lhs.target_() == rhs.target_());
return lhs.id() != rhs.id();
}
template <typename G, typename F>
bool
operator<(const p_vertices_psite<G,F>& lhs, const p_vertices_psite<G,F>& rhs)
{
mln_assertion(lhs.target_() == rhs.target_());
return lhs.id() < rhs.id();
}
namespace internal
{
......
......@@ -92,14 +92,14 @@ namespace mln
static math::round<blue_t> to_b;
static const float
sqrt3_3 = std::sqrt(3) / 3,
inv_sqrt6 = 1 / std::sqrt(6),
inv_sqrt2 = 1 / std::sqrt(2);
sqrt3_3 = std::sqrt(3) / 3,
inv_sqrt6 = 1 / std::sqrt(6),
inv_sqrt2 = 1 / std::sqrt(2);
float
h = hsi.hue() / 180.0 * 3.1415,
alpha = hsi.sat() * std::cos(h),
beta = hsi.sat() * std::sin(h);
h = hsi.hue() / 180.0 * 3.1415,
alpha = hsi.sat() * std::cos(h),
beta = hsi.sat() * std::sin(h);
red_t r = to_r(sqrt3_3 * hsi.inty() + 2 * inv_sqrt6 * beta);
......
......@@ -54,6 +54,7 @@ namespace mln
{
template <typename H, typename S, typename L> class hsl_;
typedef hsl_<float, float, float> hsl_f;
template <unsigned n> struct rgb;
}
namespace fun
......
// Copyright (C) 2009 EPITA Research and Development Laboratory
// 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
......@@ -28,7 +28,6 @@
#ifndef MLN_IO_MAGICK_LOAD_HH
# define MLN_IO_MAGICK_LOAD_HH
///
/// \file mln/io/magick/load.hh
///
/// Define a function which loads an image of kind magick with
......@@ -147,7 +146,8 @@ namespace mln
{
const Magick::PixelPacket *pixel = pixel_cache + (int) p.to_site().to_vec()[0] * columns
+ (int) p.to_site().to_vec()[1];
value::rgb8 pix(pixel->red % 256, pixel->green % 256, pixel->blue % 256); // FIXME: Quantum = 16bits but rgb is 8bits
// FIXME: Quantum = 16bits but rgb is 8bits
value::rgb8 pix(pixel->red % 256, pixel->green % 256, pixel->blue % 256);
mln_value(I) res;
if (!do_it(pix, res, filename))
abort();
......
// Copyright (C) 2009 EPITA Research and Development Laboratory
// 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
......@@ -28,11 +28,12 @@
#ifndef MLN_IO_MAGICK_SAVE_HH
# define MLN_IO_MAGICK_SAVE_HH
///
/// \file mln/io/magick/save.hh
///
/// Define a function which saves an image of kind magick with
/// given path.
///
/// FIXME: there seems to be roundness errors while computing rgb values.
# include <mln/core/image/image2d.hh>
# include <mln/metal/equal.hh>
......@@ -56,7 +57,7 @@ namespace mln
* \param[in] filename The output.
*/
template <typename I>
void save(Image<I>& ima,
void save(const Image<I>& ima,
const std::string& filename);
......@@ -65,38 +66,32 @@ namespace mln
inline
Magick::Color get_color(bool value)
{
if (value)
return Magick::Color("white");
else
return Magick::Color("black");
std::cout << "bool color!" << std::endl;
return Magick::ColorMono(value);
}
inline
Magick::Color get_color(value::int_u8 value)
Magick::Color get_color(const value::int_u8& value)
{
return Magick::Color((unsigned) value * MaxRGB / 256,
(unsigned) value * MaxRGB / 256,
(unsigned) value * MaxRGB / 256,
0);
return Magick::ColorGray(value / (double)256.0f);
}
inline
Magick::Color get_color(value::rgb8 value)
Magick::Color get_color(const value::rgb8& value)
{
return Magick::Color((unsigned) value.red() * MaxRGB / 256,
(unsigned) value.green() * MaxRGB / 256,
(unsigned) value.blue() * MaxRGB / 256,
0);
return Magick::ColorRGB(value.red() / (double)256.0f,
value.green() / (double)256.0f,
value.blue() / (double)256.0f);
}
template <typename I>
inline
void save(Image<I>& ima_, const std::string& filename)
void save(const Image<I>& ima_, const std::string& filename)
{
trace::entering("mln::io::magick::save");
mln_precondition(mln_site_(I)::dim == 2);
I& ima = exact(ima_);
const I& ima = exact(ima_);
if (!(mln::metal::equal<mln_value(I), bool>::value ||
mln::metal::equal<mln_value(I), value::int_u8>::value ||
mln::metal::equal<mln_value(I), value::rgb8>::value))
......@@ -106,15 +101,15 @@ namespace mln
abort();
}
Magick::Image im_file(Magick::Geometry(ima.nrows(), ima.ncols()),
Magick::Color(0, 0, 0, 0));
Magick::Image im_file;
im_file.size(Magick::Geometry(ima.nrows(), ima.ncols()));
Magick::PixelPacket* pixel_cache = im_file.getPixels(0, 0, ima.nrows(), ima.ncols());
Magick::PixelPacket* pixel;
mln_piter(I) p(ima.domain());
unsigned columns = ima.ncols();
for_all(p)
{
pixel = pixel_cache + (int) p.to_site().to_vec()[0] * columns
pixel = pixel_cache + (int) p.to_site().to_vec()[0] * ima.ncols()
+ (int) p.to_site().to_vec()[1];
*pixel = get_color(ima(p));
}
......
......@@ -247,6 +247,13 @@ namespace mln
operator/(const hsl_<H,S,L>& lhs, const mln::value::scalar_<S2>& s);
/// \}
/// Comparison.
/// \{
template <typename H, typename S, typename L>
bool
operator==(const hsl_<H,S,L>& lhs, const hsl_<H,S,L>& rhs);
/// \}
} // end of namespace mln::value
......@@ -367,6 +374,15 @@ namespace mln
lhs.lum() / s);
}
template <typename H, typename S, typename L>
bool
operator==(const hsl_<H,S,L>& lhs, const hsl_<H,S,L>& rhs)
{
return lhs.hue() == rhs.hue()
&& lhs.sat() == rhs.sat()
&& lhs.lum() == rhs.lum();
}
} // end of namespace mln::value
......
......@@ -2,6 +2,8 @@
include $(top_srcdir)/milena/tests/tests.mk
magick_LDFLAGS = -lMagick++
check_PROGRAMS = \
load
......
......@@ -13,7 +13,7 @@ test $# -eq 1 || { echo "Usage: $0 <mln path>" && exit 1; }
## FIXME: Ouch! Using `find' properly can probably save us some pipes,
## forks and characters here.
HEADERS=`find $1 -name "*.hh" | grep -vE "*.spe.hh" | grep -v "mln/core/concept/doc" | sed -e 's/.*\/mln\/\(.*\)/mln\/\1/g' | sed 's/\.\.\/\.\.\///g'`
HEADERS=`find $1 -name "*.hh" | grep -vE "*.spe.hh" | grep -v "mln/core/concept/doc" | sort | sed -e 's/.*\/mln\/\(.*\)/mln\/\1/g' | sed 's/\.\.\/\.\.\///g'`
output=unit-tests.mk
......
This diff is collapsed.
// -*- C++ -*-
// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
// 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
......@@ -22,35 +21,40 @@
// 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.
// License. This exception does not however invalidate any other
// reasons why the executable file might be covered by the GNU General
// Public License.
/// \file window2d.i
/// \brief A wrapper of mln::window2d.
/// \file tests/io/magick/magick.cc
///
/// Test on mln::io::magick::*.
%module window2d
#include <mln/core/image/image2d.hh>
#include <mln/io/magick/load.hh>
#include <mln/io/ppm/save.hh>
%import "dpoint2d.i"
#include <mln/level/compare.hh>
%{
#include "mln/core/window2d.hh"
%}
#include <mln/value/int_u8.hh>
#include <mln/value/rgb8.hh>
%include "mln/core/macros.hh"
#include "tests/data.hh"
%include "mln/core/concept/window.hh"
%include "mln/core/window.hh"
#include <mln/debug/println.hh>
%include "mln/core/window2d.hh"
int main()
{
using namespace mln;
// Swig tries to wrap everything by default; prevent it from wrapping
// invalid methods (1D and 3D insertions for a window2d).
%ignore mln::window< mln::dpoint_<mln::grid::square, int > >::
insert(const typename mln::dpoint_<mln::grid::square, int>::coord&);
%ignore mln::window< mln::dpoint_<mln::grid::square, int > >::
insert(const typename mln::dpoint_<mln::grid::square, int>::coord&,
const typename mln::dpoint_<mln::grid::square, int>::coord&,
const typename mln::dpoint_<mln::grid::square, int>::coord&);
{
image2d<value::rgb8> lena_im;
io::magick::load(lena_im, "lena.png");
image2d<value::rgb8> lena_mln;
io::ppm::load(lena_mln, "lena.ppm");
mln_assertion(lena_im.domain() == lena_mln.domain());
mln_assertion(lena_im == lena_mln);
}
}
%template(window2d) mln::window< mln::dpoint_<mln::grid::square, int > >;
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