From fde247b651ab1ae706c2e46d8918caca9ff332d8 Mon Sep 17 00:00:00 2001 From: David Vierra Date: Wed, 17 Oct 2012 12:19:01 -1000 Subject: [PATCH] Change data type of computed heightmap arrays to signed integer to avoid unsigned overflow. Code that works with heightmaps such as filters/smooth.py will subtract two heights expecting to get a negative integer. Getting a very large positive one usually causes an error, so make sure signed int arithmetic gets used. --- level.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/level.py b/level.py index 3b0a371..cc87812 100644 --- a/level.py +++ b/level.py @@ -50,7 +50,7 @@ def extractHeights(array): # from each column. w, h = array.shape[:2] - heightMap = zeros((w, h), 'uint16') + heightMap = zeros((w, h), 'int16') heights = argmax((array > 0)[..., ::-1], 2) heights = array.shape[2] - heights