diff options
Diffstat (limited to 'ipl/gprocs/popular.icn')
-rw-r--r-- | ipl/gprocs/popular.icn | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/ipl/gprocs/popular.icn b/ipl/gprocs/popular.icn new file mode 100644 index 0000000..0a68a09 --- /dev/null +++ b/ipl/gprocs/popular.icn @@ -0,0 +1,54 @@ +############################################################################ +# +# File: popular.icn +# +# Subject: Procedure to show "popularity" of colors in image string +# +# Author: Ralph E. Griswold +# +# Date: September 17, 1998 +# +############################################################################ +# +# This file is in the public domain. +# +############################################################################ +# +# This procedure shows the "popularity" of colors in an image string. +# +############################################################################ +# +# Requires: Version 9 graphics +# +############################################################################ +# +# Links: imrutils, wopen +# +############################################################################ + +link imrutils +link wopen + +procedure popularity(ims) #: color popularity in image string + local imr, color_tbl, color_list, color + + imr := imstoimr(ims) + + color_tbl := table(0) + + every color_tbl[PaletteColor(imr.palette, !imr.pixels)] +:= 1 + + color_list := sort(color_tbl, 4) + + write("dimensions: ", imr.width, "x", imr.height) + write("pixels: ", *imr.pixels) + write("palette: ", imr.palette) + write("number of different colors: ", *color_tbl) + write() + write("color popularity:") + write() + + while color := pull(color_list) do + write(left(pull(color_list), 20), right(color, 6)) + +end |