blob: eff2012eec066f5debe603ac80dad2b2a05f3d4c (
plain)
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
|
#!/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()
|