1 #include "Coordinate.h" 2 #include "LinearMapper.h" 8 Mat res(img.size(), CV_8UC1);
10 int height = img.rows;
13 for (
int y = 0; y < height; y++) {
14 byte *pRes = res.ptr<byte>(y);
15 for (
int x = 0; x < width; x++) {
17 case COORDINATE_ORDINATE: pRes[x] = linear_mapper<byte>(
static_cast<float>(y), 0, static_cast<float>(height - 1));
break;
18 case COORDINATE_ABSCISS: pRes[x] = linear_mapper<byte>(
static_cast<float>(x), 0, static_cast<float>(width - 1));
break;
20 float dx = x - 0.5f * width;
21 float dy = y - 0.5f * height;
22 float val = sqrtf(dx*dx + dy*dy);
23 if (max < 0) max = val;
24 pRes[x] = linear_mapper<byte>(val, 0, max);
Coordinate feature depend on the pixel's ordinate (y-coordinate).
Coordinate feature depend on the pixel's absciss (x-coordinate).
Coordinate feature depend on the pixel's distance to the image center.
virtual Mat get(void) const
Extracts and returns the required feature.
coordinateType
Types of the coordinate feature.