core/vil/algo/vil_orientations.h
Go to the documentation of this file.
00001 #ifndef vil_orientations_h_
00002 #define vil_orientations_h_
00003 //:
00004 // \file
00005 // \brief Functions to compute orientations and gradient magnitude
00006 // \author Tim Cootes
00007 
00008 #include <vil/vil_image_view.h>
00009 #include <vxl_config.h>
00010 #include <vil/algo/vil_sobel_3x3.h>
00011 
00012 //: Compute orientation (in radians) and gradient magnitude at each pixel
00013 //  Images assumed to be single plane
00014 // \relatesalso vil_image_view
00015 void vil_orientations(const vil_image_view<float>& grad_i,
00016                       const vil_image_view<float>& grad_j,
00017                       vil_image_view<float>& orient_im,
00018                       vil_image_view<float>& grad_mag);
00019 
00020 //: Compute discrete orientation and gradient magnitude at each pixel
00021 //  Computes orientation at each pixel and scales to range [0,n_orientations-1].
00022 //
00023 //  Orientation of i corresponds to angles in range [(i-0.5)dA,(i+0.5)dA]
00024 //  where dA=2*pi/n_orientations.
00025 //
00026 //  Images assumed to be single plane
00027 // \relatesalso vil_image_view
00028 void vil_orientations(const vil_image_view<float>& grad_i,
00029                       const vil_image_view<float>& grad_j,
00030                       vil_image_view<vxl_byte>& orient_im,
00031                       vil_image_view<float>& grad_mag,
00032                       unsigned n_orientations=256);
00033 
00034 //: Compute discrete orientation and gradient magnitude at edge pixels
00035 //  Computes orientation at each pixel and scales to range [0,n_orientations].
00036 //  If gradient magnitude is less than grad_threshold, then orientation
00037 //  of zero is set, meaning undefined orientation.
00038 //
00039 //  Orientation of i>0 corresponds to angles in range [(i-1.5)dA,(i-0.5)dA]
00040 //  where dA=2*pi/n_orientations.
00041 //
00042 //  Images assumed to be single plane
00043 // \relatesalso vil_image_view
00044 void vil_orientations_at_edges(const vil_image_view<float>& grad_i,
00045                                const vil_image_view<float>& grad_j,
00046                                vil_image_view<vxl_byte>& orient_im,
00047                                vil_image_view<float>& grad_mag,
00048                                float grad_threshold,
00049                                unsigned n_orientations=255);
00050 
00051 //: Compute orientation and gradient magnitude using sobel to get gradients
00052 // \relatesalso vil_image_view
00053 template <class T>
00054 inline void vil_orientations_from_sobel(const vil_image_view<T>& src_image,
00055                                         vil_image_view<float>& orient_im,
00056                                         vil_image_view<float>& grad_mag)
00057 {
00058   vil_image_view<float> grad_i,grad_j;
00059   vil_sobel_3x3(src_image,grad_i,grad_j);
00060   vil_orientations(grad_i,grad_j,orient_im,grad_mag);
00061 }
00062 
00063 //: Compute discrete orientation and gradient using sobel operations
00064 //  Computes orientation at each pixel and scales to range [0,n_orientations-1].
00065 //
00066 //  Orientation of i corresponds to angles in range [(i-0.5)dA,(i+0.5)dA]
00067 //  where dA=2*pi/n_orientations.
00068 //
00069 //  Images assumed to be single plane
00070 // \relatesalso vil_image_view
00071 template <class T>
00072 inline void vil_orientations_from_sobel(const vil_image_view<T>& src_image,
00073                                         vil_image_view<vxl_byte>& orient_im,
00074                                         vil_image_view<float>& grad_mag,
00075                                         unsigned n_orientations=256)
00076 {
00077   vil_image_view<float> grad_i,grad_j;
00078   vil_sobel_3x3(src_image,grad_i,grad_j);
00079   vil_orientations(grad_i,grad_j,orient_im,grad_mag,n_orientations);
00080 }
00081 
00082 #endif // vil_orientations_h_