Skip to content

Commit 204e98e

Browse files
committed
Bugfix #1143
1 parent da29f71 commit 204e98e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

modules/ximgproc/src/structured_edge_detection.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,12 @@ static void gradientHist(const cv::Mat &src, cv::Mat &magnitude, cv::Mat &histog
245245

246246
for (int j = 0; j < phase.cols; ++j)
247247
{
248-
int index = cvRound((j/pSize + pPhase[j])*nBins);
249-
index = std::max(0, std::min(index, pHistSize));
248+
int angle = cvRound(pPhase[j]*nBins);
249+
if(angle >= nBins)
250+
{
251+
angle = 0;
252+
}
253+
const int index = (j/pSize)*nBins + angle;
250254
pHist[index] += pMagn[j] / CV_SQR(pSize);
251255
}
252256
}

0 commit comments

Comments
 (0)