Modeling an "out of focus" image

I am programming auto focus on a microscope with a programmable axis controller. For testing, I have implemented a simulation that returns an image based on exposure, axis position, etc. The simulation takes a good image and distorts it - for example, makes it brighter, darker.

The primer indicator for good focus is sharp edges (works well for my type of images). Basically I am summarizing the intensity differences between adjacent pixels. The higher the amount, the better the focus.

My question is, how do I simulate an out of focus image? Has anyone already implemented this? The sequence of filters would be great.

I tried cvSmooth but it didn't give realistic results.

PS: My current workaround is changing the ROI size inversely proportional to the distance from the focus. It works well for testing my algorithms, but not good for demonstrations - since the image does not change during simulation.

+3


source to share


1 answer


(I'm not sure if Stack Overflow is the right site for your problem as it is highly domain dependent)

View the microscope in terms of the point reversal function (PSF). PSF is a function that describes the image of a point light source in a microscope. If you take one plane from a 3D point distribution function, you have defocusing behavior for that axial distance. Fold the image with the dot spread image and you have the image with focus. This operation is commonly referred to as "folding", "folding" or "smooth with kernel".

Of course, you will need a point spread function for your microscope, and there are many details to consider - most importantly, the type of optics, numerical aperture, etc. Ask for relevant optical literature. Sibaritas Deconvolution Microscopy seems like a good start.



Note that in general 3D defocusing involves integrating the Bessel function across phases. You might be able to approximate the behavior with a Gaussian mask if the axial defocus is about 2 times the lateral resolution of your microscope. It's like one or two microns on conventional microscopes. For large axial defocusings, you need to calculate the integral. I doubt this is in the scope of OpenCV, so you need to pre-compute the defocus function.

My dissertation rapidSTORM has implemented oily targets, but the code (pixelatedBessel.cpp) is not in opencv.

Particularly for high-aperture microscopes, the calculations are very complicated, however in my laboratory we usually preferred to just point a point light source (for example, a quantum dot) at the microscope, and let the Z-step work.

+4


source







All Articles