Direct Graphical Models  v.1.7.0
CommonFeatureExtractor.h
1 // A common feature extraction class, which unites other feature extraction algorithms
2 // Writtem by Sergey G. Kosov in 2015 for Project X
3 #pragma once
4 
5 #include "IFeatureExtractor.h"
6 #include "Coordinate.h"
7 #include "Intensity.h"
8 #include "HSV.h"
9 #include "Gradient.h"
10 #include "NDVI.h"
11 #include "Distance.h"
12 #include "HOG.h"
13 #include "SIFT.h"
14 #include "Variance.h"
15 #include "Scale.h"
16 #include "SparseCoding.h"
17 #include "GlobalFeatureExtractor.h"
18 #include "macroses.h"
19 
20 namespace DirectGraphicalModels { namespace fex
21 {
23  enum ChannelsRGB {
27  };
28 
30  enum ChannelsHSV {
34  };
35 
36 
37  // ================================ Common Feature Extractor Class ==============================
53  {
54  public:
59  DllExport CCommonFeatureExtractor(const Mat &img) : ILocalFeatureExtractor(img) {}
60  DllExport virtual ~CCommonFeatureExtractor(void) {}
61 
66  DllExport Mat virtual get(void) const { return m_img; }
67 
86  DllExport CCommonFeatureExtractor getIntensity(cv::Scalar weight = CV_RGB(0.333, 0.333, 0.333)) const { return CCommonFeatureExtractor(CIntensity::get(m_img, weight)); }
98  DllExport CCommonFeatureExtractor getHue(void) const { return CCommonFeatureExtractor(CHSV::get(m_img)).getChannel(CH_HUE); }
121  DllExport CCommonFeatureExtractor getGradient(float mid = GRADIENT_MAX_VALUE) const { return CCommonFeatureExtractor(CGradient::get(m_img, mid)); }
138  DllExport CCommonFeatureExtractor getNDVI(byte midPoint = 127) const { return CCommonFeatureExtractor(CNDVI::get(m_img, midPoint)); }
147  DllExport CCommonFeatureExtractor getDistance(byte threshold = 16, double multiplier = 4.0) const { return CCommonFeatureExtractor(CDistance::get(m_img, threshold, multiplier)); }
156  DllExport CCommonFeatureExtractor getHOG(int nBins = 9, SqNeighbourhood nbhd = sqNeighbourhood(5)) const { return CCommonFeatureExtractor(CHOG::get(m_img, nBins, nbhd)); }
193  DllExport CCommonFeatureExtractor invert(void) const;
199  DllExport CCommonFeatureExtractor blur(int R = 2) const;
204  DllExport CCommonFeatureExtractor autoContrast(void) const;
213  DllExport CCommonFeatureExtractor thresholding(byte threshold) const;
219  DllExport CCommonFeatureExtractor getChannel(int channel) const;
220  };
221 } }
Coordinate feature depend on the pixel's ordinate (y-coordinate).
Definition: Coordinate.h:13
CCommonFeatureExtractor getBrightness(void) const
Extracts the brightness feature.
CCommonFeatureExtractor getHSV(void) const
Extracts the HSV feature.
CCommonFeatureExtractor getHue(void) const
Extracts the hue feature.
CCommonFeatureExtractor getCoordinate(coordinateType type=COORDINATE_ORDINATE) const
Extracts a coordinate feature.
CGlobalFeatureExtractor toGlobal(void) const
Allows for global-features extraction.
virtual Mat get(void) const
Extracts and returns the required feature.
Definition: SparseCoding.h:27
CCommonFeatureExtractor getChannel(int channel) const
Extracts one channel from the source image.
CCommonFeatureExtractor blur(int R=2) const
Performs Gaussian blurring of the source image.
CCommonFeatureExtractor getIntensity(cv::Scalar weight=CV_RGB(0.333, 0.333, 0.333)) const
Extracts the intesity feature.
CCommonFeatureExtractor getDistance(byte threshold=16, double multiplier=4.0) const
Extracts the distance feature.
virtual Mat get(void) const
Extracts and returns the required feature.
Definition: Coordinate.h:34
CCommonFeatureExtractor getSparseCoding(const Mat &D, SqNeighbourhood nbhd=sqNeighbourhood(3)) const
Extracts the sparse coding feature.
CCommonFeatureExtractor autoContrast(void) const
Performs histogram stretching of the source image.
CCommonFeatureExtractor getVariance(SqNeighbourhood nbhd=sqNeighbourhood(5)) const
Extracts the variance feature.
virtual Mat get(void) const
Extracts and returns the required feature.
Definition: Scale.h:26
SqNeighbourhood sqNeighbourhood(int leftGap, int rightGap, int upperGap, int lowerGap)
Initializes the square neighborhood structure.
CCommonFeatureExtractor invert(void) const
Inverts the source image.
CCommonFeatureExtractor getNDVI(byte midPoint=127) const
Extracts the NDVI (normalized difference vegetation index) feature.
virtual Mat get(void) const
Extracts and returns the required feature.
Definition: Intensity.h:24
virtual Mat get(void) const
Extracts and returns the required feature.
Definition: HOG.h:25
CCommonFeatureExtractor getSIFT() const
Extracts the SIFT (scale-invariant feature transform) feature.
virtual Mat get(void) const
Extracts and returns the required feature.
Definition: Gradient.h:26
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="_blan...
virtual Mat get(void) const
Extracts and returns the required feature.
Definition: Variance.h:25
CCommonFeatureExtractor thresholding(byte threshold) const
Performs thresholding on the source image.
Interface class for global feature extraction algorithms.
virtual Mat get(void) const
Extracts and returns the required feature.
Definition: HSV.h:24
Common class, which unites feature extraction algorithms.
virtual Mat get(void) const
Extracts and returns the required feature.
Definition: SIFT.h:26
ChannelsHSV
Channels in the HSV color space.
virtual Mat get(void) const
Extracts and returns the required feature.
Definition: NDVI.h:24
CCommonFeatureExtractor reScale(SqNeighbourhood nbhd=sqNeighbourhood(5)) const
Extracts the scale feature.
Interface class for local feature extraction algorithms.
CCommonFeatureExtractor getSaturation(void) const
Extracts the saturation feature.
ChannelsRGB
Channels in the BGR color space.
const Mat m_img
Container for the image, from which the features are to be extracted.
CCommonFeatureExtractor getGradient(float mid=GRADIENT_MAX_VALUE) const
Extracts the gradient feature.
virtual Mat get(void) const
Extracts and returns the required feature.
Definition: Distance.h:25
coordinateType
Types of the coordinate feature.
Definition: Coordinate.h:12