$extrastylesheet
Olena
User documentation 2.1
An Image Processing Platform
Milena
Getting started
API Reference Manual
All Classes
Examples
Demos
Publications
All
Classes
Namespaces
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
interpolated-tr_image-composed.cc
1
// Copyright (C) 2013 EPITA Research and Development Laboratory (LRDE).
2
//
3
// This file is part of Olena.
4
//
5
// Olena is free software: you can redistribute it and/or modify it under
6
// the terms of the GNU General Public License as published by the Free
7
// Software Foundation, version 2 of the License.
8
//
9
// Olena is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
// General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with Olena. If not, see <http://www.gnu.org/licenses/>.
16
//
17
// As a special exception, you may use this file as part of a free
18
// software project without restriction. Specifically, if other files
19
// instantiate templates or use macros or inline functions from this
20
// file, or you compile this file and link it with other files to produce
21
// an executable, this file does not by itself cause the resulting
22
// executable to be covered by the GNU General Public License. This
23
// exception does not however invalidate any other reasons why the
24
// executable file might be covered by the GNU General Public License.
25
29
30
#include <iostream>
31
32
#include <mln/core/image/image2d.hh>
33
#include <mln/core/image/imorph/interpolated.hh>
34
#include <mln/core/image/imorph/safe.hh>
35
#include <mln/core/image/imorph/tr_image.hh>
36
37
#include <mln/fun/x2v/bilinear.hh>
38
#include <mln/fun/x2x/rotation.hh>
39
#include <mln/fun/x2x/translation.hh>
40
#include <mln/fun/x2x/composed.hh>
41
42
#include <mln/math/pi.hh>
43
#include <mln/math/sqrt.hh>
44
45
#include <mln/algebra/vec.hh>
46
47
#include <mln/debug/iota.hh>
48
#include <mln/debug/println.hh>
49
51
#define PRINTLN(Ima) mln::debug::println(#Ima " = ", Ima)
52
53
54
int
main()
55
{
56
using namespace
mln;
57
58
typedef
image2d<float>
I;
59
I ima(4, 4);
60
debug::iota
(ima);
61
PRINTLN(ima);
62
63
// Step-by-step approach.
64
{
67
typedef
mln::safe_image<I>
S;
68
S
safe
(ima, 0.f);
69
PRINTLN(
safe
);
70
72
typedef
interpolated<S, fun::x2v::bilinear> B;
73
B inter(
safe
);
74
PRINTLN(inter);
75
77
float
angle =
math::pi
/ 4;
78
typedef
fun::x2x::rotation<2, float>
F;
79
F
rotate
(angle);
80
typedef
fun::x2x::translation<2, float>
G;
81
/* FIXME: Compute these coordinates automatically from IMA's
82
domain and ANGLE. */
83
G
translate
(
make::vec
(1.5f, 1.5f * (1.f -
math::sqrt
(2.f))));
84
typedef
fun::x2x::composed<G, F>
H;
85
H move(
translate
,
rotate
);
86
typedef
tr_image<mln_domain_(B), B, H>
M;
87
M moved(inter.domain(), inter, move);
88
PRINTLN(moved);
89
}
90
91
// Equivalent ``one-liner''.
92
{
93
/* FIXME: mln/fun/x2x/rotation.hh and mln/fun/x2x/translation.hh
94
should provide generators (helpers), as mln/fun/x2x/composed.hh
95
does. */
96
/* FIXME: We could also add a routine perfoming the centered
97
rotation as shortcut. */
98
PRINTLN(
apply_tr
99
(interpolate<fun::x2v::bilinear>(
safe
(ima, 0.f).rw()),
100
/* FIXME: Compute these coordinates automatically from
101
IMA's domain and ANGLE. */
102
compose
(
fun::x2x::translation<2, float>
103
(
make::vec
(1.5f,
104
1.5f * (1.f -
math::sqrt
(2.f)))),
105
fun::x2x::rotation<2, float>
(
math::pi
/ 4))));
106
}
107
}
tests
core
image
imorph
interpolated-tr_image-composed.cc
Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)