Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Imaging simulations #14

Open
meller92 opened this issue Jan 24, 2017 · 5 comments
Open

Imaging simulations #14

meller92 opened this issue Jan 24, 2017 · 5 comments

Comments

@meller92
Copy link

Hi, I don't know Python a lot but i think that adding something like this to the zernike.py module could be useful:

import opticspy
import numpy as np
from PIL import Image
from scipy import signal
import matplotlib.pyplot as plt

Z = opticspy.zernike.Coefficient(Z1=0.2)
Z.zernikesurface()
psfmatrix = Z.psf(matrix=True)
Z.mtf()
abspsf=abs(psfmatrix/psfmatrix.max())

im = Image.open("img.bmp")
pic = np.array(im)
imgplot=plt.imshow(pic)
imgplot.set_cmap("gray")
plt.colorbar()
plt.show()

abspic=(pic/pic.max())
outpic=signal.fftconvolve(abspsf,abspic,mode="same")
outpic=np.trunc(255*abs(outpic/outpic.max()))
imgplot=plt.imshow(outpic)
imgplot.set_cmap("gray")
plt.colorbar()
plt.show()
@Sterncat
Copy link
Owner

Hi meller,

Thank you!

I will test it and add it in the module! Cool!

Marvin

@Sterncat Sterncat assigned Sterncat and unassigned Sterncat Jan 25, 2017
@dguerra
Copy link

dguerra commented Apr 3, 2017

Hi Marvin, any improvement on this? I think it could be a nice feature. Thanks

@brandondube
Copy link

Hi @dguerra, you may be interested in prysm, an alternative python optics module. Among its features are image simulation, with respect for units and a lack of necessity for the PSF and image to have equal spacing. I do need to polish the code for that type of thing more, but you can find an example of using image simulation here.

@goldengrape
Copy link

failed in
psfmatrix = Z.psf(matrix=True)
return
TypeError: psf() got an unexpected keyword argument 'matrix'

I dive into the code, for .psf

def psf(self,r=1,lambda_1=632*10**(-9),z=0.1):
		"""
		------------------------------------------------
		psf()
		Return the point spread function of a wavefront described by
		Zernike Polynomials
		------------------------------------------------
		Input:
		r: exit pupil radius(mm)
		lambda_1: wavelength(m)
		z: exit pupil to image plane distance(m)
		"""
		print(r,lambda_1,z)
		PSF = self.__psfcaculator__(r=r,lambda_1=lambda_1,z=z)
		fig = __plt__.figure(figsize=(9, 6), dpi=80)
		__plt__.imshow(abs(PSF),cmap=__cm__.RdYlGn)
		__plt__.colorbar()
		__plt__.show()
		return 0

Z.psf() always return 0, not PSF from psfcaculator

@Sterncat
Copy link
Owner

Maybe one int 0 get into the calculation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants