LRE
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
List overview
Download
Olena-patches
June 2005
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
olena-patches@lrde.epita.fr
8 participants
22 discussions
Start a n
N
ew thread
proto-1.0 199: Tree and Maxtree
by Nicolas Widynski
Index: ChangeLog from Nicolas Widynski <nicolas.widynski(a)lrde.epita.fr> * olena/oln/morpho/tree.hh: tree (canva). * olena/oln/morpho/maxtree.hh: creation of maxtree. * olena/oln/morpho/clean_astro_images.hh: maxtree utilisation's sample. clean_astro_images.hh | 268 ++++++++++++++++++++++++++++++++++++++++++ maxtree.hh | 315 ++++++++++++++++++++++++++++++++++++++++++++++++++ tree.hh | 196 +++++++++++++++++++++++++++++++ 3 files changed, 779 insertions(+) Index: olena/oln/morpho/tree.hh --- olena/oln/morpho/tree.hh (revision 0) +++ olena/oln/morpho/tree.hh (revision 0) @@ -0,0 +1,196 @@ +// Copyright (C) 2001-2005 EPITA Research and Development Laboratory +// +// This file is part of the Olena 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, 59 Temple Place - Suite 330, 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 OLENA_MORPHO_CANVAS_TREE_HH +# define OLENA_MORPHO_CANVAS_TREE_HH + +# include <mlc/any.hh> + +# include <oln/core/box.hh> +# include <oln/utils/record.hh> +# include <oln/core/abstract/image_entry.hh> +# include <oln/core/ch_value_type.hh> +# include <oln/level/fill.hh> +# include <oln/basics.hh> + +# include <vector> + +// just for test +#include <ntg/real/int_u.hh> + +namespace oln { + + namespace morpho { + + namespace canvas { + + + template <typename I, typename E> + struct tree : public mlc::any<E> + { + typedef oln_type_of(I, point) point_type; + + // Attribute. + box<const I> input; + oln_type_of(I, concrete) output; + std::vector<std::vector<point_type> > S; + point_type root_point; + + void run_compute_tree() + { + first_pass(); + compute_tree(); + } + + void run_compute_output() + { + init_traitement(); + traitement(); + } + + // Concrete method. + void first_pass() + { + oln_type_of(I, niter) n(input); + + // init + compute_S(); + set_is_processed_to_false(); + set_default_output(); + + typename std::vector<std::vector<point_type> >::reverse_iterator i; + typename std::vector<point_type>::const_iterator j; + for (i = S.rbegin(); i != S.rend(); i++) + { + for (j = i->begin(); j != i->end(); j++) + { + make_set(*j); + for_all_n_of_p (n, *j) + if (input.hold(n) and is_processed(n)) + do_union(n, *j); + set_is_processed(*j); + } + } + root_point = *j; + } + + void do_union(const point_type& n, const point_type& p) + { + point_type r = find_root(n); + if (r != p) + set_father(r, p); + } + + // Abstract methods. + // --------------------------- + + // init + + void init_traitement() + { + this->exact().impl_init_traitement(); + } + + void compute_S() + { + this->exact().impl_compute_S(); + } + void set_default_output() + { + this->exact().impl_set_default_output(); + } + + // about is_processed + void set_is_processed_to_false() + { + this->exact().impl_set_is_processed_to_false(); + } + void set_is_processed(const point_type& p) + { + this->exact().impl_set_is_processed(p); + } + bool is_processed(const point_type& n) const + { + return this->exact().impl_is_processed(n); + } + + const point_type get_father(const point_type& p) const + { + return this->exact().impl_get_father(p); + } + + // core + + void compute_tree() + { + this->exact().impl_compute_tree(); + } + + void traitement() + { + this->exact().impl_traitement(); + } + + void make_set(const point_type& p) + { + this->exact().impl_make_set(p); + } + point_type find_root(const point_type& x) + { + return this->exact().impl_find_root(x); + } + void set_father(const point_type& r, const point_type& p) + { + this->exact().impl_set_father(r, p); + } + + protected: + + // Ctor. + tree(const abstract::image_with_nbh<I>& input) : + input(input), + S() + { + } + + // Check for impls.. + ~tree() + { + // FIXME... mlc_check_method_impl(E, void, init, , ); + } + + }; + + + } // end of namespace oln::morpho::canvas + + } // end of namespace oln::morpho + +} // end of namespace oln + + +#endif // ! OLENA_MORPHO_CANVAS_TREE_HH Index: olena/oln/morpho/maxtree.hh --- olena/oln/morpho/maxtree.hh (revision 0) +++ olena/oln/morpho/maxtree.hh (revision 0) @@ -0,0 +1,315 @@ +// Copyright (C) 2001-2005 EPITA Research and Development Laboratory +// +// This file is part of the Olena 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, 59 Temple Place - Suite 330, 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 OLENA_MORPHO_MAX_TREE_HH +# define OLENA_MORPHO_MAX_TREE_HH + +# include <mlc/any.hh> + +# include <oln/core/box.hh> +# include <oln/utils/record.hh> +# include <oln/core/abstract/image_entry.hh> +# include <oln/core/ch_value_type.hh> +# include <oln/level/fill.hh> + +# include <oln/morpho/tree.hh> +# include <oln/basics.hh> + +# include <cassert> +# include <vector> +# include <functional> +# include <set> + +// just for test +#include <ntg/real/int_u.hh> + + +namespace oln { + + namespace morpho { + + namespace misc { + + struct pair_cmp + { + template<typename L, typename P> + bool operator()(const std::pair<L,P>& lhs, + const std::pair<L,P>& rhs) const + { + return lhs.first < rhs.first + or (lhs.first == rhs.first + and lhs.second.fwd_less(rhs.second)); + } + }; + + template<typename I, typename II, typename O, typename V> + void set_children(abstract::image_with_nbh<I>& marked, + const abstract::image_with_nbh<II>& children, + abstract::image_with_nbh<O>& out, + const oln_type_of(I, point)& p, + const V v) + { + typedef oln_type_of(I, point) point_type; + std::vector<point_type> f = children[p].value(); + typename std::vector<point_type>::const_iterator pt; + for (pt = f.begin(); pt != f.end(); pt++) + { + out[*pt] = v; + marked[*pt] = true; + set_children(marked, children, out, *pt, v); + } + } + + + template <class I> + std::vector<std::vector<oln_type_of(I, point)> > + sort(const abstract::image_with_nbh<I>& input) + { + typedef oln_type_of(I, point) point_type; + std::vector<std::vector<point_type> > S(256); + oln_type_of(I, fwd_piter) p(input.size()); + +#ifdef DEBUG + typedef std::pair<oln_type_of(I, value), point_type> pair_t; + std::set<pair_t,pair_cmp> sc; +#endif // ! DEBUG + + for_all_p (p) + { + S[input[p]].push_back(p); +#ifdef DEBUG + sc.insert(pair_t(input[p], p)); +#endif // ! DEBUG + } + +#ifdef DEBUG + { + unsigned l; + + typename std::set<pair_t,pair_cmp>::const_iterator i = sc.begin(); + typename std::vector<std::vector<point_type> >::const_iterator v; + + for (l = 0, v = S.begin(); + v != S.end(); v++, ++l) + { + for (typename std::vector<point_type>::const_iterator p = v->begin(); + p != v->end(); p++, ++i) + { + assert(input[*p] == l); + assert(i->first == l); + assert(i->second == *p); + } + } + } +#endif // ! DEBUG + + return S; + } + + } // end of oln::morpho::misc + + + template <typename I, typename E> + struct max_tree : public canvas::tree<I, E> + { + typedef canvas::tree<I, E> super_type; + typedef oln_type_of(I, point) point_type; + + // Attributes. + oln_ch_concrete_type(I, bool) is_proc; + oln_ch_concrete_type(I, bool) marked; + oln_ch_concrete_type(I, bool) is_deleted; + oln_ch_concrete_type(I, point_type) father; + oln_ch_concrete_type(I, std::vector<point_type>) children; + std::vector<std::vector<point_type> > v_root_point; + oln_type_of(I, concrete) new_value; + + void impl_compute_S() + { + this->S = misc::sort(this->input); + } + + bool condition_add_root_point(const point_type& f, const point_type& p) + { + if (this->input[f] == this->input[p]) + return false; + return true; + } + + void left_hand_walk(const point_type& p) + { + if (condition_add_root_point(p, father[p])) + v_root_point[this->input[p]].push_back(p); + + std::vector<point_type> f = children[p].value(); + typename std::vector<point_type>::const_iterator pt; + for (pt = f.begin(); pt != f.end(); pt++) + { + left_hand_walk(*pt); + } + } + + void impl_compute_tree() + { + v_root_point[this->input[this->root_point]].push_back(this->root_point); + left_hand_walk(this->root_point); + } + + void impl_set_default_output() + { + } + + void impl_set_is_processed_to_false() + { + oln_type_of(I, fwd_piter) p(is_proc.size()); + for_all_p (p) + is_proc[p] = false; + } + + void impl_set_is_processed(const point_type& p) + { + is_proc[p] = true; + } + + bool impl_is_processed(const point_type& n) const + { + return is_proc[n]; + } + + void init_aux_data(const point_type& p) + { + this->exact().impl_init_aux_data(p); + } + + const point_type impl_get_father(const point_type& p) const + { + return father[p].value(); + } + + void merge_aux_data(const point_type& r , const point_type& p) + { + children[p].call(&std::vector<point_type>::push_back, r); + this->exact().impl_merge_aux_data(r,p); + } + + void impl_make_set(const point_type& p) + { + father[p] = p; + init_aux_data(p); + } + + point_type impl_find_root(const point_type& x) + { + if (is_root(x)) + return x; + return find_root(father[x]); + } + + bool is_root(const point_type& x) const + { + return father[x] == x; + } + + void impl_set_father(const point_type& r, const point_type& p) + { + father[r] = p; + merge_aux_data(r,p); + } + + void eligible_component(const point_type& p) + { + this->exact().impl_eligible_component(p); + } + + void compute_image_is_deleted() + { + for (int i = 0; i <= 255 ;i++) + for (typename std::vector<point_type>::const_iterator p = v_root_point[i].begin(); + p != v_root_point[i].end(); p++) + eligible_component(*p); + } + + void impl_init_traitement() + { + level::fill(this->marked, false); + level::fill(this->is_deleted, false); + this->exact().impl_init_aux_traitement(); + } + + void impl_traitement() + { + compute_image_is_deleted(); + + oln_type_of(I, fwd_piter) p(this->input.size()); + for_all_p (p) + { + if (is_deleted[p]) + this->output[p] = this->new_value[p]; + else + this->output[p] = this->input[p]; + } + } + + protected: + + // Ctor. + max_tree(const abstract::image_with_nbh<I>& input) : + super_type(input) + { + oln_ch_concrete_type(I, bool) tmp1(input.size()); + is_proc = tmp1; + + oln_ch_concrete_type(I, point_type) tmp2(input.size()); + father = tmp2; + + oln_ch_concrete_type(I, std::vector<point_type>) tmp3(input.size()); + children = tmp3; + + oln_type_of(I, concrete) tmp4(input.size()); + this->output = tmp4; + + std::vector<std::vector<point_type> > tmp5(256); + v_root_point = tmp5; + + oln_ch_concrete_type(I, bool) tmp6(input.size()); + marked = tmp6; + + oln_ch_concrete_type(I, bool) tmp7(input.size()); + is_deleted = tmp7; + + oln_type_of(I, concrete) tmp8(input.size()); + new_value = tmp8; + } + + }; + + } // end of namespace oln::morpho + +} // end of namespace oln + + +#endif // ! OLENA_MORPHO_MAX_TREE_HH Index: olena/oln/morpho/clean_astro_images.hh --- olena/oln/morpho/clean_astro_images.hh (revision 0) +++ olena/oln/morpho/clean_astro_images.hh (revision 0) @@ -0,0 +1,268 @@ +// Copyright (C) 2001-2005 EPITA Research and Development Laboratory +// +// This file is part of the Olena 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, 59 Temple Place - Suite 330, 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 OLENA_MORPHO_CLEAN_ASTRO_IMAGES_HH +# define OLENA_MORPHO_CLEAN_ASTRO_IMAGES_HH + +# include <mlc/any.hh> + +# include <oln/core/box.hh> +# include <oln/utils/record.hh> +# include <oln/core/abstract/image_entry.hh> +# include <oln/core/ch_value_type.hh> +# include <oln/level/fill.hh> + +# include <oln/morpho/maxtree.hh> +# include <oln/basics.hh> + +# include <vector> + +// just for test +#include <ntg/real/int_u.hh> + + +namespace oln { + + namespace morpho { + + namespace misc { + + template<typename I> + bool have_the_center_point(const abstract::image_with_nbh<I>& children, + const oln_type_of(I, point)& p, + int row, + int col) + { + typedef oln_type_of(I, point) point_type; + if (((p.row() == (row / 2)) or (p.row() == (row - 1) / 2) or (p.row() == (row + 1) / 2)) + and ((p.col() == (col / 2)) or (p.col() == (col - 1) / 2) or (p.col() == (col + 1) / 2))) + return true; + std::vector<point_type> f = children[p].value(); + typename std::vector<point_type>::const_iterator pt; + for (pt = f.begin(); pt != f.end(); pt++) + { + return have_the_center_point(children, *pt, row, col); + } + return false; + } + + + template <typename I, typename II> + const oln_type_of(I, value) min_nbh(const abstract::image_with_nbh<I>& input, + const abstract::image_with_nbh<II>& children, + const oln_type_of(II, point)& p) + { + typedef oln_type_of(I, point) point_type; + std::vector<point_type> f = children[p].value(); + oln_type_of(I, niter) n(input.exact()); + oln_type_of(I, value) min; + typename std::vector<point_type>::const_iterator pt; + for (pt = f.begin(); pt != f.end(); pt++) + { + min = input[*pt].value(); + for_all_n_of_p (n, *pt) + { + min = ntg::min(min, input[n].value()); + } + + return ntg::min(min, min_nbh(input, children, *pt)); + } + return input[p]; + } + + template <typename I> + struct find_box + { + typedef oln_type_of(I, point) point_type; + + find_box(const point_type& p) { row_min_ = p.row(); row_max_ = p.row(); col_min_ = p.col(); col_max_ = p.col(); } + int row_min_, row_max_, col_min_, col_max_; + + + void box(const abstract::image_with_nbh<I>& children, + const oln_type_of(I, point)& p) + { + std::vector<point_type> f = children[p].value(); + typename std::vector<point_type>::const_iterator pt; + for (pt = f.begin(); pt != f.end(); pt++) + { + if (row_min_ > pt->row()) + row_min_ = pt->row(); + if (row_max_ < pt->row()) + row_max_ = pt->row(); + if (col_min_ > pt->col()) + col_min_ = pt->col(); + if (col_max_ < pt->col()) + col_max_ = pt->col(); + box(children, *pt); + } + } + }; + + + template <typename I> + bool is_a_circle(const abstract::image_with_nbh<I>& children, + const oln_type_of(I, point)& p, + float c_a) + { + find_box<I> fb(p); + fb.box(children,p); + int w = fb.col_max_ - fb.col_min_ + 1; + int h = fb.row_max_ - fb.row_min_ + 1; + float theoric_area = 3.14f * ((h + w) / 4.0) * ((h + w) / 4.0); + +#ifdef DEBUG + std::cout << "POINT : " << p << std::endl; + std::cout << "col_min : " << fb.col_min_ << std::endl; + std::cout << "col_max : " << fb.col_max_ << std::endl; + std::cout << "row_min : " << fb.row_min_ << std::endl; + std::cout << "row_max : " << fb.row_max_ << std::endl; + std::cout << "theoric area : " << theoric_area << std::endl; + std::cout << "computed area : " << c_a << std::endl; + std::cout << "t - sqrt(c) : " << theoric_area - sqrt(c_a) << std::endl; + std::cout << "t + sqrt(c) : " << theoric_area + sqrt(c_a) << std::endl; + std::cout << "w : " << w << std::endl << "h : " << h << std::endl; +#endif // ! DEBUG + if (((theoric_area - sqrt(c_a) < c_a) && + (theoric_area + sqrt(c_a) > c_a)) && + (c_a > (0.9 * 0.75 * w * h)) && + (c_a < (1.1 * 0.75 * w * h))) + return true; + return false; + } + + } // end of oln::morpho::misc + + + template <typename I> + struct clean_astro : public max_tree<I, clean_astro<I> > + { + typedef max_tree<I, clean_astro<I> > super_type; + typedef oln_type_of(I, point) point_type; + + // Attributes. + oln_ch_concrete_type(I, unsigned) area; + oln_type_of(I, value) level_; + unsigned area_; + + + // specific methods + + void set_area(unsigned nb) + { + area_ = nb; + } + + void set_level(unsigned nb) + { + level_ = nb; + } + + void remove_star(const point_type& p) + { + this->is_deleted[p] = true; + misc::set_children(this->marked, this->children, this->is_deleted, p, true); + this->new_value[p] = this->input[this->father[p]].value(); + misc::set_children(this->marked, + this->children, this->new_value, p, this->input[this->father[p]].value()); + } + + void remove_little_surface(const point_type& p) + { + this->is_deleted[p] = true; + misc::set_children(this->marked, this->children, this->is_deleted, p, true); + this->new_value[p] = this->input[this->father[p]].value(); + misc::set_children(this->marked, + this->children, this->new_value, p, this->input[this->father[p]].value()); + } + + bool is_a_star(const point_type& p) + { + if (not (this->marked[p])) + { + if (this->area[p] >= area_) + if (not (misc::have_the_center_point(this->children, p, this->input.size().nrows(), + this->input.size().ncols()))) + if (misc::is_a_circle(this->children, p, this->area[p])) + return true; + } + return false; + } + + bool is_a_little_surface(const point_type& p) + { + if (this->area[p] <= 20 && this->input[p] < 150) + return true; + return false; + } + + // fill the holes + + void impl_init_aux_data(const point_type& p) + { + this->area[p] = 1; + } + + void impl_merge_aux_data(const point_type& r , const point_type& p) + { + this->area[p] = this->area[r].value() + this->area[p].value(); + } + + void impl_eligible_component(const point_type& p) + { + if (this->input[p].value() > this->level_) + { + // if (is_a_little_surface(p)) + // remove_little_surface(p); + if (is_a_star(p)) + remove_star(p); + } + } + + void impl_init_aux_traitement() + { + } + + // Ctor. + clean_astro(const abstract::image_with_nbh<I>& input) : + super_type(input) + { + oln_ch_concrete_type(I, unsigned) tmp(input.size()); + this->area = tmp; + + this->area_ = 0; + this->level_ = 0; + } + + }; + + } // end of namespace oln::morpho + +} // end of namespace oln + + +#endif // ! OLENA_MORPHO_CLEAN_ASTRO_IMAGES_HH
19 years, 6 months
5
5
0
0
proto-1.0 203: Fix level::arith
by Roland Levillain
Il faudrait qu'on voie ce qu'on fait pour oln/level/arith.hh : plus() est écrit à l'aide d'un objet fonction, alors que les autres utilisent les opérateurs de oln/ops/arith.hh. Par ailleurs, je me demande s'il n'y a pas de duplication de code dans oln/core/apply.hh : apply() (et apply2()) sont définis à la fois pour les objets fonctions de Metalic (mlc/fun.hh) et ceux d'Olena (oln/funobj).
https://svn.lrde.epita.fr/svn/oln/prototypes/proto-1.0
ChangeLog | 10 ++++ oln/level/arith.hh | 11 ++--- tests/level/tests/arith | 97 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 113 insertions(+), 5 deletions(-) Index: olena/ChangeLog from Roland Levillain <roland(a)lrde.epita.fr> Fix level::arith. * oln/level/arith.hh (oln/core/apply.hh): Include it. (f_plus): Rename as... (plus): ...this. (minus, times, div, mod): Fix the operators used in these functions. * tests/level/tests/arith: New test. Index: olena/oln/level/arith.hh --- olena/oln/level/arith.hh (revision 202) +++ olena/oln/level/arith.hh (working copy) @@ -32,6 +32,7 @@ # include <oln/core/ch_value_type.hh> # include <oln/funobj/arith.hh> +# include <oln/core/apply.hh> # include <oln/ops/arith.hh> # include <oln/utils/clone.hh> @@ -111,7 +112,7 @@ template <typename I1, typename I2> oln_arith_output(plus, I1, I2) - f_plus (const abstract::image<I1>& input1, + plus (const abstract::image<I1>& input1, const abstract::image<I2>& input2) { // FIXME: recording(?) @@ -162,7 +163,7 @@ precondition(input1.size() == input2.size()); oln_arith_output(minus,I1,I2) output("output"); - output = clone( input1 + input2 ); + output = clone( input1 - input2 ); exiting("level::minus"); return output; @@ -185,7 +186,7 @@ precondition(input1.size() == input2.size()); oln_arith_output(times,I1,I2) output("output"); - output = clone( input1 + input2 ); + output = clone( input1 * input2 ); exiting("level::times"); return output; @@ -208,7 +209,7 @@ precondition(input1.size() == input2.size()); oln_arith_output(div,I1,I2) output("output"); - output = clone( input1 + input2 ); + output = clone( input1 / input2 ); exiting("level::div"); return output; @@ -231,7 +232,7 @@ precondition(input1.size() == input2.size()); oln_arith_output(mod,I1,I2) output("output"); - output = clone( input1 + input2 ); + output = clone( input1 % input2 ); exiting("level::mod"); return output; Index: olena/tests/level/tests/arith --- olena/tests/level/tests/arith (revision 0) +++ olena/tests/level/tests/arith (revision 0) @@ -0,0 +1,97 @@ + // -*- C++ -*- +#include <ntg/int.hh> +#include <oln/basics2d.hh> +#include <oln/level/arith.hh> +#include <oln/level/fill.hh> +#include <oln/level/compare.hh> + +using namespace oln; + + +// FIXME: Not safe, nor generic. Re-introduce static initialization +// in Olena and use it instead. +template<typename T> +image2d<T> +image_from_array(coord_t nrows, coord_t ncols, T values[]) +{ + image2d<T> output(nrows, ncols); + unsigned i = 0; + oln_type_of(image2d<T>, fwd_piter) p(output.size()); + for_all_p (p) + { + output[p] = values[i]; + ++i; + } + return output; +} + + +bool check() +{ + typedef ntg::int_s<32, ntg::unsafe> value_type; + + image2d<value_type> ima1(3, 3); + ima1(0, 0) = 0; ima1(0, 1) = 1; ima1(0, 2) = 2; + ima1(1, 0) = 3; ima1(1, 1) = 4; ima1(1, 2) = 5; + ima1(2, 0) = 6; ima1(2, 1) = 7; ima1(2, 2) = 8; + + image2d<value_type> ima2(3, 3); + level::fill(ima2, 3); + + // Checking level::plus. + { + image2d<value_type> sum = level::plus(ima1, ima2); + value_type sum_ref[] = { 3, 4, 5, + 6, 7, 8, + 9, 10, 11 }; + if (not level::is_equal(sum, + image_from_array<value_type>(3, 3, sum_ref))) + return true; + } + + // Checking level::minus. + { + image2d<value_type> diff = level::minus(ima1, ima2); + value_type diff_ref[] = { -3, -2, -1, + 0, 1, 2, + 3, 4, 5 }; + if (not level::is_equal(diff, + image_from_array<value_type>(3, 3, diff_ref))) + return true; + } + + // Checking level::times. + { + image2d<value_type> product = level::times(ima1, ima2); + value_type product_ref[] = { 0, 3, 6, + 9, 12, 15, + 18, 21, 24 }; + if (not level::is_equal(product, + image_from_array<value_type>(3, 3, product_ref))) + return true; + } + + // Checking level::div. + { + image2d<value_type> quotient = level::div(ima1, ima2); + value_type quotient_ref[] = { 0, 0, 0, + 1, 1, 1, + 2, 2, 2 }; + if (not level::is_equal(quotient, + image_from_array<value_type>(3, 3, quotient_ref))) + return true; + } + + // Checking level::mod. + { + image2d<value_type> remain = level::mod(ima1, ima2); + value_type remain_ref[] = { 0, 1, 2, + 0, 1, 2, + 0, 1, 2 }; + if (not level::is_equal(remain, + image_from_array<value_type>(3, 3, remain_ref))) + return true; + } + + return false; +}
19 years, 6 months
1
0
0
0
← Newer
1
2
3
Older →
Jump to page:
1
2
3
Results per page:
10
25
50
100
200