fixed sparse histogram update (ticket #526)
This commit is contained in:
parent
e15a2ea95a
commit
79ca6d8995
@ -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 Mat& mask, SparseMat& hist, int dims, const int* histSize,
|
||||||
const float** ranges, bool uniform, bool accumulate, bool keepInt )
|
const float** ranges, bool uniform, bool accumulate, bool keepInt )
|
||||||
{
|
{
|
||||||
SparseMatIterator it;
|
|
||||||
size_t i, N;
|
size_t i, N;
|
||||||
|
|
||||||
if( !accumulate )
|
if( !accumulate )
|
||||||
hist.create(dims, histSize, CV_32F);
|
hist.create(dims, histSize, CV_32F);
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
SparseMatIterator it = hist.begin();
|
||||||
for( i = 0, N = hist.nzcount(); i < N; i++, ++it )
|
for( i = 0, N = hist.nzcount(); i < N; i++, ++it )
|
||||||
{
|
{
|
||||||
int* value = (int*)it.ptr;
|
Cv32suf* val = (Cv32suf*)it.ptr;
|
||||||
*value = cvRound(*(const float*)value);
|
val->i = cvRound(val->f);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
vector<uchar*> ptrs;
|
vector<uchar*> ptrs;
|
||||||
vector<int> deltas;
|
vector<int> deltas;
|
||||||
@ -783,11 +785,14 @@ static void calcHist( const Mat* images, int nimages, const int* channels,
|
|||||||
calcSparseHist_<float>(ptrs, deltas, imsize, hist, dims, ranges, _uniranges, uniform );
|
calcSparseHist_<float>(ptrs, deltas, imsize, hist, dims, ranges, _uniranges, uniform );
|
||||||
|
|
||||||
if( !keepInt )
|
if( !keepInt )
|
||||||
|
{
|
||||||
|
SparseMatIterator it = hist.begin();
|
||||||
for( i = 0, N = hist.nzcount(); i < N; i++, ++it )
|
for( i = 0, N = hist.nzcount(); i < N; i++, ++it )
|
||||||
{
|
{
|
||||||
int* value = (int*)it.ptr;
|
Cv32suf* val = (Cv32suf*)it.ptr;
|
||||||
*(float*)value = (float)*value;
|
val->f = (float)val->i;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user