Go to the documentation of this file.00001 #ifndef vil3d_abs_shuffle_distance_h_
00002 #define vil3d_abs_shuffle_distance_h_
00003
00004
00005
00006
00007
00008 #include <vil3d/algo/vil3d_structuring_element.h>
00009 #include <vil3d/vil3d_image_view.h>
00010
00011
00012 template <class T1, class T2>
00013 inline double vil3d_abs_shuffle_distance(T1 v0, const T2* im,
00014 const vcl_ptrdiff_t* offset, unsigned n)
00015 {
00016 double min_v = im[offset[0]]<v0?(v0-im[offset[0]]):(im[offset[0]]-v0);
00017 for (unsigned i=1;i<n;++i)
00018 {
00019 T2 v1 = im[offset[i]];
00020 double abs_diff = (v0<v1?(v1-v0):(v0-v1));
00021 if (abs_diff<min_v) min_v=abs_diff;
00022 }
00023 return min_v;
00024 }
00025
00026
00027
00028
00029 template <class T1, class T2>
00030 inline double vil3d_abs_shuffle_distance(T1 v0, const vil3d_image_view<T2>& image,
00031 unsigned plane,
00032 const vil3d_structuring_element& element,
00033 int i0, int j0, int k0)
00034 {
00035 double min_v=9e99;
00036 unsigned n = element.p_i().size();
00037 for (unsigned int m=0;m<n;++m)
00038 {
00039 unsigned int i = i0+element.p_i()[m];
00040 unsigned int j = j0+element.p_j()[m];
00041 unsigned int k = k0+element.p_k()[m];
00042 if (i<image.ni() && j<image.nj() && k<image.nk())
00043 {
00044 T2 v1 = image(i,j,k,plane);
00045 double abs_diff = (v0<v1?(v1-v0):(v0-v1));
00046 if (abs_diff < min_v) { min_v = abs_diff; }
00047 }
00048 }
00049 return min_v;
00050 }
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061 template <class T1, class T2>
00062 double vil3d_abs_shuffle_distance(const vil3d_image_view<T1>& image1,
00063 const vil3d_image_view<T2>& image2,
00064 const vil3d_structuring_element& element,
00065 bool include_borders=true);
00066
00067
00068
00069
00070
00071
00072
00073
00074 template <class T1, class T2>
00075 void vil3d_abs_shuffle_distance(const vil3d_image_view<T1>& image1,
00076 const vil3d_image_view<T2>& image2,
00077 const vil3d_structuring_element& element,
00078 vil3d_image_view<T1>& image3);
00079
00080 #endif // vil3d_abs_shuffle_distance_h_