粒子滤波直方图

来源:互联网 发布:淘宝无线端其他来源 编辑:程序博客网 时间:2024/06/08 10:16
      /* increment appropriate histogram bin for each pixel */      for( r = 0; r < img->height; r++ )      for( c = 0; c < img->width; c++ )      {        bin = histo_bin( /*pixval32f( h, r, c )*/((float*)(h->imageData + h->widthStep*r) )[c],                 ((float*)(s->imageData + s->widthStep*r) )[c],                 ((float*)(v->imageData + v->widthStep*r) )[c] );        hist[bin] += 1;      }
/*  Calculates the histogram bin into which an HSV entry falls  @param h Hue  @param s Saturation  @param v Value  @return Returns the bin index corresponding to the HSV color defined by    \a h, \a s, and \a v.*/int histo_bin( float h, float s, float v ){  int hd, sd, vd;  /* if S or V is less than its threshold, return a "colorless" bin */  vd = MIN( (int)(v * NV / V_MAX), NV-1 );  if( s < S_THRESH  ||  v < V_THRESH )        return NH * NS + vd;  /* otherwise determine "colorful" bin */  hd = MIN( (int)(h * NH / H_MAX), NH-1 );  sd = MIN( (int)(s * NS / S_MAX), NS-1 );  return sd * NH + hd;}
0 0
原创粉丝点击