MCPcopy Create free account
hub / github.com/KAlO2/PerfectShow / InitGradMagAndOrientMats

Function InitGradMagAndOrientMats

jni/stasm/hat.cpp:28–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26// degrees, with 0 being due east, and anticlockwise increasing.
27
28static void InitGradMagAndOrientMats(
29 MAT& magmat, // out: grad mag mat
30 MAT& orientmat, // out: grad ori mat
31 const Image& img) // in: ROI scaled to current pyramid level
32{
33 const int nrows = img.rows, nrows1 = img.rows-1;
34 const int ncols = img.cols, ncols1 = img.cols-1;
35 const double bins_per_degree = BINS_PER_HIST / 360.;
36
37 magmat.create(nrows, ncols);
38 orientmat.create(nrows, ncols);
39
40 for (int y = 0; y < nrows1; y++)
41 {
42 const byte* const buf = (byte*)(img.data) + y * ncols;
43 const byte* const buf_x1 = (byte*)(img.data) + y * ncols + 1;
44 const byte* const buf_y1 = (byte*)(img.data) + (y+1) * ncols;
45
46 double* const magbuf = Buf(magmat) + y * ncols;
47 double* const orientbuf = Buf(orientmat) + y * ncols;
48
49 for (int x = 0; x < ncols1; x++)
50 {
51 const byte pixel = buf[x];
52 const double xdelta = buf_x1[x] - pixel;
53 const double ydelta = buf_y1[x] - pixel;
54
55 magbuf[x] = sqrt(SQ(xdelta) + SQ(ydelta));
56
57 double orient =
58 RadsToDegrees(atan2(ydelta, xdelta)); // -180 <= orient < 180
59 if (orient < 0)
60 orient += 360; // 0 <= orient < 360
61 orientbuf[x] = orient * bins_per_degree; // 0 <= orient < BINS_PER_HIST
62 }
63 }
64 // fill bottom and right edges
65 magmat.row(nrows1) = 0;
66 magmat.col(ncols1) = 0;
67 orientmat.row(nrows1) = 0;
68 orientmat.col(ncols1) = 0;
69}
70
71// Init the indices which map a patch row,col to the corresponding
72// histogram grid row,col. The mapping depends only on the image

Callers 1

Init_Method · 0.85

Calls 3

BufFunction · 0.85
SQFunction · 0.85
RadsToDegreesFunction · 0.85

Tested by

no test coverage detected