Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef lm_filter_bank_h_DEFINED
00036 #define lm_filter_bank_h_DEFINED
00037
00038 #include <ros/common.h>
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
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
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
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