A fake log filter stage while I work on other stuff

This commit is contained in:
Steven Robertson 2010-09-12 02:32:03 -04:00
parent c13f6a06cf
commit ce0571deaf

15
main.py
View File

@ -40,11 +40,16 @@ def main(args):
anim = Animation(genomes) anim = Animation(genomes)
anim.compile() anim.compile()
bins = anim.render_frame() bins = anim.render_frame()
#bins = np.log2(bins + 1)
alpha = [bins[y][x][3] for x in range(anim.features.hist_width) # Embarrassingly poor (and s-l-o-w) approximation of log filtering, because
for y in range(anim.features.hist_height)] # I want to keep working on performance right now
print sum(alpha) alpha = np.array([[bins[y][x][3] for x in range(anim.features.hist_width)]
bins *= (512./(np.mean(alpha)+1e-9)) for y in range(anim.features.hist_height)])
k2ish = (256./(np.mean(alpha)+1e-9))
lses = 20 * np.log2(1.0 + alpha * k2ish) / (alpha+1e-6)
for x in range(anim.features.hist_width):
for y in range(anim.features.hist_height):
bins[y][x] *= lses[y][x]
bins = np.minimum(bins, 255) bins = np.minimum(bins, 255)
bins = bins.astype(np.uint8) bins = bins.astype(np.uint8)