[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Histogram Hot-shots Required



David Fanning wrote:
> What I can't figure out tonight is how to find out
> what bin that pixel is in, given that I know the pixel
> value. (Even as I write this sentence I have the sense
> that this is a trivial exercise, but I'm afraid it is
> not yielding the shear number of hours I have spent
> on it. At least not for me.)

Assuming I know the minimum and maximum values (the range) used in
creating the histogram, the histogram binsize, and the number of bins,
the zero-based bin index is given by

bin_index = long(float(pixel_value - histogram_min_value) /
float(binsize))

and then to protect against pixel values LT histogram minimum value, or
GE histogram maximum value

bin_index = (bin_index > 0L) < (number_of_bins - 1L)

At least, that's how it looks to me on paper....

Cheers,
Liam.

-- 
Liam E. Gumley
Space Science and Engineering Center, UW-Madison
http://cimss.ssec.wisc.edu/~gumley