Commit 324abfb2 authored by Roland Levillain's avatar Roland Levillain
Browse files

Remove Milena sandboxes.

parent 39e1152e
This diff is collapsed.
These files have been integrated into Milena:
mln/morpho/topo_wst.hh
-> ../../mln/morpho/watershed/topological.hh
tests/morpho/test_watershed_topo.cc
-> ../../tests/morpho/watershed/topological.cc
The versions contained in this sandbox should be considered obsolete
and should not be used nor modified anymore. Actually, removing them
might be a good option.
P5
# CREATOR: GIMP PNM Filter Version 1.1
16 16
255
[kyzyzxrrTXitx}pxS*mSeopwws,FXQfkvʃ[88^Srjw.t`Rt{~rpnEaQajC=n.q]Tgl;4D8UWiH<YqWHRC]U9FeqIrGTJQg:vPLBOMo?2W1UNHFeD/OuX}rW_66QX6by[a7/I<Gne]Qv2>C7_|_jOJ
\ No newline at end of file
P6
# CREATOR: GIMP PNM Filter Version 1.1
16 16
255
nkDRTVb_c`b`c`a_\^pjlrЅr]^@Qj}f@MQU\\acpq̓~hjX\bd~nxg梀@Q`@VU}e<MMTWYZartץݻot`babqe__b@{5RAN|i:LOVTY`evw۫ྴŻpnGV֐q%Gn&J~yFNj;J]ZRWagԅڜۨٱ۫۱࿲aDcnӈ}HPk:J_[maejjva}`wԟݹП_k}3SӈЇ}IQm9JIQ}pThx0]o+Yب‚]kf@akԐψFPp=OOUWbo)Vf"Qv|ˀ蟕֍z2Sn&I˄{ˈ~Ɓ}=Kq?MWgv7gj+YI_sv]n߁BY6VAW΅yȁyɌ-FqGb}Ezh(T}5SUcfj凂[f7SbfȁyΎz1Hu>\t:o~AjXhw'F[_oozy<V:R}r}w㭅˥-Hw;]s>r`r.LlA?LgjishCBUɅy|w鿘ǝ=Uuz7Zp6fXt4YcC9MilّisFXmnbg跍ERRgsg%Ld&RxBuJnq#DJSjf}koysђ{́lGVTgpk&M^Jo:ik,S2FW[icyo殜ΖU^ژtHP>Tju܇pc!Jj.[m4an%HGLc\mfshᖇܮMXWW=S8Q
\ No newline at end of file
P5
# CREATOR: GIMP PNM Filter Version 1.1
4 3
255
*oydFj
\ No newline at end of file
// Copyright (C) 2007 EPITA Research and Development Laboratory
//
// This file is part of the Milena 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.
#ifndef MLN_CORE_P_PRIORITY_QUEUE_HH
# define MLN_CORE_P_PRIORITY_QUEUE_HH
/*! \file mln/core/p_priority_queue.hh
*
* \brief Definition of a site set class based on p_queue with
* priority features.
*/
# include <vector>
# include <deque>
# include <map>
# include <algorithm>
# include <iterator>
# include <mln/core/internal/site_set_base.hh>
# include <mln/core/site_set/p_array.hh>
# include <mln/accu/shape/bbox.hh>
# include <mln/core/site_set/p_queue.hh>
namespace mln
{
// Fwd decls.
template <typename P> struct p_array_fwd_piter_;
template <typename P> struct p_array_bkd_piter_;
/*! \brief Site priority queue class (based on p_queue and std::map).
*
* This is a mathematical set of sites (unique insertion).
*
* \todo Make it work with P being a Site_Site.
*
* \warning We have some troubles with site set comparison based on
* a call to nsites() when this container is multiple.
*/
template <typename P, typename T>
class p_priority_queue : public internal::site_set_base_< P, p_priority_queue<P, T> >
{
public:
/// Forward Site_Iterator associated type.
typedef p_array_fwd_piter_<P> fwd_piter;
/// Backward Site_Iterator associated type.
typedef p_array_bkd_piter_<P> bkd_piter;
/// Constructor.
p_priority_queue();
/// Test is \p p belongs to this site set.
bool has(const P& p) const;
/// Test if queue is empty or not.
bool is_empty() const;
/// Give the number of sites.
size_t nsites() const;
/// Give the exact bounding box.
const box_<P>& bbox() const;
/// Push force a site \p p in the queue.
p_priority_queue<P, T>& push_force(const P& p, T prio = 0);
/// Push a site \p p in the queue.
p_priority_queue<P, T>& push(const P& p, T prio = 0);
/// Pop (remove) the front site \p p from the queue; \p p is the
/// least recently inserted site.
void pop();
/// Give the front site \p p of the queue; \p p is the least
/// recently inserted site.
const P& front() const;
/// Pop (remove) the front site \p p from the queue; \p p is the
/// least recently inserted site and give the front site \p p of
/// the queue; \p p is the least recently inserted site.
const P& pop_front();
/// Clear the queue.
void clear();
/// Return the corresponding std::vector of sites.
const std::vector<P>& vect() const;
/// Return the \p i-th site.
const P& operator[](unsigned i) const;
protected:
typedef std::map<T, p_queue<P> > queue_map_t;
queue_map_t q_;
mutable std::vector<P> vect_;
mutable bool vect_needs_update_;
void vect_update_() const;
mutable accu::shape::bbox<P> bb_;
mutable bool bb_needs_update_;
void bb_update_() const;
};
# ifndef MLN_INCLUDE_ONLY
template <typename P, typename T>
inline
p_priority_queue<P, T>::p_priority_queue()
{
vect_needs_update_ = false;
bb_needs_update_ = false;
}
template <typename P, typename T>
inline
void
p_priority_queue<P, T>::vect_update_() const
{
vect_.clear();
vect_.reserve(nsites());
typename queue_map_t::const_iterator it = q_.begin ();
for (; it != q_.end (); ++it)
std::copy((*it).second.vect().begin(), (*it).second.vect().end(),
std::back_inserter(vect_));
vect_needs_update_ = false;
}
template <typename P, typename T>
inline
void
p_priority_queue<P, T>::bb_update_() const
{
bb_.init();
typename queue_map_t::const_iterator it = q_.begin ();
for (; it != q_.end (); ++it)
for (unsigned i = 0; i < (*it).second.nsites (); ++i)
bb_.take((*it).second[i]);
bb_needs_update_ = false;
}
template <typename P, typename T>
inline
bool
p_priority_queue<P, T>::has(const P& p) const
{
typename queue_map_t::const_iterator it = q_.begin ();
for (; it != q_.end (); ++it)
if ((*it).second.has (p))
return true;
return false;
}
template <typename P, typename T>
inline
bool
p_priority_queue<P, T>::is_empty() const
{
typename queue_map_t::const_iterator it = q_.begin ();
for (; it != q_.end (); ++it)
if (!(*it).second.is_empty ())
return false;
return true;
}
template <typename P, typename T>
inline
size_t
p_priority_queue<P, T>::nsites() const
{
unsigned res = 0;
typename queue_map_t::const_iterator it = q_.begin ();
for (; it != q_.end (); ++it)
if (!(*it).second.is_empty ())
res += (*it).second.nsites();
return res;
}
template <typename P, typename T>
inline
const box_<P>&
p_priority_queue<P, T>::bbox() const
{
mln_precondition(nsites() != 0);
if (bb_needs_update_)
bb_update_();
return bb_.to_result();
}
template <typename P, typename T>
inline
p_priority_queue<P, T>&
p_priority_queue<P, T>::push_force(const P& p, T prio)
{
q_[prio].push_force (p);
if (! vect_needs_update_)
{
vect_needs_update_ = true;
bb_needs_update_ = true;
}
return *this;
}
template <typename P, typename T>
inline
p_priority_queue<P, T>&
p_priority_queue<P, T>::push(const P& p, T prio)
{
if (! has(p))
return this->push_force(p, prio);
else
return *this;
}
template <typename P, typename T>
inline
void
p_priority_queue<P, T>::pop()
{
typename queue_map_t::reverse_iterator it =
q_.rbegin ();
for (; it != q_.rend (); ++it)
if (!(*it).second.is_empty ())
return (*it).second.pop ();
if (! vect_needs_update_)
{
vect_needs_update_ = true;
bb_needs_update_ = true;
}
}
template <typename P, typename T>
inline
const P&
p_priority_queue<P, T>::front() const
{
mln_precondition(! q_.empty());
typename queue_map_t::const_reverse_iterator it =
q_.rbegin ();
for (; it != q_.rend (); ++it)
if (!(*it).second.is_empty ())
break;
return (*it).second.front ();
}
template <typename P, typename T>
inline
const P&
p_priority_queue<P, T>::pop_front()
{
const P& res = this->front();
this->pop();
return res;
}
template <typename P, typename T>
inline
void
p_priority_queue<P, T>::clear()
{
typename queue_map_t::iterator it = q_.begin ();
for (; it != q_.end (); ++it)
(*it).second.clear ();
q_.clear();
vect_needs_update_ = false;
bb_needs_update_ = false;
}
template <typename P, typename T>
inline
const std::vector<P>&
p_priority_queue<P, T>::vect() const
{
if (vect_needs_update_)
vect_update_();
return vect_;
}
template <typename P, typename T>
inline
const P&
p_priority_queue<P, T>::operator[](unsigned i) const
{
mln_precondition(i < nsites());
typename queue_map_t::const_reverse_iterator it = q_.rbegin ();
unsigned cpt = 0;
for (; it != q_.rend (); ++it)
{
if (!(*it).second.is_empty ())
for (cpt = 0; cpt < (*it).second.nsites (); ++cpt)
{
if (i == 0)
return (*it).second[cpt];
--i;
}
}
return (*it).second[cpt];
}
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
#endif // ! MLN_CORE_P_PRIORITY_QUEUE_HH
// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Milena 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.
// reasons why the executable file might be covered by the GNU General
// Public License.
#ifndef MLN_FUN_V2V_RGB_TO_HSI_HH
# define MLN_FUN_V2V_RGB_TO_HSI_HH
#include <cmath>
#include <mln/value/rgb8.hh>
#include <mln/math/round.hh>
#include <mln/value/hsi.hh>
// FIXME: Split interface and implementation.
namespace mln
{
namespace fun
{
namespace v2v
{
template <typename T_hsi>
struct f_rgb_to_hsi_ : public Function_v2v< f_rgb_to_hsi_<T_hsi> >
{
typedef T_hsi result;
template <typename T_rgb>
T_hsi operator()(const T_rgb& rgb) const
{
// Locals.
// wtf?
// static const double sqrt3_3 = std::sqrt(3) / 3;
// static const double inv_sqrt6 = 1 / std::sqrt(6);
// static const double inv_sqrt2 = 1 / std::sqrt(2);
T_hsi hsi;
// double alpha = inv_sqrt2 * rgb.green() - inv_sqrt2 * rgb.blue();
// double beta =
// 2 * inv_sqrt6 * rgb.red() -
// inv_sqrt6 * rgb.green() -
// inv_sqrt6 * rgb.blue();
// hsi.hue() = atan2(beta, alpha) / 3.1415 * 180.0;
// if (hsi.hue() < 0)
// hsi.hue() = hsi.hue() + 360.0;
// mln_invariant(hsi.hue() >= 0);
// hsi.sat() = std::sqrt(alpha * alpha + beta * beta);
// hsi.inty() =
// sqrt3_3 * rgb.red() +
// sqrt3_3 * rgb.green() +
// sqrt3_3 * rgb.blue();
hsi.inty() = (double) (rgb.red() + rgb.green() + rgb.blue()) / 3 / mln_max(typename T_rgb::red_t);
typename T_rgb::red_t min = rgb.red();
if (rgb.green() < min)
min = rgb.green();
if (rgb.blue() < min)
min = rgb.blue();
if (hsi.inty())
hsi.sat() = (1 - (double) 3 * min / (double)(rgb.red() + rgb.green() + rgb.blue()));
else
hsi.sat() = 0; // this is black for any value of saturation
if (hsi.sat())
hsi.hue() = acos( 0.5 * (2 * rgb.red() - rgb.green() - rgb.blue()) /
std::sqrt((rgb.red() - rgb.green()) * (rgb.red() - rgb.green()) + (rgb.red() - rgb.blue()) * (rgb.green() - rgb.blue()))) / 3.1416;
else
hsi.hue() = 0; // this is grey for any value of hue
if (hsi.hue() < 0)
hsi.hue() = hsi.hue() + 1.0;
mln_invariant(hsi.hue() >= 0);
mln_invariant(hsi.hue() < 360);
mln_invariant(hsi.sat() >= 0);
mln_invariant(hsi.inty() >= 0);
return hsi;
}
};
typedef f_rgb_to_hsi_<value::hsi_f> f_rgb_to_hsi_f_t;
// FIXME: Warning: global object.
f_rgb_to_hsi_f_t f_rgb_to_hsi_f;
template <typename T_rgb>
struct f_hsi_to_rgb_ : public Function_v2v< f_hsi_to_rgb_<T_rgb> >
{
typedef T_rgb result;
template <typename T_hsi>
T_rgb operator()(const T_hsi& hsi) const
{
typedef typename T_rgb::red_t red_t;
typedef typename T_rgb::green_t green_t;
typedef typename T_rgb::blue_t blue_t;
static math::round<red_t> to_r;
static math::round<green_t> to_g;
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);
float
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);
green_t g =
to_g(sqrt3_3 * hsi.inty() + inv_sqrt2 * alpha - inv_sqrt6 * beta);
blue_t b =
to_b(sqrt3_3 * hsi.inty() - inv_sqrt2 * alpha - inv_sqrt6 * beta);
T_rgb rgb(r, g, b);
return rgb;
}
};
typedef f_hsi_to_rgb_<value::rgb8> f_hsi_to_rgb_3x8_t;
// FIXME: Warning: global object.
f_hsi_to_rgb_3x8_t f_hsi_to_rgb_3x8;
} // end of namespace fun::v2v
} // end of namespace fun
} // end of namespace mln
#endif // ! MLN_FUN_V2V_RGB_TO_HSI_HH
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 EPITA
// Research and Development Laboratory
//
// This file is part of the Milena 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.
#ifndef MLN_IO_TIKZ_SAVE_HH
# define MLN_IO_TIKZ_SAVE_HH
/*!
* \file mln/io/tikz/save.hh