|
|
|
@ -235,6 +235,7 @@ static void gradientHist(const cv::Mat &src, cv::Mat &magnitude, cv::Mat &histog |
|
|
|
|
magnitude /= imsmooth( magnitude, gnrmRad ) |
|
|
|
|
+ 0.01*cv::Mat::ones( magnitude.size(), magnitude.type() ); |
|
|
|
|
|
|
|
|
|
int pHistSize = histogram.cols*histogram.channels() - 1; |
|
|
|
|
for (int i = 0; i < phase.rows; ++i) |
|
|
|
|
{ |
|
|
|
|
const float *pPhase = phase.ptr<float>(i); |
|
|
|
@ -243,7 +244,11 @@ static void gradientHist(const cv::Mat &src, cv::Mat &magnitude, cv::Mat &histog |
|
|
|
|
float *pHist = histogram.ptr<float>(i/pSize); |
|
|
|
|
|
|
|
|
|
for (int j = 0; j < phase.cols; ++j) |
|
|
|
|
pHist[cvRound((j/pSize + pPhase[j])*nBins)] += pMagn[j] / CV_SQR(pSize); |
|
|
|
|
{ |
|
|
|
|
int index = cvRound((j/pSize + pPhase[j])*nBins); |
|
|
|
|
index = std::max(0, std::min(index, pHistSize)); |
|
|
|
|
pHist[index] += pMagn[j] / CV_SQR(pSize); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|