| 116 | // We also use shape for figuring out the direction of the whisker. |
| 117 | |
| 118 | static VEC FullProf( // return full profile |
| 119 | const Image& img, // in |
| 120 | const MAT& shape, // in |
| 121 | int ipoint, // in: index of the current point |
| 122 | int fullproflen) // in |
| 123 | { |
| 124 | CV_Assert(fullproflen > 1 && fullproflen < 100); // 100 is arb |
| 125 | CV_Assert(fullproflen % 2 == 1); // fullprof length must be odd |
| 126 | |
| 127 | VEC fullprof(1, fullproflen); |
| 128 | |
| 129 | double xstep; // x axis dist corresponding to one pixel along whisker |
| 130 | double ystep; |
| 131 | WhiskerStep(xstep, ystep, shape, ipoint); |
| 132 | |
| 133 | const double x = shape(ipoint, IX); // center point of the whisker |
| 134 | const double y = shape(ipoint, IY); |
| 135 | |
| 136 | // number of pixs to sample in each direction along the whisker |
| 137 | const int n = (NSIZE(fullprof) - 1) / 2; |
| 138 | |
| 139 | int prevpix = Pix(img, |
| 140 | Step(x, xstep, -n-1), Step(y, ystep, -n-1)); |
| 141 | |
| 142 | for (int i = -n; i <= n; i++) |
| 143 | { |
| 144 | const int pix = Pix(img, |
| 145 | Step(x, xstep, i), Step(y, ystep, i)); |
| 146 | fullprof(i + n) = double(pix - prevpix); // signed gradient |
| 147 | prevpix = pix; |
| 148 | } |
| 149 | return fullprof; |
| 150 | } |
| 151 | |
| 152 | static double SumAbsElems( // return the sum of the abs values of the elems of mat |
| 153 | const MAT& mat) // in |
no test coverage detected