Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

brip_para_cvrg.h

Go to the documentation of this file.
00001 #ifndef brip_para_cvrg_h
00002 #define brip_para_cvrg_h
00003 //-----------------------------------------------------------------------------
00004 //:
00005 // \file
00006 // \author  Joe Mundy July 31, 1999
00007 // \brief brip_para_cvrg - Detection of parallel image features
00008 //
00009 //    A detector for parallel lines. The algorithm uses a 4 direction set
00010 //   of gradient filters (0, 45, 90, 135 degrees) to detect linear steps.
00011 //   The steps are then projected onto an accumulation array oriented
00012 //   perpendicular to the direction of the linear feature. The projection
00013 //   is carried out in each of the four orientations at each pixel, using
00014 //   the approriate gradient image.
00015 //    Parallel support is defined as the existence of two or more peaks in
00016 //   the projection array. The peaks are found by carrying out non-maximal
00017 //   suppression on the projection array. This parallel coverage is quantified
00018 //   by computing the average peak height.  If there are not at least two
00019 //   peaks, the "coverage" is defined as zero.
00020 //    The direction with maximum coverage value is determined and that
00021 //   value is inserted an output image called the cover_image.
00022 //
00023 //   The current algorithm has a performance of about 1.8*10^4 pixels/sec
00024 //   The bulk of the time is taken in doing the projections.
00025 //
00026 //
00027 // \verbatim
00028 // Modifications:
00029 //   Ported to vxl July 01, 2004
00030 // \endverbatim
00031 //-----------------------------------------------------------------------------
00032 
00033 #include <brip/brip_para_cvrg_params.h>
00034 #include <vil1/vil1_rgb.h>
00035 #include <vil1/vil1_image.h>
00036 #include <vil1/vil1_memory_image_of.h>
00037 class brip_para_cvrg : public brip_para_cvrg_params
00038 {
00039   // PUBLIC INTERFACE----------------------------------------------------------
00040 
00041  public:
00042 
00043   // Constructors/Initializers/Destructors-------------------------------------
00044   brip_para_cvrg(float sigma = 1.0, float low = 6,
00045                float gauss_tail = .05,
00046                int proj_width = 7, int proj_height=1,
00047                int sup_radius = 1,
00048                bool verbose = true);
00049 
00050   brip_para_cvrg(brip_para_cvrg_params& pdp);
00051   ~brip_para_cvrg();
00052   void do_coverage(vil1_image const& image);
00053 
00054   // Data Access---------------------------------------------------------------
00055   vil1_memory_image_of<float> get_float_detection_image(const float max = 255);
00056   vil1_memory_image_of<unsigned char> get_detection_image();
00057   vil1_memory_image_of<unsigned char> get_dir_image();
00058   vil1_memory_image_of<vil1_rgb<unsigned char> > get_combined_image();
00059   // Utility Methods
00060  private:
00061   void init(vil1_image const& image);
00062   void init_variables();
00063   float **make_float_image(int m , int n); //A m x n array m = xsize;
00064   void free_float_image(float** image);
00065   float *make_float_vector(int size);
00066   void set_float_vector(float* vector, int size, float val);
00067   void set_float_image(float**,float);
00068   void copy_image(float**,float**);
00069   void set_kernel();
00070   void smooth_image();
00071   void avg(int x, int y, vil1_memory_image_of<float> const& smooth, float** avg);
00072   void grad0(int x, int y, vil1_memory_image_of<float> const& smooth, float** grad0);
00073   void grad45(int x, int y, vil1_memory_image_of<float> const& smooth, float** grad45);
00074   void grad90(int x, int y, vil1_memory_image_of<float> const& smooth, float** grad90);
00075   void grad135(int x, int y, vil1_memory_image_of<float> const& smooth, float** grad135);
00076   void compute_gradients();
00077   float project(int x, int y, int dir, float* projection);
00078   void remove_flat_peaks(int n, float* array);
00079   void non_maximum_supress(float* array, float* sup_array);
00080   float parallel_coverage(float* sup_array);
00081   void compute_parallel_coverage();
00082   void compute_image(float** data, vil1_memory_image_of<unsigned char>& image);
00083   //
00084   // Members
00085   int proj_n_;         // Number of pixels in the projection array
00086   int width_;          // The smoothing kernel width
00087   int k_size_;         // The kernel is 2*_width+1
00088   float *kernel_;      // 1-Dimensional convolution kernel of size k_size
00089 
00090   int xstart_, ystart_; // The origin of the buffer in the image
00091   int xsize_, ysize_;   // The width of the image buffer
00092   vil1_memory_image_of<float> smooth_;       // The smoothed image
00093   float **avg_;       // average intensity
00094   float **grad0_;       // Derivative images in 45 degree increments
00095   float **grad45_;
00096   float **grad90_;
00097   float **grad135_;
00098   float **det_;        //The resulting detector value
00099   float **dir_;        //The direction of maximum detection amplitude
00100   //A memory image of the detected pattern
00101   vil1_memory_image_of<unsigned char> det_image_;
00102   //A memory image of the max pattern orientation
00103   vil1_memory_image_of<unsigned char> dir_image_;
00104   vil1_memory_image_of<float> image_;
00105   float* sup_proj_;     //A 1-d array for maximal suppression
00106   float* proj_0_;       //1d arrays for projecting the gradient magnitude
00107   float* proj_45_;
00108   float* proj_90_;
00109   float* proj_135_;
00110 };
00111 
00112 #endif

Generated on Thu Jan 10 14:52:30 2008 for contrib/brl/bseg/brip by  doxygen 1.4.4