phantominator包介绍
- 网址:https://github.com/mckib2/phantominator
- 安装:pip install phantominator
- 简介:用于简便的生成 numerical phantoms 的 python 包
基本用法:生成shepp_logan体模
import phantominator
from phantominator import shepp_logan
import matplotlib.pyplot as plt
2D体模
"""
E = np.zeros((10, 6)) # (10, [A, a, b, xc, yc, theta])
E[:, 0] = [2, -.98, -.02, -.02, .01, .01, .01, .01, .01, .01]
E[:, 1] = [
.69, .6624, .11, .16, .21, .046, .046, .046, .023, .023]
E[:, 2] = [.92, .874, .31, .41, .25, .046, .046, .023, .023, .046]
E[:, 3] = [0, 0, .22, -.22, 0, 0, 0, -.08, 0, .06]
E[:, 4] = [0, -.0184, 0, 0, .35, .1, -.1, -.605, -.605, -.605]
E[:, 5] = np.deg2rad([0, 0, -18, 18, 0, 0, 0, 0, 0, 0])
return E
"""
ph = shepp_logan(512)
print(ph.shape)
print(ph)
plt.imshow(ph, cmap='gray')
plt.show()
(512, 512)
[[0. 0. 0. ... 0. 0. 0.]
[0. 0. 0. ... 0. 0. 0.]
[0. 0. 0. ... 0. 0. 0.]
...
[0. 0. 0. ... 0. 0. 0.]
[0. 0. 0. ... 0. 0. 0.]
[0. 0. 0. ... 0. 0. 0.]]
3D体模
ph3d = shepp_logan((512, 512, 6), zlims=(-.25, .25))
print(ph3d.shape)
plt.figure(figsize=(15, 15))
n = ph3d.shape[-1]
for i in range(n):
img = ph3d[:,:,i]
plt.subplot(1, n, i + 1)
plt.imshow(img, cmap="gray")
plt.show()
(512, 512, 6)
生成震荡的同心圆
from phantominator import dynamic
import math
phd = dynamic(128, 20)
print(ph.shape)
(128, 128, 20)
cols = 6
rows = math.ceil(phd.shape[-1] / cols)
n = phd.shape[-1]
plt.figure(figsize=(15, 15))
for i in range(n):
img = phd[:,:,i]
plt.subplot(rows, cols, i + 1)
plt.imshow(img, cmap="gray")
plt.show()
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)