summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2016-08-16 16:57:51 +0100
committerCarl Hetherington <cth@carlh.net>2016-08-16 16:57:51 +0100
commit555affbf3f180efed31a3582a7bcf592009627b4 (patch)
tree14f1e2a7dab7c0c13bbe2f16d596de1e60fc3de0
parent94b3924ed3cbf4fbfa2445ca1007f25c53dc8b60 (diff)
Add hack.
-rw-r--r--hacks/testcard.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/hacks/testcard.py b/hacks/testcard.py
new file mode 100644
index 000000000..eff2012ee
--- /dev/null
+++ b/hacks/testcard.py
@@ -0,0 +1,38 @@
+#!/usr/bin/python
+
+from PIL import Image
+import numpy
+from libtiff import TIFF
+
+width = 1998
+height = 1080
+filename = 'test.tif'
+
+im = numpy.zeros((height, width, 3), dtype=numpy.uint16)
+
+# Convert 12 to 16-bit
+def pixel(x):
+ return x << 4
+
+# Bars of increasing intensity in X
+for x in range(0, width):
+ for y in range(0, height):
+ if x < 400:
+ im[y][x][0] = pixel(0)
+ elif x < 800:
+ im[y][x][0] = pixel(1024)
+ elif x < 1200:
+ im[y][x][0] = pixel(2048)
+ elif x < 1600:
+ im[y][x][0] = pixel(3072)
+ else:
+ im[y][x][0] = pixel(4095)
+
+# Ramp in Y
+for x in range(0, width):
+ for y in range(0, height):
+ im[y][x][1] = pixel((x * 4) % 4096)
+
+tiff = TIFF.open(filename, mode='w')
+tiff.write_image(im, write_rgb=True)
+tiff.close()