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

Re: how to count % color coverage?



On 8/26/05, Paolo Pedaletti <paolo.pedaletti@unimib.it> wrote:

> My best wish would be:
> 
> Color 0: 1.4%
> Color 2: 4.5%
> Color 10: 50.1%
> ....
> ...
> 
> (% of surface, image extension)

You need the netpbm package.

$ giftopnm image.gif > image.ppm
$ pamfile image.ppm   # get the dimension
image.ppm:       PPM raw, 50 by 48  maxval 255
$ ppmhist image.ppm   # create histogram
   r     g     b         lum     count
 ----- ----- -----      -----   -------
     0     0     0          0      1631
    51    51    51         51         9
   166   166   166        166         9
   136   136   136        136         9
   161   161   161        161         8
[...]

The colors are given by RGB values and count is the number of pixels
of given color. Divide by the total number of pixels for percentages.

Hope this helps.

Igor



Reply to: