contrib/mul/vimt/vimt_reflect.h
Go to the documentation of this file.
00001 // This is mul/vimt/vimt_reflect.h
00002 #ifndef vimt_reflect_h_
00003 #define vimt_reflect_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \author Kevin de Souza
00010 // \brief Functions to reflect a vimt_image_2d_of<T>
00011 
00012 
00013 #include <vil/vil_flip.h>
00014 #include <vimt/vimt_image_2d_of.h>
00015 
00016 
00017 //: Reflect an image about the x=0 line (world coords)
00018 template<class T>
00019 inline void vimt_reflect_x(vimt_image_2d_of<T>& img)
00020 {
00021   // Transpose the pixel array. This is equivalent to reflecting about the image centre.
00022   img.image() = vil_flip_lr(img.image());
00023 
00024   // Compose the transform with a translation about the world origin.
00025   vcl_vector<double> bboxmin, bboxmax;
00026   img.world_bounds(bboxmin, bboxmax);
00027   vimt_transform_2d transl;
00028   transl.set_translation(bboxmin[0]+bboxmax[0], 0);
00029   img.world2im() = img.world2im() * transl;
00030 }
00031 
00032 
00033 //: Reflect an image about the y=0 line (world coords)
00034 template<class T>
00035 inline void vimt_reflect_y(vimt_image_2d_of<T>& img)
00036 {
00037   // Transpose the pixel array. This is equivalent to reflecting about the image centre.
00038   img.image() = vil_flip_ud(img.image());
00039 
00040   // Compose the transform with a translation about the world origin.
00041   vcl_vector<double> bboxmin, bboxmax;
00042   img.world_bounds(bboxmin, bboxmax);
00043   vimt_transform_2d transl;
00044   transl.set_translation(0, bboxmin[1]+bboxmax[1]);
00045   img.world2im() = img.world2im() * transl;
00046 }
00047 
00048 
00049 #endif // vimt_reflect_h_