$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ima2d-rot.cc
1 #include <mln/core/image/image2d.hh>
2 #include <mln/core/image/dmorph/extended.hh>
3 #include <mln/core/var.hh>
4 #include <mln/core/routine/extend.hh>
5 
6 #include <mln/value/rgb8.hh>
7 
8 #include <mln/border/fill.hh>
9 
10 #include <mln/literal/colors.hh>
11 
12 #include <mln/data/fill.hh>
13 
14 #include <mln/draw/box.hh>
15 
16 #include <mln/fun/x2x/rotation.hh>
17 
18 #include <mln/algebra/vec.hh>
19 
20 #include <doc/tools/sample_utils.hh>
21 
22 int main()
23 {
24  using namespace mln;
25 
26  // \{
27  border::thickness = 30;
28 
29  // Declare the image to be rotated.
30  image2d<value::rgb8> ima1_(220, 220);
31  data::fill(ima1_, literal::cyan);
33  // Set an infinite extension.
34  mln_VAR(ima1, extend(ima1_, pw::cst(literal::yellow)));
35 
36  // Declare the output image.
37  image2d<value::rgb8> ima2(220, 220);
40 
41  box2d extended_domain= ima1.domain();
42  extended_domain.enlarge(border::thickness);
43 
44  // Draw the domain bounding box
45  draw::box(ima1, geom::bbox(ima1_), literal::red);
46  // Save the image, including its border.
47  doc::ppmsave(ima1 | extended_domain, "ima2d-rot");
48 
49  // Define and apply a point-wise rotation
51  image2d<value::rgb8>::fwd_piter p(ima1.domain());
52  for_all(p)
53  {
54  algebra::vec<2,float> pv = p.to_site().to_vec();
55  algebra::vec<2,float> v = rot1.inv()(pv);
56  ima2(p) = ima1(v);
57  }
58 
59  draw::box(ima2, ima2.bbox(), literal::red);
60  doc::ppmsave(extended_to(ima2, extended_domain), "ima2d-rot");
61  // \}
62 
63 }