Darwin  1.10(beta)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Protected Attributes | List of all members
drwnFilterBankResponse Class Reference

Holds the results of running an image through a bank of filters and allows for computation of features over rectangular regions. More...

Public Member Functions

 drwnFilterBankResponse ()
 default constructor
 
 drwnFilterBankResponse (const drwnFilterBankResponse &f)
 copy constructor
 
void clear ()
 clears the filter bank responses (and releases memory)
 
bool empty () const
 returns true if their are no filter responses
 
int size () const
 returns the number of responses from the filter bank
 
int width () const
 returns the width of each filter response (i.e., image width)
 
int height () const
 returns the height of each filter response (i.e., image height)
 
size_t memory () const
 returns number of bytes stored
 
void addResponseImage (cv::Mat &r)
 add a filter response image to the filterbank (takes ownership)
 
void addResponseImages (vector< cv::Mat > &r)
 add a number of filter response images to the filterbank (takes ownership)
 
void copyResponseImage (const cv::Mat &r)
 copies a filter response image to the filterbank (called retains ownership)
 
void copyResponseImages (const vector< cv::Mat > &r)
 copies a number of filter response images to the filterbank (called retains ownership)
 
const cv::Mat & getResponseImage (int i) const
 return the i-th filter response image
 
void deleteResponseImage (int i)
 delete the i-th filter response image (all responses above i are renumbered)
 
void exponentiateResponses (double alpha=1.0)
 transform responses by exponentiation (useful, for example, when approximating max over a region, via log-sum-exp)
 
void normalizeResponses ()
 transform responses by pixelwise normalization (e.g., following an exponentiation)
 
void expAndNormalizeResponses (double alpha=1.0)
 transform responses by pixelwise exponentiation and normalization. More numerically stable than exponentiateResponses followed by normalizeResponses.
 
VectorXd value (int x, int y) const
 value of each filter at given pixel
 
VectorXd mean (int x, int y, int w, int h) const
 mean of each filter in rectangular region <x, y, x+w, y+h>
 
VectorXd energy (int x, int y, int w, int h) const
 sum of squared values for each filter in rectangular region <x, y, x+w, y+h>
 
VectorXd variance (int x, int y, int w, int h) const
 variance of each filter in rectangular region <x, y, x+w, y+h>
 
VectorXd mean (const list< cv::Point > &pixels) const
 mean of each filter over given pixels
 
VectorXd energy (const list< cv::Point > &pixels) const
 energy of each filter over given pixels
 
VectorXd variance (const list< cv::Point > &pixels) const
 variance of each filter over given pixels
 
VectorXd mean (const cv::Mat &mask) const
 mean of each filter over masked pixels
 
VectorXd energy (const cv::Mat &mask) const
 energy of each filter over masked pixels
 
VectorXd variance (const cv::Mat &mask) const
 variance of each filter over masked pixels
 
VectorXd mean () const
 mean of each filter over entire image
 
VectorXd energy () const
 energy of each filter over entire image
 
VectorXd variance () const
 variance of each filter over entire image
 
cv::Mat visualize () const
 visualize the feature responses
 

Protected Attributes

vector< cv::Mat > _responses
 filter responses
 
vector< cv::Mat > _sum
 sum of filter responses (integral image)
 
vector< cv::Mat > _sqSum
 sum of filter responses squared
 

Detailed Description

Holds the results of running an image through a bank of filters and allows for computation of features over rectangular regions.

The difference between addResponseImage and copyResponseImage functions is that the former does not clone the images — the calling function must not modify the image since this will corrupt data internal to drwnFilterBankResponse. Response images should be 32-bit floating point.

The class uses integral images to allow quick computation of sums over rectangular regions. For example, the following code snippet computes the mean image intensity over a few small rectangular patches.

// load the image and convert to 32-bit greyscale
cv::Mat img = cv::imread( ... );
cv::Mat grey = drwnGreyImage(img);
// create filterbank response object and add greyscale image
filterbank.addResponseImage(grey);
// compute average intensity over random rectangular regions
for (int i = 0; i < 100; i++) {
const int x = (int)(drand48() * filterbank.width());
const int y = (int)(drand48() * filterbank.height());
const int w = (int)(drand48() * (filterbank.width() - x)) + 1;
const int h = (int)(drand48() * (filterbank.height() - y)) + 1;
double meanIntensity = filterbank.mean(x, y, w, h)[0];
DRWN_LOG_VERBOSE("mean intensity over " << w << "-by-" << h << " patch at ("
<< x << ", " << y << ") is " << meanIntensity);
}

The documentation for this class was generated from the following files: