lm_filter_bank.h
Go to the documentation of this file.
00001 /*********************************************************************
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2010, Georgia Institute of Technology
00005  *  All rights reserved.
00006  *
00007  *  Redistribution and use in source and binary forms, with or without
00008  *  modification, are permitted provided that the following conditions
00009  *  are met:
00010  *
00011  *   * Redistributions of source code must retain the above copyright
00012  *     notice, this list of conditions and the following disclaimer.
00013  *   * Redistributions in binary form must reproduce the above
00014  *     copyright notice, this list of conditions and the following
00015  *     disclaimer in the documentation and/or other materials provided
00016  *     with the distribution.
00017  *   * Neither the name of the Georgia Institute of Technology nor the names of
00018  *     its contributors may be used to endorse or promote products derived
00019  *     from this software without specific prior written permission.
00020  *
00021  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032  *  POSSIBILITY OF SUCH DAMAGE.
00033  *********************************************************************/
00034 
00035 #ifndef lm_filter_bank_h_DEFINED
00036 #define lm_filter_bank_h_DEFINED
00037 
00038 #include <ros/common.h> // include ROS_ASSERT
00039 #include <opencv2/core/core.hpp>
00040 #include <opencv2/imgproc/imgproc.hpp>
00041 #include <opencv2/highgui/highgui.hpp>
00042 #include <vector>
00043 #include <iostream>
00044 #include <string>
00045 
00046 namespace cpl_visual_features
00047 {
00048   // Define the texton feature structure
00049   typedef std::vector<float> TextonFeature;
00050 
00051 class LMFilterBank
00052 {
00053  public:
00060   LMFilterBank(int orientations = 6, int elongated_scales = 1,
00061                int gaussian_scales = 1, int num_extract_scales = 2,
00062                int support = 7);
00063 
00064 
00073   std::vector<TextonFeature> extractRawFeature(cv::Mat& frame,
00074                                                bool use_all_pixels = false);
00075 
00083   std::vector<int> extractDescriptor(cv::Mat& frame);
00084 
00093   float featureDist(TextonFeature f1, TextonFeature f2);
00094 
00098   void visualizeKernels(void);
00099 
00108   std::vector<TextonFeature> clusterTextons(
00109       std::vector<std::vector<TextonFeature> > samples, int k, int attempts=3);
00110 
00118   void saveTextonCenters(std::vector<TextonFeature> centers,
00119                          std::string file_name);
00120 
00128   bool readTextonCenters(std::string file_name);
00129 
00138   int quantizeFeature(TextonFeature feat);
00139 
00148   cv::Mat textonQuantizeImage(cv::Mat& frame);
00149 
00150   //
00151   // Getters and Setters
00152   //
00153   std::vector<TextonFeature> getCenters() const
00154   {
00155     return centers_;
00156   }
00157 
00158   int getNumCenters() const
00159   {
00160     return centers_.size();
00161   }
00162 
00163  protected:
00164   void generateFilters(void);
00165   cv::Mat getGaussianDeriv(float sigma, float mu, cv::Mat x, int ord);
00166   cv::Mat createElongatedFilter(float scale, int phase_x, int phase_y,
00167                                 cv::Mat pts_1, cv::Mat pts_2, int sup);
00168   cv::Mat upSampleResponse(cv::Mat& down_convolved, int s, cv::Size size0);
00169   cv::Mat normalize(cv::Mat& f);
00170   cv::Mat getDOGFilter(int ksize, float sigma, float alpha=3.0);
00171 
00172   //
00173   // Class Members
00174   //
00175   int n_orientations_;
00176   int n_e_scales_;
00177   int n_g_scales_;
00178   int n_extract_scales_;
00179   int support_;
00180   int n_filters_;
00181   std::vector<cv::Mat> bars_;
00182   std::vector<cv::Mat> edges_;
00183   std::vector<cv::Mat> gaussians_;
00184   std::vector<cv::Mat> dogs_;
00185   std::vector<TextonFeature> centers_;
00186 };
00187 }
00188 
00189 #endif // filter_bank_h_DEFINED


cpl_visual_features
Author(s): Tucker Hermans
autogenerated on Wed Nov 27 2013 11:52:36