opticspy / lightpipes

LightPipes for Python, "Pure Python version"
https://opticspy.github.io/lightpipes/
BSD 3-Clause "New" or "Revised" License
227 stars 52 forks source link

The aliasing problem occurs in synthetic digital hologram #49

Open yp000925 opened 3 years ago

yp000925 commented 3 years ago

Hi

Thanks for your great working in building this light field simulation library!

I am using this to synthesise some in-line holograms from the particle field based on the Fresnel Diffraction theory. While there are some nonphysical noise occurs (Probably come from the aliasing effect?) Is there any way to handle that?

And with the seem parameter setting , the resulted holograms look quite different from using Forvard() (Fig Set.1) and Fresnel()(Fig Set.2). Do you have some ideas about how to tackle this issue? It looks like the Fresnel()has more vertical and horizontal stripes contained. Image1 Image2

Thanks

The code i used is

from LightPipes import *
wavelength = 633*nm
N = 1024
pixel_pitch = 10*um
size = pixel_pitch*N 
particle = 50*um/2

[x1,y1,z1] = [0,0,3*cm]
[x2,y2,z2] = [-3.0*mm,1.2*mm,3*cm]
[x3,y3,z3] = [0.5*mm,0.5*mm,1*cm]

f_factor1 = 2*particle**2/(wavelength*z1)
f_factor2 = 2*particle**2/(wavelength*z2)
f_factor3 = 2*particle**2/(wavelength*z3)

F = Begin(size,wavelength,N)
F_obj1 = CircScreen(F,particle,x1,y1)
F_obj2 = CircScreen(F,particle,x2,y2)
F_obj3 = CircScreen(F,particle,x3,y3)

#using forvard()
F_obj1 = Forvard(F_obj1,z1)
F_obj2 = Forvard(F_obj2,z2)
F_obj3 = Forvard(F_obj3,z3)

#uncomment to use Fresnel()
#F_obj1 = Fresnel(F_obj1,z1)
#F_obj2 = Fresnel(F_obj2,z2)
#F_obj3 = Fresnel(F_obj3,z3)
Mix = BeamMix(F_obj1,F_obj2)
Mix = BeamMix(Mix,F_obj3)

fig = plt.figure()
ax1 = fig.add_subplot(221)
ax2 = fig.add_subplot(222)
ax3 = fig.add_subplot(223)
ax4 = fig.add_subplot(224)
ax1.imshow(Intensity(Mix,2), cmap='gray'); ax1.axis('off');ax1.set_title('Mix ')
ax2.imshow(Intensity(F_obj1,2), cmap='gray'); ax2.axis('off');ax2.set_title('First particle at z=%f'%z1)
ax3.imshow(Intensity(F_obj2,2), cmap='gray'); ax3.axis('off');ax3.set_title('Second particlez z=%f'%z2)
ax4.imshow(Intensity(F_obj3,2), cmap='gray'); ax4.axis('off');ax4.set_title('Third particle z=%f'%z3)
plt.show()
#fig.savefig("Hologram.png")
FredvanGoor commented 3 years ago

The vertical and horizontal stripes are caused by 'numerical reflections' from the grid borders and can be removed by making the fields equal to zero near those borders. This is important when using the Fresnel command. You can use for example the SuperGaussAperture command to do this. In the following example this has been demonstrated. Comment the SuperGaussAperture command and see the effect on the Fresnel propagation. Sometimes it is better to use the Fresnel command instead of the Forvard command, see the manual for some explanation.

from LightPipes import *
import matplotlib.pyplot as plt
wavelength = 633*nm
N = 1000

size = 2000*um
particle = 50*um

z1=3*cm

F = Begin(size,wavelength,N)
F=SuperGaussAperture(F,size/3,n=10)
F_obj1 = CircScreen(F,particle)

F_obj1Fo = Forvard(F_obj1,z1)

F_obj1Fr = Fresnel(F_obj1,z1)

fig = plt.figure()
ax1 = fig.add_subplot(221)
ax2 = fig.add_subplot(222)

ax1.imshow(Intensity(F_obj1Fo,2), cmap='gray'); ax1.axis('off');ax1.set_title('Forvard')
ax2.imshow(Intensity(F_obj1Fr,2), cmap='gray'); ax2.axis('off');ax2.set_title('Fresnel')

plt.show()

Figure_1 Figure_2