Milena (Olena)
User documentation 2.0a Id
|
00001 #include <mln/core/image/image2d.hh> 00002 #include <mln/core/image/dmorph/extended.hh> 00003 #include <mln/core/var.hh> 00004 #include <mln/core/routine/extend.hh> 00005 00006 #include <mln/value/rgb8.hh> 00007 00008 #include <mln/border/fill.hh> 00009 00010 #include <mln/literal/colors.hh> 00011 00012 #include <mln/data/fill.hh> 00013 00014 #include <mln/draw/box.hh> 00015 00016 #include <mln/fun/x2x/rotation.hh> 00017 00018 #include <mln/algebra/vec.hh> 00019 00020 #include <doc/tools/sample_utils.hh> 00021 00022 int main() 00023 { 00024 using namespace mln; 00025 00026 // \{ 00027 border::thickness = 30; 00028 00029 // Declare the image to be rotated. 00030 image2d<value::rgb8> ima1_(220, 220); 00031 data::fill(ima1_, literal::cyan); 00032 border::fill(ima1_, literal::yellow); 00033 // Set an infinite extension. 00034 mln_VAR(ima1, extend(ima1_, pw::cst(literal::yellow))); 00035 00036 // Declare the output image. 00037 image2d<value::rgb8> ima2(220, 220); 00038 data::fill(ima2, literal::cyan); 00039 border::fill(ima2, literal::yellow); 00040 00041 box2d extended_domain= ima1.domain(); 00042 extended_domain.enlarge(border::thickness); 00043 00044 // Draw the domain bounding box 00045 draw::box(ima1, geom::bbox(ima1_), literal::red); 00046 // Save the image, including its border. 00047 doc::ppmsave(ima1 | extended_domain, "ima2d-rot"); 00048 00049 // Define and apply a point-wise rotation 00050 fun::x2x::rotation<2,float> rot1(0.5, literal::zero); 00051 image2d<value::rgb8>::fwd_piter p(ima1.domain()); 00052 for_all(p) 00053 { 00054 algebra::vec<2,float> pv = p.to_site().to_vec(); 00055 algebra::vec<2,float> v = rot1.inv()(pv); 00056 ima2(p) = ima1(v); 00057 } 00058 00059 draw::box(ima2, ima2.bbox(), literal::red); 00060 doc::ppmsave(extended_to(ima2, extended_domain), "ima2d-rot"); 00061 // \} 00062 00063 }