This repository has been archived by the owner on Jan 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhdriedit.py
85 lines (65 loc) · 2.11 KB
/
hdriedit.py
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import sys, numpy, pygame, time, scipy
import scipy.ndimage
from imgutils import Image
from scipy.misc import toimage
# pylint: disable-msg=C0103
if len(sys.argv)==1:
fns = [raw_input("file name: ").strip()]
else:
fns = sys.argv[1:]
data = None
for fn in fns:
d = numpy.nan_to_num(numpy.load(fn))
print "opened numpy matrix of size "+str(d.shape)
if data == None:
data = d
else:
data += d
image = Image(data = data)
image.show()
print """-----------
Valid commans are:
[any number]
(for example 0.1, 2, 0.9234)
show and output an image whose brightness has been multiplied by that
number (e.g. 2 outputs an image that is "two times brighter" than the image
corresponding to 1)
gamma [number] (or g [number])
set gamma correction value (default %s)
sweep (or s)
display the image using various brightnesses
flares (or f)
toggle flares (affect over-exposure)
CTRL-D (or any unrecognized input)
quit / crash :)
The first and second of the above output an image named 'out-24bit.png'
-----------
""" % image.settings.gamma
while True:
line = raw_input("cmd: ").split()
cmd = line[0]
if cmd == "sweep" or cmd == "s":
bright0 = image.settings.brightness
Nsteps = 200
log_min = -5
log_max = 2
vals = numpy.linspace(log_min, log_max, Nsteps)
vals = numpy.exp(vals)
for v in vals:
print v
image.settings.brightness = v
image.show(data)
time.sleep(0.01)
image.settings.brightness = bright0
else:
if cmd == "flares" or cmd == "f":
image.settings.flares = image.settings.flares == False
print "flares %s" % image.settings.flares
elif cmd == "gamma" or cmd == "g":
image.settings.gamma = float(line[1])
elif cmd == "brightness" or cmd == "b":
image.settings.brightness = float(line[1])
else:
image.settings.brightness = float(cmd)
image.show(data)
image.save_png('hdriedit-out.png')