Skip to content

Commit dcaac98

Browse files
author
Andrey Pavlenko
committed
Merge pull request opencv#6775 from janstarzy:histo-ipp-fix
2 parents 627e2b1 + 7f89664 commit dcaac98

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

modules/imgproc/src/histogram.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,6 +1188,7 @@ class IPPCalcHistInvoker :
11881188

11891189
virtual void operator() (const Range & range) const
11901190
{
1191+
Ipp32s levelNum = histSize + 1;
11911192
Mat phist(hist->size(), hist->type(), Scalar::all(0));
11921193
#if IPP_VERSION_X100 >= 900
11931194
IppiSize roi = {src->cols, range.end - range.start};
@@ -1196,7 +1197,7 @@ class IPPCalcHistInvoker :
11961197
IppiHistogramSpec *pSpec = NULL;
11971198
Ipp8u *pBuffer = NULL;
11981199

1199-
if(ippiHistogramGetBufferSize(ipp8u, roi, &histSize, 1, 1, &specSize, &bufferSize) < 0)
1200+
if(ippiHistogramGetBufferSize(ipp8u, roi, &levelNum, 1, 1, &specSize, &bufferSize) < 0)
12001201
{
12011202
*ok = false;
12021203
return;
@@ -1217,7 +1218,7 @@ class IPPCalcHistInvoker :
12171218
return;
12181219
}
12191220

1220-
if(ippiHistogramUniformInit(ipp8u, (Ipp32f*)&low, (Ipp32f*)&high, (Ipp32s*)&histSize, 1, pSpec) < 0)
1221+
if(ippiHistogramUniformInit(ipp8u, (Ipp32f*)&low, (Ipp32f*)&high, (Ipp32s*)&levelNum, 1, pSpec) < 0)
12211222
{
12221223
if(pSpec) ippFree(pSpec);
12231224
if(pBuffer) ippFree(pBuffer);
@@ -1233,7 +1234,7 @@ class IPPCalcHistInvoker :
12331234
#else
12341235
CV_SUPPRESS_DEPRECATED_START
12351236
IppStatus status = ippiHistogramEven_8u_C1R(src->ptr(range.start), (int)src->step, ippiSize(src->cols, range.end - range.start),
1236-
phist.ptr<Ipp32s>(), (Ipp32s*)(Ipp32f*)*levels, histSize, (Ipp32s)low, (Ipp32s)high);
1237+
phist.ptr<Ipp32s>(), (Ipp32s*)(Ipp32f*)*levels, levelNum, (Ipp32s)low, (Ipp32s)high);
12371238
CV_SUPPRESS_DEPRECATED_END
12381239
#endif
12391240
if(status < 0)
@@ -1282,15 +1283,15 @@ static bool ipp_calchist(const Mat* images, int nimages, const int* channels,
12821283
!accumulate && uniform)
12831284
{
12841285
ihist.setTo(Scalar::all(0));
1285-
AutoBuffer<Ipp32f> levels(histSize[0] + 1);
1286+
AutoBuffer<Ipp32f> levels(histSize[0]);
12861287

12871288
bool ok = true;
12881289
const Mat & src = images[0];
12891290
int nstripes = std::min<int>(8, static_cast<int>(src.total() / (1 << 16)));
12901291
#ifdef HAVE_CONCURRENCY
12911292
nstripes = 1;
12921293
#endif
1293-
IPPCalcHistInvoker invoker(src, ihist, levels, histSize[0] + 1, ranges[0][0], ranges[0][1], &ok);
1294+
IPPCalcHistInvoker invoker(src, ihist, levels, histSize[0], ranges[0][0], ranges[0][1], &ok);
12941295
Range range(0, src.rows);
12951296
parallel_for_(range, invoker, nstripes);
12961297

0 commit comments

Comments
 (0)