/* 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 tothe 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 isless thanits 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;
}
/* 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 )*/((floa