1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
############################################################################
#
# File: spectra.icn
#
# Subject: Program to report color spectra in images
#
# Author: Ralph E. Griswold
#
# Date: November 22, 1996
#
############################################################################
#
# This file is in the public domain.
#
############################################################################
#
# This program analyzes images whose names are given on the command line
# and produces a file with the lists of colors and number of pixels of
# each color. The entries are given in the order of most to least frequent
# color. The color files have the base name of the image file and the
# extension ".spc".
#
############################################################################
#
# Requires: Version 9 graphics
#
############################################################################
#
# Links: basename, imgcolor, wopen
#
############################################################################
link imgcolor
link basename
link wopen
procedure main(args)
local file, colors, output, name, count
every file := !args do {
WOpen("canvas=hidden", "image=" || file) | {
write(&errout, "*** cannot open image file ", file)
next
}
colors := imgcolor()
WClose()
name := basename(file, ".gif")
output := open(name || ".spc", "w") | {
write("*** cannot open ", name, ".spc")
next
}
colors := sort(colors, 4)
while count := pull(colors) do
write(output, left(pull(colors), 20), right(count, 8))
close(output)
&window := &null
}
end
|