core/vil/algo/vil_corners.h
Go to the documentation of this file.
00001 // This is core/vil/algo/vil_corners.h
00002 #ifndef vil_corners_h_
00003 #define vil_corners_h_
00004 //:
00005 // \file
00006 // \brief Estimate corner positions using Forstner/Harris approach
00007 // \author Tim Cootes
00008 
00009 #include <vil/vil_image_view.h>
00010 #include <vil/algo/vil_sobel_3x3.h>
00011 
00012 //: Compute Harris corner strength function given gradient images.
00013 //  grad_i and grad_j are assumed to be the i and j gradient images (single
00014 //  plane), such as produced by vil_sobel_3x3().  At each pixel compute
00015 //  the Harris corner function: det(H)-k*sqr(trace(H)), where
00016 //  H is the 2x2 matrix of second derivatives, generated by applying a Sobel
00017 //  operator to the gradient images.
00018 //
00019 //  The local peaks of the output image correspond to corner candidates.
00020 // \relatesalso vil_image_view
00021 void vil_corners(const vil_image_view<float>& grad_i,
00022                  const vil_image_view<float>& grad_j,
00023                  vil_image_view<float>& dest, double k=0.04);
00024 
00025 void vil_corners(const vil_image_view<double>& grad_i,
00026                  const vil_image_view<double>& grad_j,
00027                  vil_image_view<double>& dest, double k=0.04);
00028 
00029 //: Compute corner strength using Rohr's recommended method
00030 //  This computes the determinant of the matrix C=g.g'
00031 //  after the elements of C have been smoothed.
00032 //  g is the vector of first derivatives (gx,gy)'
00033 //  It relies only on first derivatives.
00034 // \relatesalso vil_image_view
00035 void vil_corners_rohr(const vil_image_view<float>& grad_i,
00036                       const vil_image_view<float>& grad_j,
00037                       vil_image_view<float>& dest);
00038 
00039 //: Compute Harris corner strength function
00040 //  At each pixel compute
00041 //  the Harris corner function: det(H)-k*sqr(trace(H)), where
00042 //  H is the 2x2 matrix of second derivatives, generated by applying a Sobel
00043 //  operator twice.  The filters thus effectively have 5x5 support.
00044 //
00045 //  The local peaks of the output image correspond to corner candidates.
00046 // \relatesalso vil_image_view
00047 template<class T>
00048 inline
00049 void vil_corners(const vil_image_view<T>& src,
00050                  vil_image_view<float>& dest, double k=0.04)
00051 {
00052   vil_image_view<float> grad_i,grad_j;
00053   vil_sobel_3x3(src,grad_i,grad_j);
00054   vil_corners(grad_i,grad_j,dest,k);
00055 }
00056 
00057 //: Compute corner strength using Karl Rohr's recommended method
00058 //  This computes the determinant of the matrix C=g.g'
00059 //  after the elements of C have been smoothed.
00060 //  g is the vector of first derivatives (gx,gy)'
00061 //  It relies only on first derivatives.
00062 // \relatesalso vil_image_view
00063 template<class T>
00064 inline
00065 void vil_corners_rohr(const vil_image_view<T>& src,
00066                       vil_image_view<float>& dest)
00067 {
00068   vil_image_view<float> grad_i,grad_j;
00069   vil_sobel_3x3(src,grad_i,grad_j);
00070   vil_corners_rohr(grad_i,grad_j,dest);
00071 }
00072 
00073 
00074 #endif // vil_corners_h_