Skip to content

Instantly share code, notes, and snippets.

@devdsp
Last active December 17, 2015 08:39
Show Gist options
  • Save devdsp/5581416 to your computer and use it in GitHub Desktop.
Save devdsp/5581416 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import Image
width, height = 128,512
im = Image.new("RGB", (width,height) )
objective_influence = [[]]*width*height;
def main():
for i in range(height):
for j in range(width):
v = float(i*width+j) # / (width * height)
objective_influence[i*width+j] = v
m = max( objective_influence )
for i in range(height):
for j in range(width):
v = objective_influence[i*width +j] / m
r = 0
g = 0
if v < .5:
r = 255
g = v*2 * 255.0
else:
r = (1 - (v-.5)*2)* 255.0
g = 255
im.putpixel( (j,i), (int(r),int(g),0) )
print im.histogram()
im.save("test.ppm")
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment