vil_corners.h
Go to the documentation of this file.
1 // This is core/vil/algo/vil_corners.h
2 #ifndef vil_corners_h_
3 #define vil_corners_h_
4 //:
5 // \file
6 // \brief Estimate corner positions using Forstner/Harris approach
7 // \author Tim Cootes
8 
9 #include <vil/vil_image_view.h>
10 #include <vil/algo/vil_sobel_3x3.h>
11 
12 //: Compute Harris corner strength function given gradient images.
13 // grad_i and grad_j are assumed to be the i and j gradient images (single
14 // plane), such as produced by vil_sobel_3x3(). At each pixel compute
15 // the Harris corner function: det(H)-k*sqr(trace(H)), where
16 // H is the 2x2 matrix of second derivatives, generated by applying a Sobel
17 // operator to the gradient images.
18 //
19 // The local peaks of the output image correspond to corner candidates.
20 // \relatesalso vil_image_view
21 void vil_corners(const vil_image_view<float>& grad_i,
22  const vil_image_view<float>& grad_j,
23  vil_image_view<float>& dest, double k=0.04);
24 
25 void vil_corners(const vil_image_view<double>& grad_i,
26  const vil_image_view<double>& grad_j,
27  vil_image_view<double>& dest, double k=0.04);
28 
29 //: Compute corner strength using Rohr's recommended method
30 // This computes the determinant of the matrix C=g.g'
31 // after the elements of C have been smoothed.
32 // g is the vector of first derivatives (gx,gy)'
33 // It relies only on first derivatives.
34 // \relatesalso vil_image_view
35 void vil_corners_rohr(const vil_image_view<float>& grad_i,
36  const vil_image_view<float>& grad_j,
37  vil_image_view<float>& dest);
38 
39 //: Compute Harris corner strength function
40 // At each pixel compute
41 // the Harris corner function: det(H)-k*sqr(trace(H)), where
42 // H is the 2x2 matrix of second derivatives, generated by applying a Sobel
43 // operator twice. The filters thus effectively have 5x5 support.
44 //
45 // The local peaks of the output image correspond to corner candidates.
46 // \relatesalso vil_image_view
47 template<class T>
48 inline
50  vil_image_view<float>& dest, double k=0.04)
51 {
52  vil_image_view<float> grad_i,grad_j;
53  vil_sobel_3x3(src,grad_i,grad_j);
54  vil_corners(grad_i,grad_j,dest,k);
55 }
56 
57 //: Compute corner strength using Karl Rohr's recommended method
58 // This computes the determinant of the matrix C=g.g'
59 // after the elements of C have been smoothed.
60 // g is the vector of first derivatives (gx,gy)'
61 // It relies only on first derivatives.
62 // \relatesalso vil_image_view
63 template<class T>
64 inline
67 {
68  vil_image_view<float> grad_i,grad_j;
69  vil_sobel_3x3(src,grad_i,grad_j);
70  vil_corners_rohr(grad_i,grad_j,dest);
71 }
72 
73 
74 #endif // vil_corners_h_
Concrete view of image data of type T held in memory.
Definition: vil_fwd.h:13
void vil_corners_rohr(const vil_image_view< float > &grad_i, const vil_image_view< float > &grad_j, vil_image_view< float > &dest)
Compute corner strength using Rohr's recommended method.
A base class reference-counting view of some image data.
void vil_corners(const vil_image_view< float > &grad_i, const vil_image_view< float > &grad_j, vil_image_view< float > &dest, double k)
Compute Forstner/Harris corner strength function given gradient images.
Definition: vil_corners.cxx:24
void vil_sobel_3x3(const vil_image_view< srcT > &src, vil_image_view< destT > &grad_i, vil_image_view< destT > &grad_j)
Compute gradients of an image using 3x3 Sobel filters.
Apply 3x3 sobel operator to image data.