Menu

[r8110]: / branches / mathtex / examples / tests / pngsuite / pngsuite.py  Maximize  Restore  History

Download this file

30 lines (22 with data), 672 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"""
This test loads a subset of the files in Willem van Schaik's PNG test
suite available here:
http://libpng.org/pub/png/pngsuite.html
The result should look like truth.png.
"""
from matplotlib import pyplot as plt
import matplotlib.cm as cm
import glob
files = glob.glob("basn*.png")
files.sort()
plt.figure(figsize=(len(files), 2))
for i, fname in enumerate(files):
data = plt.imread(fname)
cmap = None # use default colormap
if data.ndim==2:
# keep grayscale images gray
cmap = cm.gray
plt.imshow(data, extent=[i,i+1,0,1], cmap=cmap)
plt.gca().get_frame().set_facecolor("#ddffff")
plt.gca().set_xlim(0, len(files))
plt.show()