Go to the documentation of this file.00001
00002 #ifndef vil_find_plateaus_h_
00003 #define vil_find_plateaus_h_
00004
00005
00006
00007
00008
00009 #include <vil/vil_image_view.h>
00010 #include <vcl_vector.h>
00011
00012
00013
00014 template <class T>
00015 inline bool vil_is_plateau_3x3(const T* im, vcl_ptrdiff_t i_step, vcl_ptrdiff_t j_step)
00016 {
00017 T v = *im;
00018 return v >= im[i_step]
00019 && v >= im[-i_step]
00020 && v >= im[j_step]
00021 && v >= im[-j_step]
00022 && v >= im[i_step+j_step]
00023 && v >= im[i_step-j_step]
00024 && v >= im[j_step-i_step]
00025 && v >= im[-i_step-j_step];
00026 }
00027
00028
00029
00030
00031
00032
00033 template <class T>
00034 inline void vil_find_plateaus_3x3(vcl_vector<unsigned>& pi,
00035 vcl_vector<unsigned>& pj,
00036 const vil_image_view<T>& image,
00037 const T& min_thresh,
00038 bool clear_list=true)
00039 {
00040 if (clear_list) {
00041 pi.resize(0);
00042 pj.resize(0);
00043 }
00044 const unsigned ni1=image.ni()-1,nj1=image.nj()-1;
00045 const vcl_ptrdiff_t istep = image.istep(),jstep=image.jstep();
00046 const T* row = image.top_left_ptr()+istep+jstep;
00047 for (unsigned j=1;j<nj1;++j,row+=jstep)
00048 {
00049 const T* pixel = row;
00050 for (unsigned i=1;i<ni1;++i,pixel+=istep)
00051 if (*pixel>=min_thresh && vil_is_plateau_3x3(pixel,istep,jstep))
00052 {
00053 pi.push_back(i);
00054 pj.push_back(j);
00055 }
00056 }
00057 }
00058
00059 #endif // vil_find_plateaus_h_