English: Intensity profiles of the first 12 Laguerre-Gaussian modes.
Each profile is generated form the following script:
- the script is and adapter version for python3 of the original found for Hemite-Gaussian modes: https://wiki.riteme.site/wiki/File:Hermite-gaussian.png
import sys
from PIL import Image
from math import *
from scipy.special import genlaguerre
size = 320
I_0 = 1.
w = size/4.
l = int(sys.argv[1])
m = int(sys.argv[2])
def linear_to_sRGB(l):
# Formula from http://www.w3.org/Graphics/Color/sRGB
if l <= 0.00304:
l = 12.92*l
else:
l = 1.055*pow(l,1.0/2.4) - 0.055
return 255.0*l
- First, let's make a floating-point image of the raw intensities.
raw = Image.new('F', (size,size))
high = 0
for x in range(1, size, 2):
for y in range(1, size, 2):
I = I_0 * (genlaguerre(m,l)(2*(x**2+y**2)/w**2) \
* (sqrt(2*(x**2+y**2))/w)**l \
* exp(-x**2/w**2) *exp(-y**2/w**2))**2
if I > high: high = I
raw.putpixel((int(size//2+(x-1)//2),int(size/2+(y-1)//2)), I)
raw.putpixel((int(size//2+(x-1)//2),int(size/2-(y+1)//2)), I)
raw.putpixel((int(size//2-(x+1)//2),int(size/2+(y-1)//2)), I)
raw.putpixel((int(size//2-(x+1)//2),int(size/2-(y+1)//2)), I)
#print('row ' + str((x+1)/2) + ' of ' + str(size/2) + ' complete')
- Now, let's normalize them and export them as sRGB.
- im_rgb_raw = raw.convert('RGB')
- im_rgb_raw.save("raw.png")
cooked = Image.new('L', (size,size))
for x in range(size):
for y in range(size):
l = raw.getpixel((x,y))/high
cooked.putpixel((x,y), int(linear_to_sRGB(l)))
print( 'row ' + str(x+1) + ' of ' + str(size) + ' complete')
im_rgb_cooked = cooked.convert('RGB')
im_rgb_cooked.save("hg"+sys.argv[1]+sys.argv[2]+".png")