MCPcopy Create free account
hub / github.com/creatale/node-dv / cvCopyHist

Function cvCopyHist

deps/opencv/modules/imgproc/src/histogram.cpp:2600–2663  ·  view source on GitHub ↗

copies one histogram to another

Source from the content-addressed store, hash-verified

2598
2599// copies one histogram to another
2600CV_IMPL void
2601cvCopyHist( const CvHistogram* src, CvHistogram** _dst )
2602{
2603 if( !_dst )
2604 CV_Error( CV_StsNullPtr, "Destination double pointer is NULL" );
2605
2606 CvHistogram* dst = *_dst;
2607
2608 if( !CV_IS_HIST(src) || (dst && !CV_IS_HIST(dst)) )
2609 CV_Error( CV_StsBadArg, "Invalid histogram header[s]" );
2610
2611 bool eq = false;
2612 int size1[CV_MAX_DIM];
2613 bool is_sparse = CV_IS_SPARSE_MAT(src->bins);
2614 int dims1 = cvGetDims( src->bins, size1 );
2615
2616 if( dst && (is_sparse == CV_IS_SPARSE_MAT(dst->bins)))
2617 {
2618 int size2[CV_MAX_DIM];
2619 int dims2 = cvGetDims( dst->bins, size2 );
2620
2621 if( dims1 == dims2 )
2622 {
2623 int i;
2624
2625 for( i = 0; i < dims1; i++ )
2626 {
2627 if( size1[i] != size2[i] )
2628 break;
2629 }
2630
2631 eq = (i == dims1);
2632 }
2633 }
2634
2635 if( !eq )
2636 {
2637 cvReleaseHist( _dst );
2638 dst = cvCreateHist( dims1, size1, !is_sparse ? CV_HIST_ARRAY : CV_HIST_SPARSE, 0, 0 );
2639 *_dst = dst;
2640 }
2641
2642 if( CV_HIST_HAS_RANGES( src ))
2643 {
2644 float* ranges[CV_MAX_DIM];
2645 float** thresh = 0;
2646
2647 if( CV_IS_UNIFORM_HIST( src ))
2648 {
2649 for( int i = 0; i < dims1; i++ )
2650 ranges[i] = (float*)src->thresh[i];
2651
2652 thresh = ranges;
2653 }
2654 else
2655 {
2656 thresh = src->thresh2;
2657 }

Callers 2

icvCloneHistFunction · 0.85

Calls 5

cvGetDimsFunction · 0.85
cvReleaseHistFunction · 0.85
cvCreateHistFunction · 0.85
cvSetHistBinRangesFunction · 0.85
cvCopyFunction · 0.85

Tested by

no test coverage detected