CT典型数据——shepp_logan体模数据的生成 python版本

phantominator包介绍

基本用法:生成shepp_logan体模

import phantominator
from phantominator import shepp_logan

import matplotlib.pyplot as plt

2D体模

# 基本用法
# 2D CT
# 输出典型的体模,取值为[0,1] 参数为:
"""
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体模

# 3D CT
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)

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-wqeA0bvw-1610505201695)(output_6_1.png)]

生成震荡的同心圆

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()

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-ZpS5lMTB-1610505201696)(output_9_0.png)]

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值