avoid crash in cvCalcEMD() when one of the histograms has only one non-zero element (ticket #396). Thanks to nburrus for the patch

pull/13383/head
Vadim Pisarevsky 15 years ago
parent 0faa75da11
commit 62fa7f6620
  1. 6
      modules/imgproc/src/emd.cpp

@ -297,10 +297,14 @@ CV_IMPL float cvCalcEMD2( const CvArr* signature_arr1,
float val = xp->val;
int i = xp->i;
int j = xp->j;
if( xp == state.enter_x )
continue;
int ci = state.idx1[i];
int cj = state.idx2[j];
if( xp != state.enter_x && ci >= 0 && cj >= 0 )
if( ci >= 0 && cj >= 0 )
{
total_cost += (double)val * state.cost[i][j];
if( flow )

Loading…
Cancel
Save