"Roy Schestowitz" <newsgroups@xxxxxxxxxxxxxxx> wrote in message
> __/ [ tirzan ] on Monday 27 March 2006 16:31 \__
>> Roy Schestowitz wrote:
>>> You can look up a precise description by searching the Web. In short,
>>> histogram bins involve taking the pixels whose values lie within a given
>>> range (say 0..255) and then partitioning that range into smaller chunks
>>> (bins or 'buckets'). You could, for example, have a bin that contains
>>> pixels whose (grey-level) value is between 1 and 10.
>> yes! thanks!
>>> What are "min" and "max"?
>> the min and the max grey value on the image, we can consider min=0 and
>> but (maybe) is more convenient to calculate the min and the max
>>> This seems okay, but why not use many of the
>>> existing implementation, which could be /far/ more efficient?
>> do you have any link? or any example of a more efficient
>>> Hope it helps,
> Have a look at VXL:
> It is very extensive and Open Source too.
> Hope it helps,
> Roy S. Schestowitz | Useless fact: sheep outnumber people in NZ
> http://Schestowitz.com | SuSE Linux ¦ PGP-Key: 0x74572E8E
> 6:15pm up 19 days 8:00, 8 users, load average: 1.36, 0.91, 0.74
> http://iuron.com - help build a non-profit search engine
Histograms are very simple. Here's some code (UNTESTED!!)
#define BINS 64
unsigned long histogram[BINS];
unsigned long histo_total;
unsigned long histo_perc;
int total_pixels = image_width * image_height;
for(int y = 0; y<image_height;y++)
pixel_value = GetPixel(x,y);
// You may want to normalise the histogram
// This loop gives the bins as a percentage of the total number of pixels
// NB you may want to multiply by a larger value or make the histogram array
of type float to get better than 1% resolution here
histogram[i] = histogram[i] * 100 / histo_total;
// You may want to find the grey level of a percentile, e.g. the median
brighness, or the level that 90% of pixels are darker than
// These can be useful in automatic thresholding
// This code assumes you have normalised. If not then scale the histo_total
to get the stopping condition, in place of 90 here.
histo_perc = 0;
histo_perc += histogram[i];
if(histo_perc > 90) break;
// i is the grey level bin of the 90th percentile
// The actual grey level is then
result = i*256/BINS;