此页面是从 /doc/source/ipynb/lprec.ipynb. 互动在线版: Binder badge

使用LPrec的TomoPy

下面是一个有关如何使用 log-polar based method 用于TomoPy重建。

若要使用LPrec而不是TomoPy重建图像,请更改 algorithm 关键字至 tomopy.lprec 。属性指定要重建的LPrec算法 lpmethod 关键字。

这两个单元格是用于 Reconstruction with TomoPy

[1]:
import dxchange
import matplotlib.pyplot as plt
import tomopy
[2]:
proj, flat, dark, theta = dxchange.read_aps_32id(
    fname='../../../source/tomopy/data/tooth.h5',
    sino=(0, 2),
)
proj = tomopy.normalize(proj, flat, dark)
rot_center = 296

请注意,使用LPrec时,在透射层析线性化后不能有负值:

[3]:
proj = tomopy.minus_log(proj)
proj[proj < 0] = 0  # no values less than zero with lprec

采用对数极坐标下的FBP方法进行重建。

\[\hat{f}=\mathcal{W}\mathcal{R}^*g\]
[4]:
recon = tomopy.recon(proj,
                     theta,
                     center=rot_center,
                     algorithm=tomopy.lprec,
                     lpmethod='fbp',
                     filter_name='parzen')
recon = tomopy.circ_mask(recon, axis=0, ratio=0.95)
plt.imshow(recon[0, :, :])
plt.show()
Reconstructing 48 slice groups with 2 master threads...
../_images/ipynb_lprec_7_1.png

采用对数极坐标的梯度下降法进行重建。

\[\hat{f} = \text{argmin}_f\lVert\mathcal{R}f-g \rVert_2^2\]
[5]:
recon = tomopy.recon(proj,
                     theta,
                     center=rot_center,
                     algorithm=tomopy.lprec,
                     lpmethod='grad',
                     ncore=1,
                     num_iter=64,
                     reg_par=-1)
recon = tomopy.circ_mask(recon, axis=0, ratio=0.95)
plt.imshow(recon[0, :, :])
plt.show()
Reconstructing 1 slice groups with 1 master threads...
../_images/ipynb_lprec_9_1.png

利用对数极坐标下的共轭梯度法进行重建。

\[\hat{f} = \text{argmin}_f\lVert\mathcal{R}f-g \rVert_2^2\]
[6]:
recon = tomopy.recon(proj,
                     theta,
                     center=rot_center,
                     algorithm=tomopy.lprec,
                     lpmethod='cg',
                     ncore=1,
                     num_iter=16,
                     reg_par=-1)
recon = tomopy.circ_mask(recon, axis=0, ratio=0.95)
plt.imshow(recon[0, :, :])
plt.show()
Reconstructing 1 slice groups with 1 master threads...
../_images/ipynb_lprec_11_1.png

利用对数极坐标的TV方法进行重建。它给出了分段常量重构,可用于去噪。

\[\hat{f} = \text{argmin}_f\lVert\mathcal{R}f-g \rVert_2^2 + \lambda \lVert\nabla f\rVert_1\]
[7]:
recon = tomopy.recon(proj,
                     theta,
                     center=rot_center,
                     algorithm=tomopy.lprec,
                     lpmethod='tv',
                     ncore=1,
                     num_iter=512,
                     reg_par=5e-4)
recon = tomopy.circ_mask(recon, axis=0, ratio=0.95)
plt.imshow(recon[0, :, :])
plt.show()
Reconstructing 1 slice groups with 1 master threads...
../_images/ipynb_lprec_13_1.png

利用对数极坐标下的TV-熵方法进行重建。它可以用来抑制泊松噪声。

\[\hat{f} = \text{argmin}_f \lambda \lVert\nabla f\rVert_1+\int_\Omega\mathcal{R}f-g\log(\mathcal{R}f)df\]
[8]:
recon = tomopy.recon(proj,
                     theta,
                     center=rot_center,
                     algorithm=tomopy.lprec,
                     lpmethod='tve',
                     ncore=1,
                     num_iter=512,
                     reg_par=2e-4)
recon = tomopy.circ_mask(recon, axis=0, ratio=0.95)
plt.imshow(recon[0, :, :])
plt.show()
Reconstructing 1 slice groups with 1 master threads...
../_images/ipynb_lprec_15_1.png

利用对数极坐标的TV-L1方法进行重建。它可以用来去除一定尺度的图像的结构,并且正则化参数 \(\lambda\) 可用于比例选择。

\[\hat{f} = \text{argmin}_f\lVert\mathcal{R}f-g \rVert_1 + \lambda \lVert\nabla f\rVert_1\]
[9]:
recon = tomopy.recon(proj,
                     theta,
                     center=rot_center,
                     algorithm=tomopy.lprec,
                     lpmethod='tvl1',
                     ncore=1,
                     num_iter=512,
                     reg_par=3e-2)
recon = tomopy.circ_mask(recon, axis=0, ratio=0.95)
plt.imshow(recon[0, :, :])
plt.show()
Reconstructing 1 slice groups with 1 master threads...
../_images/ipynb_lprec_17_1.png

利用对数极坐标的MLEM方法进行重建。

[10]:
recon = tomopy.recon(proj,
                     theta,
                     center=rot_center,
                     algorithm=tomopy.lprec,
                     lpmethod='em',
                     ncore=1,
                     num_iter=64,
                     reg_par=0.05)
recon = tomopy.circ_mask(recon, axis=0, ratio=0.95)
plt.imshow(recon[0, :, :])
plt.show()
Reconstructing 1 slice groups with 1 master threads...
../_images/ipynb_lprec_19_1.png
[ ]: