[vox-tech] count pixels

Ken Bloom kbloom at gmail.com
Thu Feb 22 08:29:44 PST 2007


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

-- 
Ken Bloom. PhD candidate. Linguistic Cognition Laboratory.
Department of Computer Science. Illinois Institute of Technology.
http://www.iit.edu/~kbloom1/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.lugod.org/pipermail/vox-tech/attachments/20070222/e1661b50/attachment.pgp


More information about the vox-tech mailing list