[vox-tech] count pixels

Wade Pinkston blata at extent0006.entomology.ohio-state.edu
Thu Feb 22 09:57:01 PST 2007


Thanks exactly what I was looking for.

Ken Bloom wrote:
> On Thursday 22 February 2007 10:09, Wade Pinkston wrote:
>> I put a webpage up with an example.
>>
>> http://bugs.osu.edu/wade
>>
>> As you can see its the same image but the first has no damage.  The
>> second has damage.  So what I need it the percent difference.
> 
> $ convert red4.jpg -colors 16 red4.pnm
> $ ppmhist red4.pnm
>    r     g     b         lum     count
>  ----- ----- -----      -----   -------
>    253     0     1         76     32518
>     82   114    73        100      3886
>     73   104    55         89      2273
>     58    84    42         71      1972
>    111   144   107        130      1880
>    231    35    39         94      1277
>    101   135    87        119      1114
>     71    91    50         80       705
>    155   176   144        166       681
>    104   130    60        114       537
>     59    57    22         54       479
>     53    80    31         66       467
>    100   118    81        108       440
>    189    77    67        109       327
>    146   156   111        148       301
>    136   154   131        146       295
> $ convert red5.jpg -colors 16 red5.pnm
> $ ppmhist red5.pnm
>    r     g     b         lum     count
>  ----- ----- -----      -----   -------
>    253     0     1         76     33386
>     82   114    73        100      3466
>     74   104    55         89      1979
>     58    83    42         71      1829
>    111   144   107        130      1701
>    227    34    36         92      1438
>    101   135    87        119      1074
>     74    90    50         81       800
>    156   176   144        166       667
>    104   130    60        114       503
>     59    57    22         54       467
>     53    79    30         66       446
>    100   118    81        108       420
>    183    75    61        106       384
>    147   156   111        148       299
>    136   153   131        145       293
> 
> Or to even more clearly cluster the pixels of different colors:
> $ convert red5.jpg -colors 2 red5.pnm
> $ ppmhist red5.pnm
>    r     g     b         lum     count
>  ----- ----- -----      -----   -------
>    252     2     2         77     34627
>     87   115    72        102     14525
> $ convert red4.jpg -colors 2 red4.pnm
> $ ppmhist red4.pnm
>    r     g     b         lum     count
>  ----- ----- -----      -----   -------
>    252     2     2         77     33605
>     87   115    72        102     15547
> 
> Now you can easlily compute the percentage difference
> 
> (15547.0-14525.0)/15547.0
> => 0.0657361548851869
> 
> Thanks to Henry House for suggesting ppmhist.
> 
> --Ken
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> vox-tech mailing list
> vox-tech at lists.lugod.org
> http://lists.lugod.org/mailman/listinfo/vox-tech

-- 
Wade Pinkston

Ipsa scientia potestas est

Windows,a
32 bit graphical interface for a
16 bit patch to an
8 bit operating system internally coded for a
4 bit processor written by a
2 bit company that can't stand
1 bit of competition



More information about the vox-tech mailing list