8 DGM_ASSERT_MSG(img.channels() == 3,
"Input image has %d channel(s), but must have 3.", img.channels());
11 Mat res(img.size(), CV_8UC1);
12 for (
int y = 0; y < img.rows; y++) {
13 const byte *pImg = img.ptr<byte>(y);
14 byte *pRes = res.ptr<byte>(y);
15 for (
int x = 0; x < img.cols; x++) {
17 for (
int c = 0; c < 3; c++)
18 sum += weight.val[c] * pImg[3 * x + c];
19 pRes[x] = static_cast<byte> (MIN(255, MAX(0, sum + 0.5f)));
virtual Mat get(void) const
Extracts and returns the required feature.