--- /dev/null
+#!/usr/bin/python
+
+import sys
+
+if len(sys.argv) < 3:
+ sys.stderr.write("usage: icom FILE1 FILE2\n")
+
+tsz = (25, 25)
+
+files = []
+
+for i in xrange(2):
+ f = open(sys.argv[i + 1])
+ lines = []
+ for y in xrange(tsz[1]):
+ line = []
+ for x in xrange(tsz[0]):
+ p = []
+ for c in f.read(3):
+ p.append(ord(c))
+ line.append(tuple(p))
+ lines.append(line)
+ files.append(lines)
+ f.close()
+
+sum = 0
+
+for y in xrange(tsz[1]):
+ for x in xrange(tsz[0]):
+ p = [f[y][x] for f in files]
+ for c in xrange(2):
+ sum += abs(p[0][c] - p[1][c])
+
+print sum
--- /dev/null
+#!/usr/bin/python
+
+import sys, os
+from popen2 import popen2
+
+def combine(list):
+ for i in xrange(len(list) - 1):
+ for o in xrange(i + 1, len(list)):
+ yield list[i], list[o]
+
+if len(sys.argv) < 2:
+ sys.stderr.write("usage: icom-dir DIRECTORY\n")
+
+files = os.listdir(sys.argv[1])
+files.sort()
+pj = os.path.join
+
+for file1, file2 in combine(files):
+ co, ci = popen2(["icom", pj(sys.argv[1], file1), pj(sys.argv[1], file2)])
+ ci.close()
+ index = int(co.readline().split()[0])
+ co.close()
+ sys.stdout.write("%i %s %s\n" % (index, file1, file2))
--- /dev/null
+#!/usr/bin/python
+
+import sys
+import Image
+
+if len(sys.argv) < 3:
+ sys.stderr.write("usage: icom-gen INFILE OUTFILE\n")
+
+inf = Image.open(sys.argv[1])
+sz = inf.size
+tsz = (25, 25)
+out = []
+
+for y in xrange(tsz[1]):
+ line = []
+ for x in xrange(tsz[0]):
+ sum = [0, 0, 0]
+ n = 0
+ for y2 in xrange(y * sz[1] / tsz[1], (y + 1) * sz[1] / tsz[1]):
+ for x2 in xrange(x * sz[0] / tsz[0], (x + 1) * sz[0] / tsz[0]):
+ p = inf.getpixel((x2, y2))
+ for c in xrange(3):
+ sum[c] += p[c]
+ n += 1
+ for c in xrange(3):
+ sum[c] /= n
+ line.append(tuple(sum))
+ out.append(line)
+
+f = open(sys.argv[2], "w")
+for line in out:
+ for p in line:
+ for c in p:
+ f.write(chr(c))
+f.close()