Commit 98cab347 authored by Guillaume Lazzara's avatar Guillaume Lazzara
Browse files

Reduce precision issues in transformations.

	* milena/mln/core/image/imorph/interpolated.hh: Make the vector
	type more generic.

	* milena/mln/core/point.hh: Provide specific conversion operators
	for float and double.

	* milena/mln/fun/internal/x2x_linear_impl.hh: Allow to set the
	matrix value type.

	* milena/mln/fun/x2x/composed.hh,
	* milena/mln/fun/x2x/rotation.hh,
	* milena/mln/fun/x2x/translation.hh: Introduce data_t typedef
	passed to x2x_linear_impl.
parent 482527bb
2010-05-25 Guillaume Lazzara <z@lrde.epita.fr>
Reduce precision issues in transformations.
* milena/mln/core/image/imorph/interpolated.hh: Make the vector
type more generic.
* milena/mln/core/point.hh: Provide specific conversion operators
for float and double.
* milena/mln/fun/internal/x2x_linear_impl.hh: Allow to set the
matrix value type.
* milena/mln/fun/x2x/composed.hh,
* milena/mln/fun/x2x/rotation.hh,
* milena/mln/fun/x2x/translation.hh: Introduce data_t typedef
passed to x2x_linear_impl.
2010-04-30 Guillaume Lazzara <z@lrde.epita.fr>
Add some code in my sandbox.
* sandbox/lazzara/scribo/binarization_naive/main.cc,
* sandbox/lazzara/scribo/binarization_naive/toto.cc,
* sandbox/lazzara/scribo/fill_holes/main.cc,
* sandbox/lazzara/scribo/separateurs_materialises/lines_pattern.cc,
* sandbox/lazzara/scribo/skeleton_crest/main.cc,
* sandbox/lazzara/skeleton_crest/main.cc: New.
2010-05-21 edwin carlinet <carlinet@lrde.epita.fr>
 
Add MLN_WO_GLOBAL_VARS directive that prevents globals vars to be
......@@ -41,16 +70,16 @@
 
Small fixes in Milena.
 
* milena/mln/canvas/labeling/blobs.hh: Fill extension.
* mln/canvas/labeling/blobs.hh: Fill extension.
 
* milena/mln/data/paste_without_localization.hh: Check whether the
* mln/data/paste_without_localization.hh: Check whether the
two images have the same domain.
 
* milena/mln/labeling/blobs_and_compute.hh: Rename members.
* mln/labeling/blobs_and_compute.hh: Rename members.
 
* milena/mln/labeling/colorize.hh: Add missing includes.
* mln/labeling/colorize.hh: Add missing includes.
 
* milena/mln/world/binary_2d/enlarge.hh: use def::coord.
* mln/world/binary_2d/enlarge.hh: use def::coord.
 
2010-04-13 Guillaume Lazzara <z@lrde.epita.fr>
 
......@@ -172,25 +201,25 @@
 
Small fixes in Milena.
 
* milena/mln/accu/center.hh: Add nsites() member.
* mln/accu/center.hh: Add nsites() member.
 
* milena/mln/accu/pair.hh: Provide access to the underlying accus.
* mln/accu/pair.hh: Provide access to the underlying accus.
 
* milena/mln/accu/stat/variance.hh: Use literal::zero.
* mln/accu/stat/variance.hh: Use literal::zero.
 
* milena/mln/core/internal/labeled_image_base.hh: Indent.
* mln/core/internal/labeled_image_base.hh: Indent.
 
* milena/mln/core/site_set/box.hh: Rename center() as pcenter().
* mln/core/site_set/box.hh: Rename center() as pcenter().
 
* milena/mln/labeling/blobs_and_compute.hh: Return the array of
* mln/labeling/blobs_and_compute.hh: Return the array of
accumulators.
 
* milena/mln/labeling/colorize.hh: Make sure a color is not used
* mln/labeling/colorize.hh: Make sure a color is not used
twice in the same image.
 
* milena/mln/labeling/compute.hh: Add a new overload.
* mln/labeling/compute.hh: Add a new overload.
 
* milena/mln/transform/influence_zone_geodesic.hh: Fix a
* mln/transform/influence_zone_geodesic.hh: Fix a
segmentation fault when an image had a border.
 
2009-12-14 Guillaume Lazzara <z@lrde.epita.fr>
......@@ -366,10 +395,10 @@
 
First draft of raw format support.
 
* milena/mln/io/raw/all.hh,
* milena/mln/io/raw/get_header.hh,
* milena/mln/io/raw/load.hh,
* milena/mln/io/raw/save.hh: New.
* mln/io/raw/all.hh,
* mln/io/raw/get_header.hh,
* mln/io/raw/load.hh,
* mln/io/raw/save.hh: New.
 
2010-02-16 Guillaume Lazzara <z@lrde.epita.fr>
 
......@@ -501,15 +530,15 @@
 
Small fixes.
 
* milena/mln/data/paste.spe.hh,
* milena/mln/data/stretch.hh,
* milena/mln/fun/x2v/bilinear.hh,
* milena/mln/morpho/erosion.hh,
* milena/mln/value/mixin.hh: Fix layout.
* mln/data/paste.spe.hh,
* mln/data/stretch.hh,
* mln/fun/x2v/bilinear.hh,
* mln/morpho/erosion.hh,
* mln/value/mixin.hh: Fix layout.
 
* milena/mln/debug/filename.hh: Update doc.
* mln/debug/filename.hh: Update doc.
 
* milena/mln/subsampling/subsampling.hh: Fix invalid min rows and
* mln/subsampling/subsampling.hh: Fix invalid min rows and
cols.
 
2009-10-16 Edwin Carlinet <carlinet@lrde.epita.fr>
......@@ -1649,8 +1678,8 @@
 
* mln/labeling/blobs_and_compute.hh: New routine.
 
* milena/tests/labeling/Makefile.am,
* milena/tests/labeling/blobs_and_compute.cc: New test.
* tests/labeling/Makefile.am,
* tests/labeling/blobs_and_compute.cc: New test.
 
2009-08-21 Guillaume Lazzara <lazzara@lrde.epita.fr>
 
......@@ -1855,7 +1884,7 @@
 
Have transform_line fastest.
 
* milena/mln/accu/transform_line.hh: Add documentation.
* mln/accu/transform_line.hh: Add documentation.
(todo): Remove, done:
The specialization for fastest images is now up.
(todo): New. A version that ignores extensions should
......@@ -1868,29 +1897,29 @@
(transform_line_dispatch): Revamp to take into account
accumulator properties.
(transform_line): Call properly the dispatch mechanism.
* milena/tests/accu/transform_line.cc: Test both generic and
* tests/accu/transform_line.cc: Test both generic and
fastest versions.
 
Fix missing properties for some accumulators.
 
* milena/mln/accu/stat/min.hh,
* milena/mln/accu/stat/max.hh (set_value): New method.
* milena/mln/accu/stat/max_h.hh (invariant_): New method.
* mln/accu/stat/min.hh,
* mln/accu/stat/max.hh (set_value): New method.
* mln/accu/stat/max_h.hh (invariant_): New method.
(max_h): Add calls to invariant_.
(debug_print_): Augment.
* milena/mln/accu/math/count.hh,
* milena/mln/accu/logic/lor.hh,
* milena/mln/accu/logic/lor_basic.hh,
* milena/mln/accu/logic/land.hh,
* milena/mln/accu/logic/land_basic.hh,
* milena/mln/accu/stat/min.hh,
* milena/mln/accu/stat/max.hh,
* milena/mln/accu/stat/min_h.hh,
* milena/mln/accu/stat/max_h.hh (trait): Add missing traits.
* mln/accu/math/count.hh,
* mln/accu/logic/lor.hh,
* mln/accu/logic/lor_basic.hh,
* mln/accu/logic/land.hh,
* mln/accu/logic/land_basic.hh,
* mln/accu/stat/min.hh,
* mln/accu/stat/max.hh,
* mln/accu/stat/min_h.hh,
* mln/accu/stat/max_h.hh (trait): Add missing traits.
 
Misc.
 
* milena/mln/morpho/general.spe.hh: Fix layout.
* mln/morpho/general.spe.hh: Fix layout.
Remove useless includes.
 
2009-08-13 Vivien Delmon <vivien.delmon@lrde.epita.fr>
......@@ -2320,8 +2349,8 @@
 
Regen headers.mk and unit-tests.mk.
 
* milena/headers.mk,
* milena/tests/unit_test/unit-tests.mk: regen.
* headers.mk,
* tests/unit_test/unit-tests.mk: regen.
 
2009-06-30 Guillaume Lazzara <guillaume.lazzara@lrde.epita.fr>
 
......@@ -3873,7 +3902,7 @@
Complete the installation of the Make rule `tests' in Milena.
 
* Makefile.am (tests): New phony target.
* tests/world/Makefile.am: Include milena/tests/tests.mk.
* tests/world/Makefile.am: Include tests/tests.mk.
 
2009-06-10 Roland Levillain <roland@lrde.epita.fr>
 
// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
//
......@@ -83,7 +84,7 @@ namespace mln
struct interpolated :
public mln::internal::image_identity< I, mln_domain(I), interpolated<I,F> >
{
typedef mln::internal::image_identity< I, mln_domain(I),
interpolated<I,F> > super_;
......@@ -119,7 +120,8 @@ namespace mln
using super_::has;
/// Test if a pixel value is accessible at \p v.
bool has(const mln::algebra::vec<I::psite::dim, float>& v) const;
template <typename C>
bool has(const mln::algebra::vec<I::psite::dim, C>& v) const;
/// Read-only access of pixel value at point site \p p.
/// Mutable access is only OK for reading (not writing).
......@@ -182,8 +184,9 @@ namespace mln
}
template <typename I, template <class> class F>
template <typename C>
inline
bool interpolated<I,F>::has(const mln::algebra::vec<I::psite::dim, float>& v) const
bool interpolated<I,F>::has(const mln::algebra::vec<I::psite::dim, C>& v) const
{
mln_psite(I) p;
for (unsigned i = 0; i < I::psite::dim; ++i)
......@@ -191,6 +194,7 @@ namespace mln
return this->data_->ima_.has(p);
}
template <typename I, template <class> class F>
inline
mln_value(I)
......@@ -207,6 +211,7 @@ namespace mln
return fun_(v);
}
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
......
// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
// Copyright (C) 2007, 2008, 2009, 2010 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
//
......@@ -35,6 +36,7 @@
/// second there is a room for the couple of methods (in the
/// subject_impl specializations defined in core/alias/point*d.hh).
# include <cmath>
# include <mln/core/def/coord.hh>
# include <mln/core/concept/proxy.hh>
# include <mln/core/concept/gpoint.hh>
......@@ -150,6 +152,11 @@ namespace mln
template <typename C2>
point(const algebra::vec<dim,C2>& v);
point(const algebra::vec<dim,C>& v);
point(const algebra::vec<dim,double>& v);
point(const algebra::vec<dim,float>& v);
/// \{ Constructors with different numbers of arguments
/// (coordinates) w.r.t. the dimension.
explicit point(C ind);
......@@ -322,6 +329,48 @@ namespace mln
}
}
template <typename G, typename C>
inline
point<G,C>::point(const algebra::vec<dim,C>& v)
{
unsigned j = 0;
//FIXME: to be improved while adding a conversion routine.
if (dim < 3)
coord_ = v;
else
{
for (unsigned i = dim - 2; i < dim; ++i)
coord_[i] = v[j++];
for (unsigned i = 2; i < dim; ++i, ++j)
coord_[i-j] = v[j];
}
}
template <typename G, typename C>
inline
point<G,C>::point(const algebra::vec<dim,double>& v)
{
unsigned j = 0;
for (unsigned i = dim - 2; i < dim; ++i)
coord_[i] = round(v[j++]);
for (unsigned i = 2; i < dim; ++i, ++j)
coord_[i-j] = round(v[j]);
}
template <typename G, typename C>
inline
point<G,C>::point(const algebra::vec<dim,float>& v)
{
unsigned j = 0;
for (unsigned i = dim - 2; i < dim; ++i)
coord_[i] = round(v[j++]);
for (unsigned i = 2; i < dim; ++i, ++j)
coord_[i-j] = round(v[j]);
}
template <typename G, typename C>
inline
point<G,C>::point(C ind)
......
// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
//
......@@ -44,19 +45,18 @@ namespace mln
namespace internal
{
template <typename V, typename E>
template <typename V, typename C, typename E>
struct x2x_linear_impl_
{
static const unsigned dim = V::dim; // To please g++ when comparing dim in metal bexpr.
typedef V argument;
typedef V result;
typedef typename V::coord coord;
typedef algebra::h_mat<dim, coord> matrix;
typedef algebra::h_mat<dim, C> matrix;
V operator()(const V& x) const
{
algebra::h_vec<dim, coord> tmp = m_ * x.to_h_vec();
algebra::h_vec<dim, C> tmp = m_ * x.to_h_vec();
return tmp.to_vec();
}
......@@ -72,17 +72,17 @@ namespace mln
# ifndef MLN_INCLUDE_ONLY
template <typename V, typename E>
template <typename V, typename C, typename E>
inline
x2x_linear_impl_<V,E>::x2x_linear_impl_()
x2x_linear_impl_<V,C,E>::x2x_linear_impl_()
{
}
template <typename V, typename E>
template <typename V, typename C, typename E>
inline
const typename x2x_linear_impl_<V,E>::matrix&
x2x_linear_impl_<V,E>::mat() const
const typename x2x_linear_impl_<V,C,E>::matrix&
x2x_linear_impl_<V,C,E>::mat() const
{
return m_;
}
......
// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
// Copyright (C) 2007, 2008, 2009, 2010 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
//
......@@ -60,10 +61,13 @@ namespace mln
/// Helper for describing a bijective composition.
template <typename T2, typename T1, typename E>
struct helper_composed_<T2,T1,E,true>
: public fun::internal::x2x_linear_impl_<mln_result(T2), E >,
: public fun::internal::x2x_linear_impl_<mln_result(T2), typename T2::data_t, E >,
public Function_v2v<E>
{
typedef fun::internal::x2x_linear_impl_<typename T2::result, E > super_;
typedef fun::internal::x2x_linear_impl_<typename T2::result, typename T2::data_t, E > super_;
/// Type of the underlying data stored in vectors and matrices.
typedef typename T2::data_t data_t;
using super_::dim;
......@@ -98,10 +102,14 @@ namespace mln
/// Helper for describing a non bijective composition.
template <typename T2, typename T1, typename E>
struct helper_composed_<T2,T1,E,false>
: public fun::internal::x2x_linear_impl_<mln_result(T2), E >,
: public fun::internal::x2x_linear_impl_<mln_result(T2), typename T2::data_t, E >,
public Function_v2v<E>
{
typedef fun::internal::x2x_linear_impl_<typename T2::result, E > super_;
typedef fun::internal::x2x_linear_impl_<typename T2::result, typename T2::data_t, E > super_;
/// Type of the underlying data stored in vectors and matrices.
typedef typename T2::data_t data_t;
using super_::dim;
......
......@@ -136,10 +136,13 @@ namespace mln
template <unsigned n, typename C>
struct rotation
:
fun::internal::x2x_linear_impl_< algebra::vec<n,C>, rotation<n,C> >
fun::internal::x2x_linear_impl_< algebra::vec<n,C>, C, rotation<n,C> >
,
public Function_v2v< rotation<n,C> >
{
/// Type of the underlying data stored in vectors and matrices.
typedef C data_t;
/// Type of the inverse function.
typedef rotation<n,C> invert;
/// Return the invere function.
......
......@@ -51,9 +51,13 @@ namespace mln
template <unsigned n, typename C>
struct translation
:
fun::internal::x2x_linear_impl_< algebra::vec<n,C>, translation<n,C> >,
fun::internal::x2x_linear_impl_< algebra::vec<n,C>, C,
translation<n,C> >,
public Function_v2v< translation<n,C> >
{
/// Type of the underlying data stored in vectors and matrices.
typedef C data_t;
/// Type of the inverse function.
typedef translation<n,C> invert;
/// Return the inverse function.
......
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