Commit 9a670e41 authored by David E. DeMarle's avatar David E. DeMarle

Merge branch 'changes-for-paraview-export-now' into 'master'

make show raster better

See merge request !127
parents d4fa331c 4bd86971
Pipeline #134423 pending with stage
......@@ -3,6 +3,7 @@ import PIL.Image
import PIL.ImImagePlugin
import numpy as np
import zlib
import numpy.ma as ma
if len(sys.argv) < 2:
print "supply filename of a raster file"
......@@ -47,11 +48,16 @@ if ext == ".npz":
imageslice = np.multiply(np.subtract(imageslice, mm[0]), 255)
im = PIL.Image.fromarray(imageslice)
elif ext == ".Z":
with open(fname, mode='r') as file:
with open(fname, mode='rb') as file:
compresseddata = file.read()
flatarr = np.fromstring(zlib.decompress(compresseddata),
np.float32)
im = PIL.Image.fromarray(flatarr.reshape((zlib_width, zlib_height)))
flatarr = np.fromstring(zlib.decompress(compresseddata),
np.float32)
flatarr = ma.masked_invalid(flatarr)
mxval = flatarr.max()
mnval = flatarr.min();
print "MIN AND MAX ARE ", mnval, mxval
flatarr = flatarr.filled(0)*255/(mxval-mnval)+mnval #scale and bias into 0..255 for display
im = PIL.Image.fromarray(flatarr.reshape((zlib_width, zlib_height)))
else:
im = PIL.Image.open(fname)
asnumpy = np.array(im, np.float32)
......
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