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

Skip to content

Commit 12efb7f

Browse files
committed
Merge pull request #4826 from ericmjl/mep12_image_demo2.py
mep12 on image_demo2.py
2 parents afc0280 + 1df0074 commit 12efb7f

File tree

1 file changed

+9
-20
lines changed

1 file changed

+9
-20
lines changed
Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,24 @@
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-
23-
24-
#axis('off')
25-
title('CT density')
20+
plt.plot(x, y, 'o')
2621

27-
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', [])
22+
plt.title('CT density')
3423

35-
show()
24+
plt.show()

0 commit comments

Comments
 (0)