1 /*
2 Copyright 2005-2007 Adobe Systems Incorporated
3
4 Use, modification and distribution are subject to the Boost Software License,
5 Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6 http://www.boost.org/LICENSE_1_0.txt).
7
8 See http://opensource.adobe.com/gil for most recent version including documentation.
9 */
10
11 /*************************************************************************************************/
12
13 ///////////////////////
14 //// NOTE: This sample file uses the numeric extension, which does not come with the Boost distribution.
15 //// You may download it from http://opensource.adobe.com/gil
16 ///////////////////////
17
18 /// \file
19 /// \brief Test file for resample_pixels() in the numeric extension
20 /// \author Lubomir Bourdev and Hailin Jin
21 /// \date February 27, 2007
22
23 #include <boost/gil/image.hpp>
24 #include <boost/gil/typedefs.hpp>
25 #include <boost/gil/extension/io/jpeg_io.hpp>
26 #include <boost/gil/extension/numeric/sampler.hpp>
27 #include <boost/gil/extension/numeric/resample.hpp>
28
main()29 int main() {
30 using namespace boost::gil;
31
32 rgb8_image_t img;
33 jpeg_read_image("test.jpg",img);
34
35 // test resample_pixels
36 // Transform the image by an arbitrary affine transformation using nearest-neighbor resampling
37 rgb8_image_t transf(rgb8_image_t::point_t(view(img).dimensions()*2));
38 fill_pixels(view(transf),rgb8_pixel_t(255,0,0)); // the background is red
39
40 matrix3x2<double> mat = matrix3x2<double>::get_translate(-point2<double>(200,250)) *
41 matrix3x2<double>::get_rotate(-15*3.14/180.0);
42 resample_pixels(const_view(img), view(transf), mat, nearest_neighbor_sampler());
43 jpeg_write_view("out-affine.jpg", view(transf));
44
45 return 0;
46 }
47