]> git.sesse.net Git - gifmaker/commitdiff
Add a Perl script to convert the output of find-pairwise-distance to a PGM file for... master
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 25 Jul 2013 20:00:19 +0000 (22:00 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 25 Jul 2013 20:00:19 +0000 (22:00 +0200)
pairwise-to-pgm.pl [new file with mode: 0644]

diff --git a/pairwise-to-pgm.pl b/pairwise-to-pgm.pl
new file mode 100644 (file)
index 0000000..3e11fc8
--- /dev/null
@@ -0,0 +1,17 @@
+#! /usr/bin/perl
+use strict;
+use warnings;
+use POSIX;
+
+my $width = 599;
+my $height = 599;
+my $max = 7263081;
+
+print "P5\n$width $height\n255\n";
+while (<>) {
+       /(\d+) (\d+) (\d+)/ or die;
+       my ($i, $j, $z) = ($1, $2, $3);
+       $z = log($z + 1.0) / log($max + 1.0);
+       $z = pow($z, 20);
+       print chr(int(255.0 * $z));
+}