Darwin  1.10(beta)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
drwnFilterBankResponse.h
1 /*****************************************************************************
2 ** DARWIN: A FRAMEWORK FOR MACHINE LEARNING RESEARCH AND DEVELOPMENT
3 ** Distributed under the terms of the BSD license (see the LICENSE file)
4 ** Copyright (c) 2007-2015, Stephen Gould
5 ** All rights reserved.
6 **
7 ******************************************************************************
8 ** FILENAME: drwnFilterBankResponse.h
9 ** AUTHOR(S): Stephen Gould <stephen.gould@anu.edu.au>
10 **
11 *****************************************************************************/
12 
13 #pragma once
14 
15 #include <list>
16 #include <vector>
17 
18 #include "Eigen/Core"
19 
20 #include "cv.h"
21 
22 using namespace std;
23 using namespace Eigen;
24 
25 // drwnFilterBankResponse ------------------------------------------------------
59 
61  protected:
62  vector<cv::Mat> _responses;
63  vector<cv::Mat> _sum;
64  vector<cv::Mat> _sqSum;
65 
66  public:
72 
74  void clear();
76  inline bool empty() const { return _responses.empty(); }
78  inline int size() const { return (int)_responses.size(); }
80  inline int width() const { return _responses.empty() ? 0 : _responses[0].cols; }
82  inline int height() const { return _responses.empty() ? 0 : _responses[0].rows; }
84  inline size_t memory() const { return size() * width() * height() * sizeof(float) +
85  2 * size() * (width() + 1) * (height() + 1) * sizeof(double); }
86 
87  // add or copy 32-bit floating-point response images to the filter bank
89  void addResponseImage(cv::Mat& r);
91  void addResponseImages(vector<cv::Mat>& r);
93  void copyResponseImage(const cv::Mat& r);
95  void copyResponseImages(const vector<cv::Mat>& r);
97  const cv::Mat& getResponseImage(int i) const;
99  void deleteResponseImage(int i);
100 
103  void exponentiateResponses(double alpha = 1.0);
105  void normalizeResponses();
108  void expAndNormalizeResponses(double alpha = 1.0);
109 
111  VectorXd value(int x, int y) const;
113  VectorXd mean(int x, int y, int w, int h) const;
115  VectorXd energy(int x, int y, int w, int h) const;
117  VectorXd variance(int x, int y, int w, int h) const;
118 
120  VectorXd mean(const list<cv::Point>& pixels) const;
122  VectorXd energy(const list<cv::Point>& pixels) const;
124  VectorXd variance(const list<cv::Point>& pixels) const;
125 
127  VectorXd mean(const cv::Mat& mask) const;
129  VectorXd energy(const cv::Mat& mask) const;
131  VectorXd variance(const cv::Mat& mask) const;
132 
134  inline VectorXd mean() const { return mean(0, 0, width(), height()); }
136  inline VectorXd energy() const { return energy(0, 0, width(), height()); }
138  inline VectorXd variance() const { return variance(0, 0, width(), height()); }
139 
141  cv::Mat visualize() const;
142 };
143 
144 
145 
vector< cv::Mat > _sum
sum of filter responses (integral image)
Definition: drwnFilterBankResponse.h:63
vector< cv::Mat > _responses
filter responses
Definition: drwnFilterBankResponse.h:62
int size() const
returns the number of responses from the filter bank
Definition: drwnFilterBankResponse.h:78
vector< cv::Mat > _sqSum
sum of filter responses squared
Definition: drwnFilterBankResponse.h:64
VectorXd mean() const
mean of each filter over entire image
Definition: drwnFilterBankResponse.h:134
Holds the results of running an image through a bank of filters and allows for computation of feature...
Definition: drwnFilterBankResponse.h:60
int width() const
returns the width of each filter response (i.e., image width)
Definition: drwnFilterBankResponse.h:80
size_t memory() const
returns number of bytes stored
Definition: drwnFilterBankResponse.h:84
VectorXd variance() const
variance of each filter over entire image
Definition: drwnFilterBankResponse.h:138
VectorXd energy() const
energy of each filter over entire image
Definition: drwnFilterBankResponse.h:136
bool empty() const
returns true if their are no filter responses
Definition: drwnFilterBankResponse.h:76
int height() const
returns the height of each filter response (i.e., image height)
Definition: drwnFilterBankResponse.h:82