00001 // This is core/vil/algo/vil_suppress_non_max_edges.h 00002 #ifndef vil_suppress_non_max_edges_h_ 00003 #define vil_suppress_non_max_edges_h_ 00004 //: 00005 // \file 00006 // \brief Given gradient image, compute magnitude and zero any non-maximal values 00007 // \author Tim Cootes 00008 // 00009 // \verbatim 00010 // Modifications 00011 // Matt Leotta - Aug 22, 2008 - Added a parabolic subpixel version 00012 // \endverbatim 00013 00014 #include <vil/vil_image_view.h> 00015 00016 //: Given gradient images, computes magnitude image containing maximal edges 00017 // Computes magnitude image. Zeros any below a threshold. 00018 // Points with magnitude above a threshold are tested against gradient 00019 // along normal to the edge and retained only if they are higher than 00020 // their neighbours. 00021 // 00022 // Note: Currently assumes single plane only. 00023 // 2 pixel border around output set to zero. 00024 // If two neighbouring edges have exactly the same strength, it retains 00025 // both (ie an edge is eliminated if it is strictly lower than a neighbour, 00026 // but not if it is the same as two neighbours). 00027 // 00028 // \relatesalso vil_image_view 00029 template<class srcT, class destT> 00030 void vil_suppress_non_max_edges(const vil_image_view<srcT>& grad_i, 00031 const vil_image_view<srcT>& grad_j, 00032 double grad_mag_threshold, 00033 vil_image_view<destT>& grad_mag); 00034 00035 00036 //: Given gradient images, computes a subpixel edgemap with magnitudes and orientations 00037 // Computes magnitude image. Zeros any below a threshold. 00038 // Points with magnitude above a threshold are tested against gradient 00039 // along normal to the edge and retained only if they are higher than 00040 // their neighbours. The magnitude of retained points is revised using 00041 // parabolic interpolation in the normal direction. The same interpolation 00042 // provides a subpixel offset from the integral pixel location. 00043 // 00044 // This algorithm returns a 3-plane image where the planes are: 00045 // - 0 - The interpolated peak magnitude 00046 // - 1 - The orientation (in radians) 00047 // - 2 - The offset to the subpixel peak in the gradient direction 00048 // All non-maximal edge pixel have the value zero in all three planes. 00049 // \sa vil_orientations_at_edges 00050 // 00051 // The subpixel location for pixel (i,j) is computed as 00052 // \code 00053 // double theta = grad_mag_orient_offset(i,j,1); 00054 // double offset = grad_mag_orient_offset(i,j,2); 00055 // double x = i + vcl_cos(theta)*offset; 00056 // double y = j + vcl_sin(theta)*offset; 00057 // \endcode 00058 // 00059 // Note: Currently assumes single plane only. 00060 // 2 pixel border around output set to zero. 00061 // If two neighbouring edges have exactly the same strength, it retains 00062 // both (ie an edge is eliminated if it is strictly lower than a neighbour, 00063 // but not if it is the same as two neighbours). 00064 // 00065 // \relatesalso vil_image_view 00066 template<class srcT, class destT> 00067 void vil_suppress_non_max_edges_subpixel(const vil_image_view<srcT>& grad_i, 00068 const vil_image_view<srcT>& grad_j, 00069 double grad_mag_threshold, 00070 vil_image_view<destT>& grad_mag_orient_offset); 00071 00072 #endif // vil_suppress_non_max_edges_h_