# # # # # # # # # # # # # # Importation des bibliotheques/modules # # # # # # # # # # # # # # import matplotlib.pyplot as plt import numpy as np import scipy.special as sp import cv2 # # # # # # # # # # # # # # Fonction # # # # # # # # # # # # # # def reconstructionthomson(i): #Parametres du microscope #Dimension de l'image Nx = 480 Ny = 480 Pix = 1.4e-6 #Pixel camera Lambda = 638e-9 #Longueur d'onde camera z = 0.00092 pi = np.pi #Creation du mesh xmin = -Nx/2 xmax = Nx/2-1 ymin = -Ny/2 ymax = Ny/2-1 x = np.linspace(xmin,xmax,Nx) y = np.linspace(ymin,ymax,Ny) X,Y = np.meshgrid(x,y) #Mesh en pixel #Mesh metrique Xm = X*Pix Ym = Y*Pix Ith = cv2.imread('/home/pi/Desktop/image.png',0) #Lecture de notre image a reconstruire plt.figure(figsize=(6.25,6.25)) #mise en place dans une figure pour modifier correctement son dimensionnement hz = np.exp(1j*pi/Lambda/z*(Xm**2+Ym**2)) #Noyau convolution #Reconstruction de l'image par la methode Thomson I_rec_th = np.fft.fftshift(np.fft.ifft2(np.fft.fft2(Ith)*np.fft.fft2(np.conj(hz))))/Nx #Algorithme de reconstruction plt.imshow(np.abs(I_rec_th)**2,cmap=plt.cm.gray) #Affichage de notre image plt.axis('off') #Suppression des axes plt.savefig('/home/pi/Desktop/reconstruction2D.png') #Sauvegarde de la figure im = cv2.imread('/home/pi/Desktop/reconstruction2D.png') #Reouverture de l'iamge im = im[75:75+480,80:80+480] #Redimensionnement de l'image pour obtenir en sortie une image en 480*480 cv2.imwrite('/home/pi/Desktop/reconstruction2D.png',im) #Sauvegarde de l'image avec le bon dimensionnement return reconstructionthomson (1)