/Src/Dependencies/Boost/libs/gil/example/affine.cpp

http://hadesmem.googlecode.com/ · C++ · 46 lines · 17 code · 9 blank · 20 comment · 0 complexity · d77ce0f3750687d109e3601f2b140c4a MD5 · raw file

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