

 This micrograph of a diatom clearly shows the problem, it is impossible to get the whole sample in focus in one image. Fortunately there are ways around it; by analysing the image for sharp edges it is possible to find which image is the most in-focus and the whole image can then be reconstructed only using the in-focus patches. This process is called focus stacking and generates an extended depth of field. Good free implementations of focus stacking are hard to come across, so I wrote one; you can download the ImageJ macro here.
This micrograph of a diatom clearly shows the problem, it is impossible to get the whole sample in focus in one image. Fortunately there are ways around it; by analysing the image for sharp edges it is possible to find which image is the most in-focus and the whole image can then be reconstructed only using the in-focus patches. This process is called focus stacking and generates an extended depth of field. Good free implementations of focus stacking are hard to come across, so I wrote one; you can download the ImageJ macro here. Using the same technique on macro photography (processing the red, green and blue channels separately) gives a similarly impressive result. The three starting images:
Using the same technique on macro photography (processing the red, green and blue channels separately) gives a similarly impressive result. The three starting images:

 And the extended depth of field result:
And the extended depth of field result: Software used:
Software used:Image processing: ImageJ



