1 | initial version |
There are several possibilities to find the right focus plane.
For example when you use a contrast method you can analyze your images by filtering it with a sobel filter. The sobel filter gives you the deviation of your image. Now you can, for example, sum up the deviation image and use this value for comparing: The more your image is in the focus plane the more edges are existing, the more increases you have in your deviated image, the higher is your value.
Consider this method only works on images with structure in it and you need to analyze several focus planes without changing the motive because you only get a relative value dependend of your motive.
Another contrast method is to transform your image with dft or fft an looking for the one with the most ratio of high frequencies. For this the same restrictions counts like for analyze with a sobel filter. A third one is to shift your image by one or two pixel in X and Y, than subtract it from the origin and look for edges but I never tested this method.
2 | No.2 Revision |
There are several possibilities to find the right focus plane.
For example when you use a contrast method you can analyze your images by filtering it with a sobel filter. The sobel filter gives you the deviation of your image. Now you can, for example, sum up the deviation image and use this value for comparing: The more your image is in the focus plane the more edges are existing, the more increases you have in your deviated image, the higher is your value.
Consider this method only works on images with structure in it and you need to analyze several focus planes without changing the motive because you only get a relative value dependend of your motive.
Another contrast method is to transform your image with dft or fft an looking for the one with the most ratio of high frequencies. For this the same restrictions counts like for analyze analyzing with a sobel filter. A third one is to shift your image by one or two pixel in X and Y, than subtract it from the origin and look for edges but I never tested this method.