diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2013-01-27 23:51:56 +0000 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2013-01-27 23:51:56 +0000 |
commit | 6ab0c0f5bf14ed9c15370407b9ee7e0b4b089ae1 (patch) | |
tree | 926065cf45450116098db664e3c61dced9e1f21a /ipl/gprocs/popular.icn | |
download | icon-6ab0c0f5bf14ed9c15370407b9ee7e0b4b089ae1.tar.gz |
Initial upstream version 9.4.3upstream/9.4.3
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 |