有关过滤器反投影的详细信息的问题



最近我一直在研究过滤器反投影,并从github.com下载了代码。我对过滤器反投影的过程感到困惑。这是他的部分代码:

def backproject(sinogram, theta):
"""Backprojection function. 
inputs:  sinogram - [n x m] numpy array where n is the number of projections and m the number of angles
theta - vector of length m denoting the angles represented in the sinogram
output: backprojArray - [n x n] backprojected 2-D numpy array"""
imageLen = sinogram.shape[0] #sinogram : [n x m] , so imageLen = n(height)
reconMatrix = np.zeros((imageLen, imageLen)) 

x = np.arange(imageLen)-imageLen/2 
y = x.copy()
X, Y = np.meshgrid(x, y) 
plt.ion() 
fig2, ax = plt.subplots() 
im = plt.imshow(reconMatrix, cmap='gray') 
theta = theta*np.pi/180 
numAngles = len(theta)
for n in range(numAngles):
Xrot = X*np.sin(theta[n])-Y*np.cos(theta[n]) 
XrotCor = np.round(Xrot+imageLen/2) 

XrotCor = XrotCor.astype('int') 
projMatrix = np.zeros((imageLen, imageLen)) 
m0, m1 = np.where((XrotCor >= 0) & (XrotCor <= (imageLen-1))) 

s = sinogram[:,n] 
projMatrix[m0, m1] = s[XrotCor[m0, m1]] 
reconMatrix += projMatrix
im.set_data(Image.fromarray((reconMatrix-np.min(reconMatrix))/np.ptp(reconMatrix)*255)) 
                          
ax.set_title('Theta = %.2f degrees' % (theta[n]*180/np.pi))
fig2.canvas.draw()
fig2.canvas.flush_events()

plt.close()
plt.ioff()
backprojArray = np.flipud(reconMatrix) 
return backprojArray

对于循环"For",我困惑了两个星期。首先,我真的不知道下面的代码。

Xrot = X*np.sin(theta[n])-Y*np.cos(theta[n]) 
XrotCor = np.round(Xrot+imageLen/2) .

我不知道它是如何通过几何方式工作的。我已经淹没了矩阵等等,但我仍然不知道其原理。最后,对于代码im.set_data(Image.fromarray((reconMatrix-np.min(reconMatrix))/np.ptp(reconMatrix)*255)),它意味着什么,因为我只知道直接反投影。我真的不知道为什么有255

Xrot = X*np.sin(theta[n])-Y*np.cos(theta[n])
这是一种简单的反投影算法。我也在学习,所以我会尽量让它简单简洁。FBP有一些步骤。

  • 输入Sinogram图像(Radon变换(_创建滤波器(Ram滤波器效果最好,但您也可以尝试其他高通滤波器(
  • 前向傅立叶变换(dft函数(
  • 应用筛选器
  • 傅立叶逆变换
  • 反投影(基本上与正弦图技术相反(反投影只是对值进行反投影,并将它们相加,以获得每个投影的原始图像。im.set_data(Image.fromarray((reconMatrix-.min(reconMatrix))/np.ptp(reconMatrix)*255))
    我相信这段代码是在规范图像,而不是其他

相关内容

最新更新