Professional Documents
Culture Documents
Bài tập về nhà: Code
Bài tập về nhà: Code
MSSV: 18230031
Code:
import numpy as np
import scipy.ndimage as nd
import cv2
#plt.imshow(image)
#plt.show()
#ax1.set_title("Original")
#ax1.imshow(image,cmap=plt.cm.Greys_r)
plt.imshow(sinogram)
plt.show()
#print(len(theta))
#plt.imshow(reconstruction_fbp)
#plt.show()
#ax2.set_title("Radon transform\n(Sinogram)")
#ax2.imshow(sinogram, cmap=plt.cm.Greys_r,
#plt.show()
A1= fft.fft2(sinogram)
#A1=fft.fftshift(A1)
#A1= np.abs(A1)
#plt.imshow(A1)
#plt.show()
#print(A1)
import numpy as np
x, y = np.meshgrid(np.linspace(-1,1,100), np.linspace(-1,1,200))
d = np.sqrt(x*x+y*y)
sigma =0.01
#plt.imshow(g)
#plt.show()
A2= fft.fft2(g)#fourier h
#A2= fft.fftshift(A2)
#A2=np.abs(A2)
#plt.imshow(A2)
#plt.show()
A1=np.array(A1)
A2=np.array(A2)
A3= (A1*A2)#
A4=fft.fftshift(A4)
#fig,ax= subplots()
#ax.scatter(A4.real,A4.imag)
A41=np.abs(A4)
plt.imshow(A41)
plt.show()
#misc.imsave("A4.bmp")
#ax1.set_title("sinogram dau")
#ax1.imshow(A4, cmap=plt.cm.Greys_r,
#ax2.set_title("Sinogram sau")
#ax2.imshow(A4, cmap=plt.cm.Greys_r,
plt.imshow(reconstruction_fbp)
plt.show()
seed(1)
gauss_noise=np.zeros((200,100))
#value=gauss(0,1)
for i in range(0,200):
for j in range(0,100):
gauss_noise[i][j]=gauss(0,5000)
A5=A4+gauss_noise
#A5=fft.fftshift(A5)
#fig,ax= subplots()
#ax.scatter(A4.real,A4.imag)
A5=np.abs(A5)
plt.imshow(A5)
plt.show()
Sigma = 0.01
Ta được kết quả:
Sigma = 1
Sigma = 0.005
** thay đổi gauss
gauss(0,5000)
Gauss(0,20000)
gauss(0,1)
Nhận xét:
Khi thay đổi giá trị sigma thì chất lượng hình ảnh của 0.05 là tốt nhất từ đó cho
thấy nếu sigma quá lớn (1) ảnh sẽ không thấy gì khi sigma quá nhỏ (0.01) hình ảnh
bị mờ.
Khi thay đổi giá trị của gauss