Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d5bfbfe

Browse files
committed
mep12 on image_demo2.py
1 parent 8db6f68 commit d5bfbfe

File tree

1 file changed

+16
-19
lines changed

1 file changed

+16
-19
lines changed
Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,32 @@
1-
#!/usr/bin/env python
2-
31
from __future__ import print_function
4-
from pylab import *
2+
# from pylab import *
3+
import matplotlib.pyplot as plt
4+
import numpy as np
55
import matplotlib.cbook as cbook
66

77
w, h = 512, 512
88

99
datafile = cbook.get_sample_data('ct.raw.gz', asfileobj=True)
1010
s = datafile.read()
11-
A = fromstring(s, uint16).astype(float)
12-
A *= 1.0/max(A)
11+
A = np.fromstring(s, np.uint16).astype(float)
12+
A *= 1.0 / max(A)
1313
A.shape = w, h
1414

1515
extent = (0, 25, 0, 25)
16-
im = imshow(A, cmap=cm.hot, origin='upper', extent=extent)
16+
im = plt.imshow(A, cmap=plt.cm.hot, origin='upper', extent=extent)
1717

1818
markers = [(15.9, 14.5), (16.8, 15)]
1919
x, y = zip(*markers)
20-
plot(x, y, 'o')
21-
#axis([0,25,0,25])
22-
20+
plt.plot(x, y, 'o')
2321

24-
#axis('off')
25-
title('CT density')
22+
plt.title('CT density')
2623

2724
if 0:
28-
x = asum(A, 0)
29-
subplot(212)
30-
bar(arange(w), x)
31-
xlim(0, h - 1)
32-
ylabel('density')
33-
setp(gca(), 'xticklabels', [])
34-
35-
show()
25+
x = np.asum(A, 0)
26+
plt.subplot(212)
27+
plt.bar(np.arange(w), x)
28+
plt.xlim(0, h - 1)
29+
plt.ylabel('density')
30+
# setp(gca(), 'xticklabels', [])
31+
plt.xticklabels([])
32+
plt.show()

0 commit comments

Comments
 (0)