contrib/mul/vimt3d/vimt3d_reflect.h
Go to the documentation of this file.
00001 // This is mul/vimt3d/vimt3d_reflect.h
00002 #ifndef vimt3d_reflect_h_
00003 #define vimt3d_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 vimt3d_image_3d_of<T>
00011 
00012 
00013 #include <vil3d/vil3d_reflect.h>
00014 #include <vimt3d/vimt3d_image_3d_of.h>
00015 
00016 
00017 //: Reflect an image about the x=0 plane (world coords)
00018 template<class T>
00019 inline void vimt3d_reflect_x(vimt3d_image_3d_of<T>& img)
00020 {
00021   // Transpose the voxel array. This is equivalent to reflecting about the image centre.
00022   img.image() = vil3d_reflect_i(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   vimt3d_transform_3d transl;
00028   transl.set_translation(bboxmin[0]+bboxmax[0], 0, 0);
00029   img.world2im() = img.world2im() * transl;
00030 }
00031 
00032 
00033 //: Reflect an image about the y=0 plane (world coords)
00034 template<class T>
00035 inline void vimt3d_reflect_y(vimt3d_image_3d_of<T>& img)
00036 {
00037   // Transpose the voxel array. This is equivalent to reflecting about the image centre.
00038   img.image() = vil3d_reflect_j(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   vimt3d_transform_3d transl;
00044   transl.set_translation(0, bboxmin[1]+bboxmax[1], 0);
00045   img.world2im() = img.world2im() * transl;
00046 }
00047 
00048 
00049 //: Reflect an image about the z=0 plane (world coords)
00050 template<class T>
00051 inline void vimt3d_reflect_z(vimt3d_image_3d_of<T>& img)
00052 {
00053   // Transpose the voxel array. This is equivalent to reflecting about the image centre.
00054   img.image() = vil3d_reflect_k(img.image());
00055 
00056   // Compose the transform with a translation about the world origin.
00057   vcl_vector<double> bboxmin, bboxmax;
00058   img.world_bounds(bboxmin, bboxmax);
00059   vimt3d_transform_3d transl;
00060   transl.set_translation(0, 0, bboxmin[2]+bboxmax[2]);
00061   img.world2im() = img.world2im() * transl;
00062 }
00063 
00064 
00065 #endif // vimt3d_reflect_h_