EEVblog Electronics Community Forum

Products => Thermal Imaging => Topic started by: Ultrapurple on October 02, 2021, 02:48:06 pm

Title: Focus stacking in thermal imaging
Post by: Ultrapurple on October 02, 2021, 02:48:06 pm
Has anyone else done any work with focus stacking thermal images to improve the depth of field?

I was trying to image a Raspberry Pi-based stack of boards but the particularly hot bit that interested me was largely hidden beneath a heatsink, meaning I had a limited choice of angles. The depth of field with my FLIR SC-660, close-up, was only a few millimetres, so I tried taking half a dozen or so images manually focussed a few mm apart. I then used the free online focus stacker at https://focusstackingonline.com/ (https://focusstackingonline.com/) to combine the images. (Note - although the site says it'll download a jpeg image I found it came down in .PNG - even though the file it called itself .jpeg

This first attempt has made me think this is a field worth pursuing for 'difficult' subjects. I have a close-up lens that lets me reduce the field width (https://www.eevblog.com/forum/thermal-imaging/thermal-imaging-gallery-ii/msg3679291/#msg3679291) to about 30mm (roughly 0.5mm per pixel), which compares favourably with the normal minimum focus distance field width of about 240mm (2.5mm per pixel).

Thoughts? Prior art? Was it worth it?
Title: Re: Focus stacking in thermal imaging
Post by: Fraser on October 02, 2021, 03:24:22 pm
Interesting topic Ultrapurple  :-+

Because industrial/scientific grade thermal cameras tend to use quite fast lenses the depth of field is quite shallow for close-up working. With my Exx series camera the focus needs to be carefully set and then re-set if the camera is moved to a new angle. For longer range targets the situation is better but manual focussing does need to be fine tuned if targets at differing distances are to be at peak sharpness. You are very experienced at photographic techniques so you have far greater knowledge of aperture and depth of field than me. Could you use a variable aperture Iris diaphragm in front of the lens to reduce aperture and increase depth of field ? I know the Iris usually sits towards the rear of the lens block and may cause vignetting if placed in front of the objective ? I have some nice Iris diaphragms for a different project so should carry out some tests on my Exx series camera. The Radiometric calibration will be lost of course but I know you have an interest in the artistic side of thermal imaging. I suppose a simple ‘large ‘pinhole’ diaphragm could be placed on the rear of the lens before fitting to the camera ? My scientific SC4000 lenses actually provide a threaded mount on their rear for attachment of optional filters. Again I am unsure what vignetting this would cause.

None of this relates to your question on image stacking but as it is attempting to achieve the same, or similar, objective, I thought I would mention it.
Title: Re: Focus stacking in thermal imaging
Post by: Fraser on October 02, 2021, 03:48:29 pm
I just did a quick Google on camera aperture effects and the use of the diaphragm. Sadly I do not think my ideas would fly due to incorrect positioning of the diaphragm in the optical path :( I thought this could be an issue but wanted to see if it had any merit in your application.

https://photographylife.com/what-is-aperture-in-photography


With regard to using stacked images, I seem to recall that my PM series cameras with motorised focus could have their lens focus point adjusted in fine steps via a command to the communication port from a PC or RS232 remote controller. That would make building a nice stack of images relatively easy with a script driving the serial remote control port…. Set focus manually then…. Save  image, auto increment x steps, save image, increment x steps, save image etc. You would end up with a stack images at well defined focus steps and it would be automated. A fun little project :)

Fraser


Title: Re: Focus stacking in thermal imaging
Post by: Vipitis on October 02, 2021, 04:08:00 pm
It's one of the topics we discussed about years ago. There was all kinds of ideas: stacking for NR, stacking for sharpness and superresolution and also stacking for focus. Focus stacking is more similar to stiching a panorama than stacking for Dynamic range (HDR, NR....).

I did talk to a few people on a photography Discord I am really active in and what they recommended was a software meant for microscopy. Focus stacking is most often used for micrography and macro photography. I believe there is a free trail for Zerene Stacker and I tried it for myself on a really low delta T scene where I just recorded a heavily compressed and badly stretched video of a focus pull.

The results were interesting but not what I expect due to the noisy nature of the recording

https://www.eevblog.com/forum/thermal-imaging/thermal-imaging-gallery-ii/95/ (https://www.eevblog.com/forum/thermal-imaging/thermal-imaging-gallery-ii/95/)
Title: Re: Focus stacking in thermal imaging
Post by: Fraser on October 02, 2021, 04:41:19 pm
Vipitis,

That makes total sense  :-+ Small Depth  of field under a microscope can be a significant challenge so software designed to create a focus stack product would be a great asset for better imaging.

I have an interest in thermal microscopy that I have yet to act upon. I have two nice Jenoptik cameras that are fitted with very nice dedicated close-up lenses so I should spend some time testing their imaging capabilities.

Fraser
Title: Re: Focus stacking in thermal imaging
Post by: Fraser on October 02, 2021, 05:02:07 pm
A useful discussion on microscopy and macro photography image stacking softwares, including free ones  :-+

https://www.microbehunter.com/microscopy-forum/viewtopic.php?t=5814 (https://www.microbehunter.com/microscopy-forum/viewtopic.php?t=5814)
Title: Re: Focus stacking in thermal imaging
Post by: Ultrapurple on October 02, 2021, 06:37:30 pm
Fraser is right (as usual) about the aperture needing to be between the lens and sensor (most lenses have the iris in the middle of the glassware, but definitely not between the subject and lens).

My SC-660 has an iris plate that switches in under system control to extend the measurement up to its highest range (I can't remember whether mine is 1500°C or 2000°C). It would also increase the depth of field somewhat, but at the expense of sensitivity.

One thing I don't (yet) know is whether the SC-660 supports incremental focus adjustments by remote control, though the focus is motorised so there's no good reason why it couldn't be. Something else to try on another rainy Saturday afternoon!

Title: Re: Focus stacking in thermal imaging
Post by: bap2703 on October 03, 2021, 09:15:36 am
You could also stack the other way around :
- put your camera further away --> object is smaller on image but with more depth of field
- stack images for super resolution
Title: Re: Focus stacking in thermal imaging
Post by: Hydron on October 04, 2021, 12:10:32 pm
I wonder if a FDM 3d printer could be used as a platform for quick-and-dirty testing of the stacking concept. You have 3 controllable axes, with one (Z) being fairly finely controllable - just bodge the camera onto it where the hotend sits.
Title: Re: Focus stacking in thermal imaging
Post by: Ultrapurple on October 04, 2021, 12:32:09 pm
I have been thinking about using an in-out translation stage to physically move the camera toward and away from the subject. I've got one, somewhere, that would do the job. I could then use it with my incredibly shallow DoF closeup lens. I'll see what I can do, as time permits.
Title: Re: Focus stacking in thermal imaging
Post by: Vipitis on October 04, 2021, 03:55:27 pm
Just be aware that moving the imaging plane instead of the focus plane of the lens system can cause issues with parallax and perspective distortion.

But if you got a sufficiently telecentric lens it might be the way to go.

Don't be afraid and share some results.
Title: Re: Focus stacking in thermal imaging
Post by: Ultrapurple on October 04, 2021, 04:29:54 pm
Don't be afraid and share some results.

Shy? Me?

Many thanks for your wise words and encouragement. The lens combination definitely isn't telecentric (https://en.wikipedia.org/wiki/Telecentric_lens) (I wonder if there are any such beasts in the uncooled LWIR world? They are rare enough for visible light and if the example I saw on Wikipedia (https://en.wikipedia.org/wiki/File:Bi_telecentric_lens.jpg) is anything to go by then the necessary amount of germanium would be frighteningly expensive even for a billionaire. Even a cooled camera would need a heck of a lot of material. When I looked at Edmunds Optics, visible light telecentric lenses go up to and beyond US$10,000 - and they're made of glass, not germanium...).