From: Vadim Pisarevsky Date: Wed, 10 Nov 2010 21:23:04 +0000 (+0000) Subject: fixed sparse histogram update (ticket #526) X-Git-Tag: accepted/2.0/20130307.220821~4249 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=79ca6d8995723e73a9721817ce84f5854890f15d;p=profile%2Fivi%2Fopencv.git fixed sparse histogram update (ticket #526) --- diff --git a/modules/imgproc/src/histogram.cpp b/modules/imgproc/src/histogram.cpp index 3da9d7c..a68f301 100644 --- a/modules/imgproc/src/histogram.cpp +++ b/modules/imgproc/src/histogram.cpp @@ -754,17 +754,19 @@ static void calcHist( const Mat* images, int nimages, const int* channels, const Mat& mask, SparseMat& hist, int dims, const int* histSize, const float** ranges, bool uniform, bool accumulate, bool keepInt ) { - SparseMatIterator it; size_t i, N; if( !accumulate ) hist.create(dims, histSize, CV_32F); else + { + SparseMatIterator it = hist.begin(); for( i = 0, N = hist.nzcount(); i < N; i++, ++it ) { - int* value = (int*)it.ptr; - *value = cvRound(*(const float*)value); + Cv32suf* val = (Cv32suf*)it.ptr; + val->i = cvRound(val->f); } + } vector ptrs; vector deltas; @@ -783,11 +785,14 @@ static void calcHist( const Mat* images, int nimages, const int* channels, calcSparseHist_(ptrs, deltas, imsize, hist, dims, ranges, _uniranges, uniform ); if( !keepInt ) + { + SparseMatIterator it = hist.begin(); for( i = 0, N = hist.nzcount(); i < N; i++, ++it ) { - int* value = (int*)it.ptr; - *(float*)value = (float)*value; + Cv32suf* val = (Cv32suf*)it.ptr; + val->f = (float)val->i; } + } }