Commit c42beb4c authored by Vadim Pisarevsky's avatar Vadim Pisarevsky

Merge pull request #1144 from olivierpascal:olivierpascal-structured-edge-detection

parents da29f712 ab48ffdf
...@@ -235,7 +235,6 @@ static void gradientHist(const cv::Mat &src, cv::Mat &magnitude, cv::Mat &histog ...@@ -235,7 +235,6 @@ static void gradientHist(const cv::Mat &src, cv::Mat &magnitude, cv::Mat &histog
magnitude /= imsmooth( magnitude, gnrmRad ) magnitude /= imsmooth( magnitude, gnrmRad )
+ 0.01*cv::Mat::ones( magnitude.size(), magnitude.type() ); + 0.01*cv::Mat::ones( magnitude.size(), magnitude.type() );
int pHistSize = histogram.cols*histogram.channels() - 1;
for (int i = 0; i < phase.rows; ++i) for (int i = 0; i < phase.rows; ++i)
{ {
const float *pPhase = phase.ptr<float>(i); const float *pPhase = phase.ptr<float>(i);
...@@ -245,8 +244,12 @@ static void gradientHist(const cv::Mat &src, cv::Mat &magnitude, cv::Mat &histog ...@@ -245,8 +244,12 @@ static void gradientHist(const cv::Mat &src, cv::Mat &magnitude, cv::Mat &histog
for (int j = 0; j < phase.cols; ++j) for (int j = 0; j < phase.cols; ++j)
{ {
int index = cvRound((j/pSize + pPhase[j])*nBins); int angle = cvRound(pPhase[j]*nBins);
index = std::max(0, std::min(index, pHistSize)); if(angle >= nBins)
{
angle = 0;
}
const int index = (j/pSize)*nBins + angle;
pHist[index] += pMagn[j] / CV_SQR(pSize); pHist[index] += pMagn[j] / CV_SQR(pSize);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment