Commit 955777e8 authored by Bryson Howell's avatar Bryson Howell

Can create PNG images that GIMP can convert to the unity raw format

parent b1e3ecce
...@@ -2,6 +2,8 @@ import numpy as np ...@@ -2,6 +2,8 @@ import numpy as np
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
from scipy.io import loadmat from scipy.io import loadmat
from PIL import Image from PIL import Image
from PIL import features
#import libtiff
import cv2 import cv2
#Loads matlab matrices created by feature_set.py as numpy arrays #Loads matlab matrices created by feature_set.py as numpy arrays
...@@ -34,6 +36,9 @@ def make_heightmap(elev,savedir): ...@@ -34,6 +36,9 @@ def make_heightmap(elev,savedir):
name = savedir + "kentland_heightmap.raw" name = savedir + "kentland_heightmap.raw"
#Makes sure libtiff is working right
print(features.check('libtiff'))
#fig = plt.figure() #fig = plt.figure()
#plt.imshow(elev) #plt.imshow(elev)
#plt.show() #plt.show()
...@@ -44,19 +49,32 @@ def make_heightmap(elev,savedir): ...@@ -44,19 +49,32 @@ def make_heightmap(elev,savedir):
#elev_gray = np.ushort(elev) #elev_gray = np.ushort(elev)
#elev_gray = np.uint16(elev) #elev_gray = np.uint16(elev)
#From array expects uint8
fig = plt.figure() fig = plt.figure()
plt.imshow(elev_gray) #plt.imshow(elev_gray)
plt.show() #plt.savefig('./unity_data/test.png',pad_inches=0)
#plt.show()
f = open(name,'w') #f = open(name,'w')
#Convert to raw format image #Convert to raw format image
img = Image.fromarray(elev_gray) elev_int8 = (elev_gray*255).astype(np.uint8)
img = Image.fromarray(elev_int8)
img.save('./unity_data/kentland_gimptest.png')
img = img.convert('L') img = img.convert('L')
img.save('./unity_data/kentland_gray.raw', 'TIFF', compression='raw')
#img = img.convert('1')
#img = img.convert('I;16') #img = img.convert('I;16')
img.save(name, 'PNG') #Should I add L or B to the end (endian)
img = img.convert('1')
img.save(name, 'TIFF', compression='tiff_raw_16') #want tiff_raw_16
img.show() img.show()
#cv2.imshow('Kentland Heightmap',elev_gray) #cv2.imshow('Kentland Heightmap',elev_gray)
#cv2.waitKey(0) #cv2.waitKey(0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment