Go to the documentation of this file.00001 #ifndef vil_abs_shuffle_distance_h_
00002 #define vil_abs_shuffle_distance_h_
00003
00004
00005
00006
00007
00008 #include <vil/algo/vil_structuring_element.h>
00009 #include <vil/vil_image_view.h>
00010
00011
00012 template <class T1, class T2>
00013 inline double vil_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
00030
00031 template <class T1, class T2>
00032 inline double vil_abs_shuffle_distance(T1 v0, const vil_image_view<T2>& image,
00033 unsigned plane,
00034 const vil_structuring_element& element,
00035 int i0, int j0)
00036 {
00037 double min_v=9e99;
00038 unsigned n = element.p_i().size();
00039 for (unsigned int k=0;k<n;++k)
00040 {
00041 unsigned int i = i0+element.p_i()[k];
00042 unsigned int j = j0+element.p_j()[k];
00043 if (i<image.ni() && j<image.nj())
00044 {
00045 T2 v1 = image(i,j,plane);
00046 double abs_diff = (v0<v1?(v1-v0):(v0-v1));
00047 if (abs_diff < min_v) { min_v = abs_diff; }
00048 }
00049 }
00050 return min_v;
00051 }
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062 template <class T1, class T2>
00063 double vil_abs_shuffle_distance(const vil_image_view<T1>& image1,
00064 const vil_image_view<T2>& image2,
00065 const vil_structuring_element& element,
00066 bool include_borders=true);
00067
00068 #endif // vil_abs_shuffle_distance_h_