From c9efcf8d1fd5e520d42bd4b247c36e9bc8b2d60e Mon Sep 17 00:00:00 2001 From: Alexander Shishkov Date: Wed, 28 Mar 2012 15:12:12 +0000 Subject: [PATCH] fixed #1616 --- modules/imgproc/src/histogram.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/modules/imgproc/src/histogram.cpp b/modules/imgproc/src/histogram.cpp index 960a26fa3..546c215e1 100644 --- a/modules/imgproc/src/histogram.cpp +++ b/modules/imgproc/src/histogram.cpp @@ -1350,7 +1350,18 @@ void cv::calcBackProject( InputArrayOfArrays images, const vector& channels const vector& ranges, double scale ) { - Mat H = hist.getMat(); + Mat H0 = hist.getMat(), H; + int hcn = H0.channels(); + if( hcn > 1 ) + { + CV_Assert( H0.isContinuous() ); + int hsz[CV_CN_MAX+1]; + memcpy(hsz, &H0.size[0], H0.dims*sizeof(hsz[0])); + hsz[H0.dims] = hcn; + H = Mat(H0.dims+1, hsz, H0.depth(), H0.data); + } + else + H = H0; bool _1d = H.rows == 1 || H.cols == 1; int i, dims = H.dims, rsz = (int)ranges.size(), csz = (int)channels.size(); int nimages = (int)images.total();