Go to the documentation of this file.00001 #ifndef vil_greyscale_erode_h_
00002 #define vil_greyscale_erode_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 T>
00013 inline T vil_greyscale_erode(const T* im, const vcl_ptrdiff_t* offset, unsigned n)
00014 {
00015 T min_v = im[offset[0]];
00016 for (unsigned i=1;i<n;++i)
00017 if (im[offset[i]]<min_v) min_v=im[offset[i]];
00018 return min_v;
00019 }
00020
00021
00022
00023
00024
00025 template <class T>
00026 inline T vil_greyscale_erode(const vil_image_view<T>& image, unsigned plane,
00027 const vil_structuring_element& element,
00028 int i0, int j0)
00029 {
00030 T min_v = T(0);
00031 bool first=true;
00032 unsigned n = element.p_i().size();
00033 for (unsigned int k=0;k<n;++k)
00034 {
00035 unsigned int i = i0+element.p_i()[k];
00036 unsigned int j = j0+element.p_j()[k];
00037 if (i<image.ni() && j<image.nj())
00038 {
00039 if (first || image(i,j,plane) < min_v) {
00040 min_v=image(i,j,plane); first=false; }
00041 }
00042 }
00043 return min_v;
00044 }
00045
00046
00047
00048
00049
00050
00051 template <class T>
00052 void vil_greyscale_erode(const vil_image_view<T>& src_image,
00053 vil_image_view<T>& dest_image,
00054 const vil_structuring_element& element);
00055
00056 #endif // vil_greyscale_erode_h_