vil_orientations.h
Go to the documentation of this file.
1 #ifndef vil_orientations_h_
2 #define vil_orientations_h_
3 //:
4 // \file
5 // \brief Functions to compute orientations and gradient magnitude
6 // \author Tim Cootes
7 
8 #include <vil/vil_image_view.h>
9 #include <vxl_config.h>
10 #include <vil/algo/vil_sobel_3x3.h>
11 
12 //: Compute orientation (in radians) and gradient magnitude at each pixel
13 // Images assumed to be single plane
14 // \relatesalso vil_image_view
15 void vil_orientations(const vil_image_view<float>& grad_i,
16  const vil_image_view<float>& grad_j,
17  vil_image_view<float>& orient_im,
18  vil_image_view<float>& grad_mag);
19 
20 //: Compute discrete orientation and gradient magnitude at each pixel
21 // Computes orientation at each pixel and scales to range [0,n_orientations-1].
22 //
23 // Orientation of i corresponds to angles in range [(i-0.5)dA,(i+0.5)dA]
24 // where dA=2*pi/n_orientations.
25 //
26 // Images assumed to be single plane
27 // \relatesalso vil_image_view
28 void vil_orientations(const vil_image_view<float>& grad_i,
29  const vil_image_view<float>& grad_j,
30  vil_image_view<vxl_byte>& orient_im,
31  vil_image_view<float>& grad_mag,
32  unsigned n_orientations=256);
33 
34 //: Compute discrete orientation and gradient magnitude at edge pixels
35 // Computes orientation at each pixel and scales to range [0,n_orientations].
36 // If gradient magnitude is less than grad_threshold, then orientation
37 // of zero is set, meaning undefined orientation.
38 //
39 // Orientation of i>0 corresponds to angles in range [(i-1.5)dA,(i-0.5)dA]
40 // where dA=2*pi/n_orientations.
41 //
42 // Images assumed to be single plane
43 // \relatesalso vil_image_view
45  const vil_image_view<float>& grad_j,
46  vil_image_view<vxl_byte>& orient_im,
47  vil_image_view<float>& grad_mag,
48  float grad_threshold,
49  unsigned n_orientations=255);
50 
51 //: Compute orientation and gradient magnitude using sobel to get gradients
52 // \relatesalso vil_image_view
53 template <class T>
54 inline void vil_orientations_from_sobel(const vil_image_view<T>& src_image,
55  vil_image_view<float>& orient_im,
56  vil_image_view<float>& grad_mag)
57 {
58  vil_image_view<float> grad_i,grad_j;
59  vil_sobel_3x3(src_image,grad_i,grad_j);
60  vil_orientations(grad_i,grad_j,orient_im,grad_mag);
61 }
62 
63 //: Compute discrete orientation and gradient using sobel operations
64 // Computes orientation at each pixel and scales to range [0,n_orientations-1].
65 //
66 // Orientation of i corresponds to angles in range [(i-0.5)dA,(i+0.5)dA]
67 // where dA=2*pi/n_orientations.
68 //
69 // Images assumed to be single plane
70 // \relatesalso vil_image_view
71 template <class T>
72 inline void vil_orientations_from_sobel(const vil_image_view<T>& src_image,
73  vil_image_view<vxl_byte>& orient_im,
74  vil_image_view<float>& grad_mag,
75  unsigned n_orientations=256)
76 {
77  vil_image_view<float> grad_i,grad_j;
78  vil_sobel_3x3(src_image,grad_i,grad_j);
79  vil_orientations(grad_i,grad_j,orient_im,grad_mag,n_orientations);
80 }
81 
82 #endif // vil_orientations_h_
Concrete view of image data of type T held in memory.
Definition: vil_fwd.h:13
void vil_orientations_at_edges(const vil_image_view< float > &grad_i, const vil_image_view< float > &grad_j, vil_image_view< vxl_byte > &orient_im, vil_image_view< float > &grad_mag, float grad_threshold, unsigned n_orientations=255)
Compute discrete orientation and gradient magnitude at edge pixels.
A base class reference-counting view of some image data.
void vil_orientations(const vil_image_view< float > &grad_i, const vil_image_view< float > &grad_j, vil_image_view< float > &orient_im, vil_image_view< float > &grad_mag)
Compute orientation (in radians) and gradient magnitude at each pixel.
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.
void vil_orientations_from_sobel(const vil_image_view< T > &src_image, vil_image_view< float > &orient_im, vil_image_view< float > &grad_mag)
Compute orientation and gradient magnitude using sobel to get gradients.
Apply 3x3 sobel operator to image data.