Public Member Functions | Static Public Member Functions | Friends

Feature Class Reference
[Auxilliary Tools]

Auxilliary Tool: A purely virtual class for providing the skeleton for specific features. This allows different features to be manipulated using a common set of tools. More...

#include <Feature.h>

Inheritance diagram for Feature:
Inheritance graph
[legend]

List of all members.

Public Member Functions

virtual double evaluateImagePatch (const ImagePatch *patch)=0
 Turn an ImagePatch into a scalar value. This is the basic job of any feature. Must be overridden in derived classes.
virtual double evaluateImagePatch (const ImagePatch &patch)
 Turn an ImagePatch into a scalar value. This is the basic job of any feature.
virtual void filterPatchList (PatchList *patches)=0
 Apply the feature to a PatchList data structure. Must be overridden in derived classes.
virtual void setFeatureParameters (const cv::Mat &paramVec)=0
 Basic feature initialization. Must be overridden in derived classes.
virtual std::vector< Feature * > getSimilarFeatures (int numFeatures=1)
 Get features similar to the current feature. This is useful for searching through feature space for local optima.
virtual void getFeatureVisualization (cv::Mat &dest)
 Get a nice visual representation of the feature.
virtual std::string debugInfo () const
 Prints information about this feature for help debugging. By default, this prints the feature type, and its parameters.
virtual ~Feature ()
 Destructor. By default, this cleans up the parameters, valid parameter ranges, kernel image, and name. Subclasses are responsible for cleaning up extra memory.
FeaturegetFeatureOfSameTypeAndSize () const
 Get a feature with same type / dimension as this one, but random parameters.
Featurecopy () const
 Get a feature with the same type / dimension / parameters as this one.
void evaluateImagePatches (const std::vector< ImagePatch * > &imagePatches, std::vector< double > &scalarVals)
 Apply feature to multiple ImagePatch objects.
void evaluateImagePatches (const std::vector< ImagePatch > &imagePatches, std::vector< double > &scalarVals)
 Apply feature to multiple ImagePatch objects.
void evaluateImagePatches (const std::vector< ImagePatch * > &imagePatches, cv::Mat &scalarVals)
 Apply feature to multiple ImagePatch objects.
void evaluateImagePatches (const std::vector< ImagePatch > &imagePatches, cv::Mat &scalarVals)
 Apply feature to multiple ImagePatch objects.
cv::Size getPatchSize () const
 Get the size of patch that is "natural" for this feature.

Static Public Member Functions

static FeaturegetFeatureOfType (std::string featureName, cv::Size patchSize)
 Get a subclass based on its name. If you subclass Feature, you are responsible for modifying Feature.cpp to make this function aware of your feature. This function is important for saving the state of features for classifiers.

Friends

std::ostream & operator<< (std::ostream &ofs, Feature *feat)
 Write to a file.
std::istream & operator>> (std::istream &ifs, Feature *&feat)
 Read from a file.

Detailed Description

Auxilliary Tool: A purely virtual class for providing the skeleton for specific features. This allows different features to be manipulated using a common set of tools.

In general, we conceive of a feature as something that takes an image patch as input, and produces a scalar output. It may be necessary at times for a feature to apply itself efficiently to multiple image patches, using the PatchList data structure. Also, it will be necessary to find features similar to this one, and may be convenient to represent a feature in a compact parameterized form. Thus, a feature should implement the following:

virtual double evaluateImagePatch(const ImagePatch* patch); virtual void filterPatchList( PatchList* patches); virtual void setFeatureParameters(const CvMat* paramVec);

Additionally, the following utilities are provided but may be overridden:

virtual vector<Feature*> getSimilarFeatures(int numFeatures); virtual IplImage* visualizeFeature(); virtual string debugInfo() const; virtual ~Feature();

NOTE ON SUBCLASSING: In order for everything to work properly, a few rules need to be followed. First, subclasses should be able to completely reinitialize their own member variables from their parameter vector. This allows us to save a parameter vector to disk and then reconstruct the feature later. Second, subclasses should set the protected "featureName" variable, which helps determine which what the actual type of a saved feature is. Third (finally), Feature.cpp's getFeatureOfType method must be modified to be aware of your feature class, by calling the correct constructor (your constructor) when a feature of your type is read from disk.

Author:
Nicholas Butko
Date:
2010
Version:
0.4

Member Function Documentation

Feature * Feature::copy (  ) const

Get a feature with the same type / dimension / parameters as this one.

Returns:
A new feature.
string Feature::debugInfo (  ) const [virtual]

Prints information about this feature for help debugging. By default, this prints the feature type, and its parameters.

Returns:
Information about this feature useful for debugging.
double Feature::evaluateImagePatch ( const ImagePatch patch ) [virtual]

Turn an ImagePatch into a scalar value. This is the basic job of any feature.

Parameters:
patchThe image patch to evaluate.
Returns:
The value of the Image Patch according to the feature.
virtual double Feature::evaluateImagePatch ( const ImagePatch patch ) [pure virtual]

Turn an ImagePatch into a scalar value. This is the basic job of any feature. Must be overridden in derived classes.

Parameters:
patchThe image patch to evaluate.
Returns:
The value of the Image Patch according to the feature.

Implemented in BoxFeature.

void Feature::evaluateImagePatches ( const std::vector< ImagePatch * > &  imagePatches,
cv::Mat &  scalarVals 
)

Apply feature to multiple ImagePatch objects.

Parameters:
imagePatchesPatches to evaluate.
scalarValsResult of evaluation, in a CvMat data structure. If the provided CvMat is NULL or has inappropriate size, it will be freed and recreated.
void Feature::evaluateImagePatches ( const std::vector< ImagePatch > &  imagePatches,
cv::Mat &  scalarVals 
)

Apply feature to multiple ImagePatch objects.

Parameters:
imagePatchesPatches to evaluate.
scalarValsResult of evaluation, in a CvMat data structure. If the provided CvMat is NULL or has inappropriate size, it will be freed and recreated.
void Feature::evaluateImagePatches ( const std::vector< ImagePatch * > &  imagePatches,
std::vector< double > &  scalarVals 
)

Apply feature to multiple ImagePatch objects.

Parameters:
imagePatchesPatches to evaluate.
scalarValsResult of evaluation, in an STL vector data structure.
void Feature::evaluateImagePatches ( const std::vector< ImagePatch > &  imagePatches,
std::vector< double > &  scalarVals 
)

Apply feature to multiple ImagePatch objects.

Parameters:
imagePatchesPatches to evaluate.
scalarValsResult of evaluation, in an STL vector data structure.
virtual void Feature::filterPatchList ( PatchList patches ) [pure virtual]

Apply the feature to a PatchList data structure. Must be overridden in derived classes.

This is very important for efficiently filtering a whole image. The data for the filtering operation as well as the destination are contained in that data structure. See PatchList.h for details.

Parameters:
patchesRemaining patches in a large image to be filtered.

Implemented in BoxFeature.

Feature * Feature::getFeatureOfSameTypeAndSize (  ) const

Get a feature with same type / dimension as this one, but random parameters.

Returns:
A new feature.
static Feature* Feature::getFeatureOfType ( std::string  featureName,
cv::Size  patchSize 
) [static]

Get a subclass based on its name. If you subclass Feature, you are responsible for modifying Feature.cpp to make this function aware of your feature. This function is important for saving the state of features for classifiers.

Returns:
An object that is a subclass of Feature.
virtual void Feature::getFeatureVisualization ( cv::Mat &  dest ) [virtual]

Get a nice visual representation of the feature.

By default, this simply returns the "kernel" protected member variable, which subclasses should set during "setFeatureParameters".

Returns:
An image representing the feature in a visual way.
Size Feature::getPatchSize (  ) const

Get the size of patch that is "natural" for this feature.

Generally, features have a basic size. For example, a convolution-based feature has the size of the convolution kernel. Asking the feature to filter an ImagePatch that does not match this size may result in degraded performance.

Returns:
Preferred patch size.
vector< Feature * > Feature::getSimilarFeatures ( int  numFeatures = 1 ) [virtual]

Get features similar to the current feature. This is useful for searching through feature space for local optima.

By default, this randomly mutates the elements of the feature parameter vector. Override this function if different behavior is desired.

Parameters:
numFeaturesNumber of nearby features to grab.
Returns:
Set of nearby features.
virtual void Feature::setFeatureParameters ( const cv::Mat &  paramVec ) [pure virtual]

Basic feature initialization. Must be overridden in derived classes.

Subclasses should be able to completely reinitialize their own member variables from their parameter vector. This allows us to save a parameter vector to disk and then reconstruct the feature later.

Parameters:
paramVecA set of values sufficient to reconstruct a feature, or to construct a new one automatically. Must have type CV_64FC1

Implemented in BoxFeature, and HaarFeature.


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