-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathSampleCreator.py
More file actions
executable file
·34 lines (27 loc) · 916 Bytes
/
Copy pathSampleCreator.py
File metadata and controls
executable file
·34 lines (27 loc) · 916 Bytes
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
#!/usr/bin/env python3
__version__ = '2.1'
__licence__ = 'FreeBSD License'
__author__ = 'Robert Gawron'
import sys
import os
from PIL import Image
from srconfig import cfg
import Camera
from SRImage import SRImage
def createSamples(image, outDirectory, scale):
camera = Camera.Camera(cfg['psf'])
downscale = 1.0 / scale
# TODO move it somewhere
offsets = [[0,0], [1,0], [2,0],
[0,1], [1,1], [2,1],
[0,2], [1,2], [2,2]]
for (x, y) in offsets:
sampleFileName = '%s/S_%d_%d.tif' % (outDirectory, x, y)
sample = SRImage()
sample.openFromLibImg(camera.take(image.toLibImgType(), (x, y), downscale))
sample.save(sampleFileName)
def main(inImageFileName, outDirName, scale):
inImage = SRImage()
inImage.openFromFile(inImageFileName)
os.makedirs(outDirName, exist_ok = True)
createSamples(inImage, outDirName, scale)