Direct Graphical Models  v.1.5.2
DirectGraphicalModels::fex::CCommonFeatureExtractor Class Reference

Common class, which unites feature extraction algorithms. More...

#include <CommonFeatureExtractor.h>

Inheritance diagram for DirectGraphicalModels::fex::CCommonFeatureExtractor:
Collaboration diagram for DirectGraphicalModels::fex::CCommonFeatureExtractor:

Public Member Functions

 CCommonFeatureExtractor (const Mat &img)
 Constructor. More...
 
virtual ~CCommonFeatureExtractor (void)
 
virtual Mat get (void) const
 Returns the input image. More...
 
CGlobalFeatureExtractor toGlobal (void) const
 Allows for global-features extraction. More...
 
CCommonFeatureExtractor getCoordinate (coordinateType type=COORDINATE_ORDINATE) const
 Extracts a coordinate feature. More...
 
CCommonFeatureExtractor getIntensity (CvScalar weight=CV_RGB(0.333, 0.333, 0.333)) const
 Extracts the intesity feature. More...
 
CCommonFeatureExtractor getHSV (void) const
 Extracts the HSV feature. More...
 
CCommonFeatureExtractor getHue (void) const
 Extracts the hue feature. More...
 
CCommonFeatureExtractor getSaturation (void) const
 Extracts the saturation feature. More...
 
CCommonFeatureExtractor getBrightness (void) const
 Extracts the brightness feature. More...
 
CCommonFeatureExtractor getGradient (float mid=GRADIENT_MAX_VALUE) const
 Extracts the gradient feature. More...
 
CCommonFeatureExtractor getNDVI (byte midPoint=127) const
 Extracts the NDVI (normalized difference vegetation index) feature. More...
 
CCommonFeatureExtractor getDistance (byte threshold=16, double multiplier=4.0) const
 Extracts the distance feature. More...
 
CCommonFeatureExtractor getHOG (int nBins=9, SqNeighbourhood nbhd=sqNeighbourhood(5)) const
 Extracts the HOG (<a href="http://en.wikipedia.org/wiki/Histogram_of_oriented_gradients"target="_blank">histogram of oriented gradients) feature. More...
 
CCommonFeatureExtractor getSIFT () const
 Extracts the SIFT (scale-invariant feature transform) feature. More...
 
CCommonFeatureExtractor getVariance (SqNeighbourhood nbhd=sqNeighbourhood(5)) const
 Extracts the variance feature. More...
 
CCommonFeatureExtractor getSparseCoding (const Mat &D, SqNeighbourhood nbhd=sqNeighbourhood(3)) const
 Extracts the sparse coding feature. More...
 
CCommonFeatureExtractor reScale (SqNeighbourhood nbhd=sqNeighbourhood(5)) const
 Extracts the scale feature. More...
 
CCommonFeatureExtractor invert (void) const
 Inverts the source image. More...
 
CCommonFeatureExtractor blur (int R=2) const
 Performs Gaussian blurring of the source image. More...
 
CCommonFeatureExtractor autoContrast (void) const
 Performs histogram stretching of the source image. More...
 
CCommonFeatureExtractor thresholding (byte threshold) const
 Performs thresholding on the source image. More...
 
CCommonFeatureExtractor getChannel (int channel) const
 Extracts one channel from the source image. More...
 
- Public Member Functions inherited from DirectGraphicalModels::fex::ILocalFeatureExtractor
 ILocalFeatureExtractor (const Mat &img)
 Constructor. More...
 
virtual ~ILocalFeatureExtractor (void)
 
- Public Member Functions inherited from DirectGraphicalModels::fex::IFeatureExtractor
 IFeatureExtractor (const Mat &img)
 Constructor. More...
 
virtual ~IFeatureExtractor (void)
 

Additional Inherited Members

- Protected Attributes inherited from DirectGraphicalModels::fex::IFeatureExtractor
const Mat m_img
 Container for the image, from which the features are to be extracted. More...
 

Detailed Description

Common class, which unites feature extraction algorithms.

In order to simplify the user feature extraction code, this class provides fluent interface. Please see the example code below for more details.

Mat saturation = fex.getSaturation().invert().get(); // Inverted saturation feature
Mat variance = fex.getGradient().getVariance().blur().get(); // Varience of the gradient feature, after Gaussian blur
Mat intesity = fex.getIntensity().reScale(sqNeighbourhood(2)).get(); // Intencity feature, calculated at scale of window size 5 x 5 pixels
size_t nLines = fex.autoContrast().toGlobal().getNumLines(); // Global-feature: quantity of straight lines in image
Author
Sergey G. Kosov, serge.nosp@m.y.ko.nosp@m.sov@p.nosp@m.roje.nosp@m.ct-10.nosp@m..de

Definition at line 52 of file CommonFeatureExtractor.h.

Constructor & Destructor Documentation

DirectGraphicalModels::fex::CCommonFeatureExtractor::CCommonFeatureExtractor ( const Mat &  img)
inline

Constructor.

Parameters
imgInput image.

Definition at line 59 of file CommonFeatureExtractor.h.

Here is the caller graph for this function:

virtual DirectGraphicalModels::fex::CCommonFeatureExtractor::~CCommonFeatureExtractor ( void  )
inlinevirtual

Definition at line 60 of file CommonFeatureExtractor.h.

Member Function Documentation

CCommonFeatureExtractor DirectGraphicalModels::fex::CCommonFeatureExtractor::autoContrast ( void  ) const

Performs histogram stretching of the source image.

Returns
Common feature extractor class with with contrast-enhanced feature with the same number of channels.

Definition at line 20 of file CommonFeatureExtractor.cpp.

Here is the call graph for this function:

CCommonFeatureExtractor DirectGraphicalModels::fex::CCommonFeatureExtractor::blur ( int  R = 2) const

Performs Gaussian blurring of the source image.

Parameters
RRadius of the Gaussian filter box: \((2R+1)\times(2R+1)\).
Returns
Common feature extractor class with blurred feature with the same number of channels.

Definition at line 12 of file CommonFeatureExtractor.cpp.

Here is the call graph for this function:

virtual Mat DirectGraphicalModels::fex::CCommonFeatureExtractor::get ( void  ) const
inlinevirtual

Returns the input image.

Returns
The input image.

Implements DirectGraphicalModels::fex::ILocalFeatureExtractor.

Definition at line 66 of file CommonFeatureExtractor.h.

CCommonFeatureExtractor DirectGraphicalModels::fex::CCommonFeatureExtractor::getBrightness ( void  ) const
inline

Extracts the brightness feature.

This function represents the input image in HSV (hue-saturation-value) color model and returns the value channel.

Returns
Common feature extractor class with extracted brightness feature of type CV_8UC1.

Definition at line 110 of file CommonFeatureExtractor.h.

Here is the call graph for this function:

CCommonFeatureExtractor DirectGraphicalModels::fex::CCommonFeatureExtractor::getChannel ( int  channel) const

Extracts one channel from the source image.

Parameters
channelIndex of the required channel.
Returns
Common feature extractor class with the required channel as a feature.

Definition at line 59 of file CommonFeatureExtractor.cpp.

Here is the call graph for this function:

CCommonFeatureExtractor DirectGraphicalModels::fex::CCommonFeatureExtractor::getCoordinate ( coordinateType  type = COORDINATE_ORDINATE) const
inline

Extracts a coordinate feature.

This function calculates the coordinate feature of image pixels, based inly on theirs coordinates.

Parameters
typeType of the coordinate feature (Ref. coordinateType).
Returns
Common feature extractor class with extracted coordinate feature of type CV_8UC1.

Definition at line 79 of file CommonFeatureExtractor.h.

Here is the call graph for this function:

CCommonFeatureExtractor DirectGraphicalModels::fex::CCommonFeatureExtractor::getDistance ( byte  threshold = 16,
double  multiplier = 4.0 
) const
inline

Extracts the distance feature.

For each pixel of the source image this function calculates the distance to the closest pixel, which value is larger or equal to threshold. Resulting feature image is multiplied by multiplier

Parameters
thresholdThreshold value.
multiplierAmplification coefficient for the resulting feature image.
Returns
Common feature extractor class with extracted distance feature of type CV_8UC1.

Definition at line 147 of file CommonFeatureExtractor.h.

Here is the call graph for this function:

CCommonFeatureExtractor DirectGraphicalModels::fex::CCommonFeatureExtractor::getGradient ( float  mid = GRADIENT_MAX_VALUE) const
inline

Extracts the gradient feature.

This function calculates the magnitude of gradient of the input image as follows:

\[gradient=\sqrt{\left(\frac{d\,img}{dx}\right)^2+\left(\frac{d\,img}{dy}\right)^2},\]

where \(\frac{d\,img}{dx}\) and \(\frac{d\,img}{dy}\) are the first x and y central derivatives of the input image.
As \(gradient\in[0; 255\,\sqrt{2}]\), this function performs two-linear mapping of the gradient values to the interval \([0; 255]\), such that:

\begin{eqnarray*}0&\rightarrow&0 \\ mid&\rightarrow&255 \\ 255\,\sqrt{2}&\rightarrow&255\end{eqnarray*}

For more details on mapping refer to the two_linear_mapper() function.

Parameters
midParameter for the two-linear mapping of the feature: \(mid\in(0;255\sqrt{2}]\). (Ref. two_linear_mapper()).
Returns
Common feature extractor class with extracted gradient feature of type CV_8UC1.

Definition at line 121 of file CommonFeatureExtractor.h.

Here is the call graph for this function:

CCommonFeatureExtractor DirectGraphicalModels::fex::CCommonFeatureExtractor::getHOG ( int  nBins = 9,
SqNeighbourhood  nbhd = sqNeighbourhood(5) 
) const
inline

Extracts the HOG (<a href="http://en.wikipedia.org/wiki/Histogram_of_oriented_gradients"target="_blank">histogram of oriented gradients) feature.

For each pixel of the source image this function calculates the histogram of oriented gradients inside the pixel's neighbourhood nbhd. The histogram consists of nBins values, it is normalized, and stored as nBins channel image, thus, the channel index corresponds to the histogram index.

Parameters
nBinsNumber of bins. Hence a single bin covers an angle of \(\frac{180^\circ}{nBins}\).
nbhdNeighborhood around the pixel, where its histogram is estimated. (Ref. SqNeighbourhood).
Returns
Common feature extractor class with extracted HOG feature of type CV_8UC{n}, where \(n=nBins\).

Definition at line 156 of file CommonFeatureExtractor.h.

Here is the call graph for this function:

CCommonFeatureExtractor DirectGraphicalModels::fex::CCommonFeatureExtractor::getHSV ( void  ) const
inline

Extracts the HSV feature.

This function transforms the input image into HSV (hue-saturation-value) color space.

Returns
The (hue-saturation-value) feature image of type CV_8UC3.

Definition at line 92 of file CommonFeatureExtractor.h.

Here is the call graph for this function:

CCommonFeatureExtractor DirectGraphicalModels::fex::CCommonFeatureExtractor::getHue ( void  ) const
inline

Extracts the hue feature.

This function represents the input image in HSV (hue-saturation-value) color model and returns the hue channel.

Returns
Common feature extractor class with extracted hue feature of type CV_8UC1.

Definition at line 98 of file CommonFeatureExtractor.h.

Here is the call graph for this function:

CCommonFeatureExtractor DirectGraphicalModels::fex::CCommonFeatureExtractor::getIntensity ( CvScalar  weight = CV_RGB(0.333, 0.333, 0.333)) const
inline

Extracts the intesity feature.

This function calculates the intesity of the input image as follows:

\[ intensity=weight_0\cdot img.RED+weight_1\cdot img.GREEN+weight_2\cdot img.BLUE \]

Parameters
weightThe weight coefficients, which determine the contribution of each color channel to the resulting intensity.
Returns
Common feature extractor class with extracted intensity feature of type CV_8UC1.

Definition at line 86 of file CommonFeatureExtractor.h.

Here is the call graph for this function:

CCommonFeatureExtractor DirectGraphicalModels::fex::CCommonFeatureExtractor::getNDVI ( byte  midPoint = 127) const
inline

Extracts the NDVI (normalized difference vegetation index) feature.

This function calculates the NDVI from the input image as follows:

\[ NDVI=\frac{NIR-VIS}{NIR+VIS},\]

where \(NIR\) designates the near-infra-red data, and \(VIS\) - visible data. The algorithm assumes that the near-infra-red data is stored in the red image channel and the visible data - in the remaining two channels:

\begin{eqnarray*}NIR&=&img.RED \\ VIS&=&\frac{1}{2}\,img.GREEN+\frac{1}{2}\,img.BLUE.\end{eqnarray*}

As \(NDVI\in[-1; 1]\), this function performs two-linear mapping of the NDVI values to the interval \([0; 255]\), such that:

\begin{eqnarray*}-1&\rightarrow&0 \\ 0&\rightarrow&midPoint \\ 1&\rightarrow&255\end{eqnarray*}

For more details on mapping refer to the two_linear_mapper() function.

Parameters
midPointParameter for the two-linear mapping of the feature (Ref. two_linear_mapper()).

Common values are:

  • 0     - cut off the negative NDVI values;
  • 127 - linear mapping;
  • 255 - cut off the positive NDVI values.
Returns
Common feature extractor class with extracted NDVI feature of type CV_8UC1.

Definition at line 138 of file CommonFeatureExtractor.h.

Here is the call graph for this function:

CCommonFeatureExtractor DirectGraphicalModels::fex::CCommonFeatureExtractor::getSaturation ( void  ) const
inline

Extracts the saturation feature.

This function represents the input image in HSV (hue-saturation-value) color model and returns the saturation channel.

Returns
Common feature extractor class with extracted saturation feature of type CV_8UC1.

Definition at line 104 of file CommonFeatureExtractor.h.

Here is the call graph for this function:

CCommonFeatureExtractor DirectGraphicalModels::fex::CCommonFeatureExtractor::getSIFT ( ) const
inline

Extracts the SIFT (scale-invariant feature transform) feature.

For each pixel of the source image this function performs the scale-invariant feature transform.

Returns
Common feature extractor class with extracted SIFT feature of type CV_8UC{128}.

Definition at line 162 of file CommonFeatureExtractor.h.

Here is the call graph for this function:

CCommonFeatureExtractor DirectGraphicalModels::fex::CCommonFeatureExtractor::getSparseCoding ( const Mat &  D,
SqNeighbourhood  nbhd = sqNeighbourhood(3) 
) const
inline

Extracts the sparse coding feature.

For each pixel of the source image this function calculates the sparse coding feature within the pixel's neighbourhood nbhd.

This fuction supports dictionaries with nWords less or equal to 512 words. For larger dictionaries use CSparseCoding::get_v() function directly.

Parameters
DSparse dictionary \(D\): Mat(size nWords x blockSize^2; type CV_32FC1).

Dictionary should be learned from a training data with CSparseDictionary::train() function,
or it may be loaded directed from a dic file with CSparseDictionary::getDictionary("dictionary.dic").

nbhdNeighborhood around the pixel, where the feature is estimated. (Ref. SqNeighbourhood).
Returns
Common feature extractor class with extracted sparse coding feature of type CV_8UC{nWords}.

Definition at line 180 of file CommonFeatureExtractor.h.

Here is the call graph for this function:

CCommonFeatureExtractor DirectGraphicalModels::fex::CCommonFeatureExtractor::getVariance ( SqNeighbourhood  nbhd = sqNeighbourhood(5)) const
inline

Extracts the variance feature.

For each pixel of the source image this function calculates the variance within the pixel's neighbourhood nbhd.

Parameters
nbhdNeighborhood around the pixel, where the variance is estimated. (Ref. SqNeighbourhood).
Returns
Common feature extractor class with extracted variance feature of type CV_8UC1.

Definition at line 169 of file CommonFeatureExtractor.h.

Here is the call graph for this function:

CCommonFeatureExtractor DirectGraphicalModels::fex::CCommonFeatureExtractor::invert ( void  ) const

Inverts the source image.

Returns
Common feature extractor class with the inverted feature with the same number of channels.

Definition at line 5 of file CommonFeatureExtractor.cpp.

Here is the call graph for this function:

CCommonFeatureExtractor DirectGraphicalModels::fex::CCommonFeatureExtractor::reScale ( SqNeighbourhood  nbhd = sqNeighbourhood(5)) const
inline

Extracts the scale feature.

For each pixel of the source image this function calculates the mean value within the pixel's neighbourhood nbhd. Using different neighbourhood radii, it alows for different scale representations of the nput features.

Parameters
nbhdNeighborhood around the pixel, where the mean is estimated. (Ref. SqNeighbourhood).
Returns
Common feature extractor class with extracted scale feature of type CV_8UC1.

Definition at line 188 of file CommonFeatureExtractor.h.

Here is the call graph for this function:

CCommonFeatureExtractor DirectGraphicalModels::fex::CCommonFeatureExtractor::thresholding ( byte  threshold) const

Performs thresholding on the source image.

\[ res_i = \left\{\begin{array}{ll} 255 & \text{if}~~res_i > threshold \\ 0 & \text{otherwise} \end{array} \right. \]

Returns
A binary image of type CV_8UC1 with values {0, 255 }

Definition at line 43 of file CommonFeatureExtractor.cpp.

Here is the call graph for this function:

CGlobalFeatureExtractor DirectGraphicalModels::fex::CCommonFeatureExtractor::toGlobal ( void  ) const
inline

Allows for global-features extraction.

Returns
The base global feature extractor class

Definition at line 72 of file CommonFeatureExtractor.h.


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