contrib/mul/vil3d/vil3d_reflect.h
Go to the documentation of this file.
00001 // This is mul/vil3d/vil3d_reflect.h
00002 #ifndef vil3d_reflect_h_
00003 #define vil3d_reflect_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \author Kevin de Souza, Ian Scott.
00010 // \brief functions to create a reflected image view
00011 
00012 
00013 #include <vil3d/vil3d_image_view.h>
00014 
00015 
00016 //: Create a reflected view in which i -> ni-1-i.
00017 //  i.e. vil3d_reflect_i(view)(i, j, k, p) = view(ni-1-i, j, k, p)
00018 //  O(1).
00019 // \relatesalso vil3d_image_view
00020 template<class T>
00021 inline vil3d_image_view<T> vil3d_reflect_i(const vil3d_image_view<T>& v)
00022 {
00023   return vil3d_image_view<T>(v.memory_chunk(),
00024                              v.origin_ptr()+(v.ni()-1)*v.istep(),
00025                              v.ni(), v.nj(), v.nk(), v.nplanes(),
00026                              -v.istep(), v.jstep(), v.kstep(), v.planestep());
00027 }
00028 
00029 
00030 //: Create a reflected view in which j -> nj-1-j.
00031 //  i.e. vil3d_reflect_j(view)(i, j, k, p) = view(i, nj-1-j, k, p)
00032 //  O(1).
00033 // \relatesalso vil3d_image_view
00034 template<class T>
00035 inline vil3d_image_view<T> vil3d_reflect_j(const vil3d_image_view<T>& v)
00036 {
00037   return vil3d_image_view<T>(v.memory_chunk(),
00038                              v.origin_ptr()+(v.nj()-1)*v.jstep(),
00039                              v.ni(), v.nj(), v.nk(), v.nplanes(),
00040                              v.istep(), -v.jstep(), v.kstep(), v.planestep());
00041 }
00042 
00043 
00044 //: Create a reflected view in which k -> nk-1-k.
00045 //  i.e. vil3d_reflect_k(view)(i, j, k, p) = view(i, j, nk-1-k, p)
00046 //  O(1).
00047 // \relatesalso vil3d_image_view
00048 template<class T>
00049 inline vil3d_image_view<T> vil3d_reflect_k(const vil3d_image_view<T>& v)
00050 {
00051   return vil3d_image_view<T>(v.memory_chunk(),
00052                              v.origin_ptr()+(v.nk()-1)*v.kstep(),
00053                              v.ni(), v.nj(), v.nk(), v.nplanes(),
00054                              v.istep(), v.jstep(), -v.kstep(), v.planestep());
00055 }
00056 
00057 
00058 #endif // vil3d_reflect_h_