Go to the documentation of this file.00001
00002 #ifndef vil_suppress_non_plateau_h_
00003 #define vil_suppress_non_plateau_h_
00004
00005
00006
00007
00008
00009 #include <vil/vil_image_view.h>
00010 #include <vil/algo/vil_find_plateaus.h>
00011 #include <vil/vil_fill.h>
00012 #include <vcl_cassert.h>
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 template <class T>
00026 inline void vil_suppress_non_plateau_3x3(const vil_image_view<T>& src_im,
00027 vil_image_view<T>& dest_im,
00028 T threshold=0, T non_max_value=0)
00029 {
00030 unsigned ni=src_im.ni(),nj=src_im.nj();
00031 assert(src_im.nplanes()==1);
00032
00033 dest_im.set_size(ni,nj,1);
00034
00035 vcl_ptrdiff_t istep = src_im.istep(),jstep=src_im.jstep();
00036 vcl_ptrdiff_t distep = dest_im.istep(),djstep=dest_im.jstep();
00037 const T* row = src_im.top_left_ptr()+istep+jstep;
00038 T* drow = dest_im.top_left_ptr()+distep+djstep;
00039 for (unsigned j=1;j<nj-1;++j,row+=jstep,drow+=djstep)
00040 {
00041 const T* pixel = row;
00042 T* dpixel = drow;
00043 for (unsigned i=1;i<ni-1;++i,pixel+=istep,dpixel+=distep)
00044 {
00045 if (*pixel<threshold || !vil_is_plateau_3x3(pixel,istep,jstep))
00046 *dpixel = non_max_value;
00047 else
00048 *dpixel = *pixel;
00049 }
00050 }
00051
00052
00053 vil_fill_row(dest_im,0,non_max_value);
00054 vil_fill_row(dest_im,nj-1,non_max_value);
00055 vil_fill_col(dest_im,0,non_max_value);
00056 vil_fill_col(dest_im,ni-1,non_max_value);
00057 }
00058
00059 #endif // vil_suppress_non_plateau_h_