1 #include "CommonFeatureExtractor.h" 8 bitwise_not(
m_img, res);
16 GaussianBlur(
m_img, res, cv::Size(R, R), 0.0, 0.0, BORDER_REFLECT);
22 DGM_ASSERT_MSG(
m_img.depth() == CV_8U,
"The source image must have 8-bit / channel depth");
25 split(
m_img, vChannels);
27 concurrency::parallel_for_each(vChannels.begin(), vChannels.end(), [](Mat &c) {
29 for (Mat &c : vChannels) {
31 double minVal, maxVal;
32 minMaxLoc(c, &minVal, &maxVal);
33 double k = (maxVal > minVal) ? k = 255.0 / (maxVal - minVal) : 1.0;
34 c.convertTo(c, c.type(), k, -minVal * k);
39 merge(vChannels, res);
47 if (
m_img.channels() != 1) cvtColor(
m_img, res, cv::ColorConversionCodes::COLOR_RGB2GRAY);
48 else m_img.copyTo(res);
50 for (
int y = 0; y < res.rows; y++) {
51 byte *pRes = res.ptr<byte>(y);
52 for (
int x = 0; x < res.cols; x++)
53 pRes[x] = (pRes[x] > threshold) ? 225 : 0;
61 DGM_ASSERT_MSG(channel <
m_img.channels(),
"The required channel %d does not exist in the %d-channel source image", channel,
m_img.channels());
64 split(
m_img, vChannels);
65 vChannels.at(channel).copyTo(res);
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 autoContrast(void) const
Performs histogram stretching of the source image.
CCommonFeatureExtractor invert(void) const
Inverts the source image.
CCommonFeatureExtractor(const Mat &img)
Constructor.
CCommonFeatureExtractor thresholding(byte threshold) const
Performs thresholding on the source image.
Common class, which unites feature extraction algorithms.
const Mat m_img
Container for the image, from which the features are to be extracted.