Commit ccf8035d authored by Thierry Geraud's avatar Thierry Geraud
Browse files

Add perfect fusion grid neighborhoods from 2D and 3D.

	* theo/esiee: New directory.
	* theo/esiee/jean: New directory.
	* theo/esiee/jean/pfg2d.cc: New.
	* theo/esiee/jean/pfg3d.cc: New.


git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@3196 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent 8395a38d
2009-01-23 Thierry Geraud <thierry.geraud@lrde.epita.fr>
Add perfect fusion grid neighborhoods from 2D and 3D.
* theo/esiee: New directory.
* theo/esiee/jean: New directory.
* theo/esiee/jean/pfg2d.cc: New.
* theo/esiee/jean/pfg3d.cc: New.
2009-01-21 Thierry Geraud <thierry.geraud@lrde.epita.fr>
Handle properly output in Laurent's method.
......
#include <mln/core/var.hh>
#include <mln/make/double_neighb2d.hh>
inline
bool chess(const mln::point2d& p)
{
return p.row() % 2 == p.col() % 2;
}
int main()
{
using namespace mln;
bool u11[] = { 1, 1, 0,
1, 0, 1,
0, 1, 1 };
bool u1_1[] = { 0, 1, 1,
1, 0, 1,
1, 1, 0 };
mln_VAR(nbh, make::double_neighb2d(chess, u11, u1_1));
{
point2d p(0, 0);
std::cout << "N( " << p << " ) = { ";
mln_niter_(nbh_t) n(nbh, p);
for_all(n)
std::cout << n << ' ';
std::cout << " }" << std::endl;
// N( (0, 0) ) = { (-1, -1) (-1, 0) (0, -1) (0, 1) (1, 0) (1, 1) }
}
{
point2d p(0, 1);
std::cout << "N( " << p << " ) = { ";
mln_niter_(nbh_t) n(nbh, p);
for_all(n)
std::cout << n << ' ';
std::cout << " }" << std::endl;
// N( (0, 1) ) = { (-1, 1) (-1, 2) (0, 0) (0, 2) (1, 0) (1, 1) }
}
}
#include <mln/core/var.hh>
#include <mln/core/image/image3d.hh>
#include <mln/debug/iota.hh>
#include <mln/debug/println.hh>
# include <mln/core/alias/window3d.hh>
# include <mln/core/alias/neighb3d.hh>
# include <mln/win/multiple.hh>
# include <mln/convert/to.hh>
namespace mln
{
template <typename A, unsigned S>
inline
neighb< win::multiple<window3d, unsigned(*)(A)> >
make_pfg_neighb3d(unsigned (*test)(A),
bool const (&case_0)[S],
bool const (&case_1)[S],
bool const (&case_2)[S],
bool const (&case_3)[S])
{
typedef win::multiple<window3d, unsigned(*)(A)> W;
W wm(test);
wm.set_window(0, convert::to<window3d>(case_0));
wm.set_window(1, convert::to<window3d>(case_1));
wm.set_window(2, convert::to<window3d>(case_2));
wm.set_window(3, convert::to<window3d>(case_3));
neighb<W> tmp(wm);
return tmp;
}
// pfg3d is "3D perfect fusion grid" for short.
unsigned pfg3d_case_number(const point3d& p)
{
int id = 2 * (p.row() % 2 == p.col() % 2) + (p.row() % 2 == p.sli() % 2);
mln_invariant(id >= 0 && id <= 3);
return id;
}
template <typename W>
neighb<W>
make_neighb(const Window<W>& win)
{
neighb<W> tmp(exact(win));
return tmp;
}
template <typename I, typename N>
void
show_nbh(const I& ima, const mln_psite(I)& p, const N& nbh)
{
std::cout << ima(p) << ": " << ' ';
mln_niter(N) n(nbh, p);
for_all(n)
std::cout << ima(n) << ' ';
std::cout << std::endl;
}
} // mln
int main()
{
using namespace mln;
box3d b = make::box3d(-1,1, -1,1, -1,1);
image3d<unsigned> ima(b);
debug::iota(ima);
debug::println(ima);
bool u111 [] = { 1, 1, 0, // case 3
1, 1, 0,
0, 0, 0,
1, 1, 0,
1, 0, 1,
0, 1, 1,
0, 0, 0,
0, 1, 1,
0, 1, 1 };
bool u1_11[] = { 0, 1, 1, // case 1
0, 1, 1,
0, 0, 0,
0, 1, 1,
1, 0, 1,
1, 1, 0,
0, 0, 0,
1, 1, 0,
1, 1, 0 };
bool u11_1[] = { 0, 0, 0, // case 2
0, 1, 1,
0, 1, 1,
1, 1, 0,
1, 0, 1,
0, 1, 1,
1, 1, 0,
1, 1, 0,
0, 0, 0 };
bool u1_1_1[] = { 0, 0, 0, // case 0
1, 1, 0,
1, 1, 0,
0, 1, 1,
1, 0, 1,
1, 1, 0,
0, 1, 1,
0, 1, 1,
0, 0, 0 };
mln_VAR( nbh, make_pfg_neighb3d(pfg3d_case_number,
u1_1_1, // 0
u1_11, // 1
u11_1, // 2
u111 // 3
) );
show_nbh(ima, point3d(0,0,0), nbh);
}
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