Direct Graphical Models  v.1.7.0
Coordinate.cpp
1 #include "Coordinate.h"
2 #include "LinearMapper.h"
3 
4 namespace DirectGraphicalModels { namespace fex
5 {
6 Mat CCoordinate::get(const Mat &img, coordinateType type)
7 {
8  Mat res(img.size(), CV_8UC1);
9  int width = img.cols;
10  int height = img.rows;
11  float max = -1.0f;
12 
13  for (int y = 0; y < height; y++) {
14  byte *pRes = res.ptr<byte>(y);
15  for (int x = 0; x < width; x++) {
16  switch (type) {
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;
19  case COORDINATE_RADIUS:
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);
25  } // type
26  } // x
27  } // y
28 
29  return res;
30 }
31 } }
Coordinate feature depend on the pixel&#39;s ordinate (y-coordinate).
Definition: Coordinate.h:13
Coordinate feature depend on the pixel&#39;s absciss (x-coordinate).
Definition: Coordinate.h:14
Coordinate feature depend on the pixel&#39;s distance to the image center.
Definition: Coordinate.h:15
virtual Mat get(void) const
Extracts and returns the required feature.
Definition: Coordinate.h:34
coordinateType
Types of the coordinate feature.
Definition: Coordinate.h:12