#include <iostream>
#include <boost/gil/gil_all.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/gil/typedefs.hpp>
#include <boost/gil/extension/dynamic_image/any_image.hpp>
#include <boost/gil/image_view.hpp>
#include <boost/gil/planar_pixel_reference.hpp>
#include <boost/gil/color_convert.hpp>
#include <boost/gil/typedefs.hpp>
#include <boost/gil/image_view_factory.hpp>
#ifndef BOOST_GIL_NO_IO
#include <boost/gil/extension/io/jpeg_io.hpp>
#include <boost/gil/extension/io/jpeg_dynamic_io.hpp>
#include <boost/gil/extension/io/tiff_io.hpp>
#include <boost/gil/extension/io/tiff_dynamic_io.hpp>
#endif
using namespace boost::gil;
class image_crop
{
rgb8_view_t view_;
public:
image_crop( rgb8_view_t v )
: view_( v ) {}
void crop(int x, int y, int width, int height, image_crop& out) {
rgb8_image_t s( width, height );
copy_pixels( subimage_view( view_
, x
, y
, width
, height
)
, view( s )
);
out.view_ = view( s );
}
rgb8_view_t& get_result_view() {
return view_;
}
};
int main ( int argc , char **argv)
{
rgb8_image_t img;
tiff_read_image("C:\\Users\\Renato Tegon Forti\\Desktop\\cropimage\\test.tif", img);
image_crop i( view( img ) );
image_crop out( view( img ) );
i.crop(644, 288, 300, 20, out );
tiff_write_view("C:\\Users\\Renato Tegon Forti\\Desktop\\cropimage\\out.tif",out.get_result_view());
return 0;