Skip to content

Instantly share code, notes, and snippets.

@BilHim
Last active May 25, 2020 01:01
Show Gist options
  • Save BilHim/c2bb44202db0a842d82a67131e27fddf to your computer and use it in GitHub Desktop.
Save BilHim/c2bb44202db0a842d82a67131e27fddf to your computer and use it in GitHub Desktop.
from PIL import Image
width = 800
height = 600
def getpixel(x, y):
n = 0.5 # Get value here
return int(255*n)
# Create a new image. L for grayscale
im = Image.new('L', (width, height))
for x in range(width):
for y in range(height):
im.putpixel((x, y), getpixel(x, y))
im.save('displacement_map.png')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment