HOME Mathematics Computer Science
Heightmaps
Heightmaps

Introduction
  • Heightmaps are a way of representing a 3D surface as a 2D image.
  • Each pixel in the 2D image corresponds to a specific point on the 3D surface.
  • The brightness of the pixel determines the height of the point:
    • A dark pixel is a low point
    • A bright pixel is a high point
Image rendered in SketchUp
Code
from PIL import Image

im = Image.new("L", (256, 256))
pix = im.load()

for x in range(256):
    for y in range(256):
        pix[x,y] = 256 - abs(x - 128) - abs(y - 128)

im.save("test.png", "PNG")
im.show()