core/vil/algo/vil_binary_erode.h

Go to the documentation of this file.
00001 #ifndef vil_binary_erode_h_
00002 #define vil_binary_erode_h_
00003 //:
00004 // \file
00005 // \brief Perform binary erosion on images
00006 // \author Tim Cootes
00007 
00008 #include <vil/algo/vil_structuring_element.h>
00009 #include <vil/vil_image_view.h>
00010 #include <vil/vil_border.h>
00011 
00012 //: Return false if any im[offset[k]] is zero
00013 inline bool vil_binary_erode(const bool* im, const vcl_ptrdiff_t* offset, unsigned n)
00014 {
00015   for (unsigned i=0;i<n;++i) if (!im[offset[i]]) return false;
00016   return true;
00017 }
00018 
00019 //: Return false if any image pixel under element centred at (i0,j0) is zero
00020 //  Checks boundary overlap
00021 template <class imAccessorT>
00022 inline bool vil_binary_erode(const imAccessorT& image, unsigned plane,
00023                              const vil_structuring_element& element, int i0, int j0)
00024 {
00025   unsigned n = element.p_i().size();
00026   for (unsigned int k=0;k<n;++k)
00027   {
00028     unsigned int i = i0+element.p_i()[k];
00029     unsigned int j = j0+element.p_j()[k];
00030     if (!image(i,j,plane))
00031       return false;
00032   }
00033   return true;
00034 }
00035 
00036 //: Erodes src_image to produce dest_image (assumed single plane)
00037 // \relates vil_image_view
00038 // \relates vil_structuring_element
00039 void vil_binary_erode(const vil_image_view<bool>& src_image,
00040                       vil_image_view<bool>& dest_image,
00041                       const vil_structuring_element& element);
00042 
00043 //: Erodes src_image to produce dest_image (assumed single plane)
00044 // \relates vil_image_view
00045 // \relates vil_structuring_element
00046 // \relates vil_border
00047 void vil_binary_erode(const vil_image_view<bool>& src_image,
00048                       vil_image_view<bool>& dest_image,
00049                       const vil_structuring_element& element,
00050                       const vil_border<vil_image_view<bool> >& border);
00051 
00052 #endif // vil_binary_erode_h_

Generated on Sat Nov 22 05:07:50 2008 for core/vil by  doxygen 1.5.1