Fast Stacker (Arduino based automated focus stacking rail)

Have questions about the equipment used for macro- or micro- photography? Post those questions in this forum.

Moderators: rjlittlefield, ChrisR, Chris S., Pau

nsomnius
Posts: 14
Joined: Wed Nov 25, 2015 6:24 pm
Location: Berkeley, California

Post by nsomnius »

Excellent, thank you.

pulsar123
Posts: 146
Joined: Fri Jun 12, 2015 12:36 pm

Post by pulsar123 »

In other news: I am lucky to work for a large university! I discovered that we had a real entomologist on campus, and finally today I had a chat with the guy. He's also into macro photography (quite obviously), but not focus stacking. And then he was really nice to let me borrow two boxes of pinned insects (a few dozens of them; >20 different species) for my stacking experiments. That should keep me busy for a while :)

Also, I am converging to a stacking software workflow which is purely based on free open source software (dcraw, Hugin: align_image_stack + enfuse, ImageMagick) and it looks like I am converging to results I like much more than what I managed to get with Zerene Stacker, without manual retouching. If it is all good I will post a tutorial here.

rjlittlefield
Site Admin
Posts: 24055
Joined: Tue Aug 01, 2006 8:34 am
Location: Richland, Washington State, USA
Contact:

Post by rjlittlefield »

pulsar123 wrote:If it is all good I will post a tutorial here.
That would be very helpful. At the highest level, the description "align_image_stack + enfuse" is a good summary of the PMax algorithm, so I will be very interested to see in more detail what you're doing to improve the result.

--Rik

pulsar123
Posts: 146
Joined: Fri Jun 12, 2015 12:36 pm

Post by pulsar123 »

rjlittlefield wrote:
pulsar123 wrote:If it is all good I will post a tutorial here.
That would be very helpful. At the highest level, the description "align_image_stack + enfuse" is a good summary of the PMax algorithm, so I will be very interested to see in more detail what you're doing to improve the result.

--Rik
enfuse provide many advanced settings which zerene doesn't have (AFAIK). It looks I need "--gray-projector=l-star" and a large value (like 31) for "--contrast-window-size" to both get a decent contrast and sharpness and minimize ugly artifacts around bright features. I'll do more testing to know for sure.

I also like dcraw over Adobe etc. in part because it is command line (so very easy to make a part of a single script which will do the whole processing), but also because it can be used to automatically remove all hot pixels, using a dark frame for the reference. I just need to find the way to recover coordinates of the brightest pixels in a dark frame (probably using ImageMagick), and then provide the list to dcraw as deadpixels.txt. In my stacked shots I can only see artifacts from just a handful of the brightest hot pixels, so identifying say 10 brightest pixels in a dark frame should be sufficient.

pulsar123
Posts: 146
Joined: Fri Jun 12, 2015 12:36 pm

Post by pulsar123 »

I actually have to step back here - after numerous attempts, I couldn't produce great results (much better than with Zerene) with open source software. The cases where I sort of solved the glowing halo issue happened to have other significant issues (lack of contrast for certain spatial frequences).

And that's probably not surprizing: OOF halos from bright elements are large, much larger than the contrast detection window, and basically become a part of the picture.

The only correct method to remove the halos (and also increase sharpness at all scales) seems to be 3D deconvolution using an experimentally measured 3D PSF (point spread function) for my system (camera + lens). This is what apparently all microscopic scientists do for their research (in biology etc.).

It has significant challenges:
- noise has to be dealt with, as deconvolution is very sensitive to it;
- it is technically challenging to measure the 3D PSF experimentally (you need a point light source - much smaller than the wavelength of the light, and complete darkness for the background);
- one needs very large RAM to properly deconvolve the whole stack in 3D: 45 GB of RAM to fit both 250shots x 90MB (15 Mpixels x 48 bit color) stack + same size PSF. Or only 1/3 of this (more manageable 15GB) if you do one color (r, g, b) at a time.

Anyone here tried to do this? The results can be quite spectacular. I played a bitwith the demo version of SmartDeblur program (http://smartdeblur.net/index.html) which is one of the few programs which attempt to do "blind deconvolution" - trying simultaneously to recover the underlying (and unknown) PSF and sharpen the image using that PSF. It is only 2D, and obviously can't do perfect job because of that, but after a few attempts to use it to a focus stacked photo I got some interesting results. How much more if I had the actual 3D PSF!

Also there is a hope that one can construct a 2D version of the experimental 3D PSF which can be used to deconvolve the end product - the stacked photo. Presumably one can apply the same focus stacking algorithm to the 3D PSF to get a 2D version of PSF. If this approach works at least partially as well as the full 3D approach, this could be a very interesting compromise, as it'll require much less memory (and time) to carry out.

I am thinking of trying to estimate my 3D PSF by shooting a stack of a reflection of a bare flash from a tiny metal ball (removed from a ball pen) glued to a piece of black paper and placed inside cylinder made of that paper (with the ball inside the cylinder). The microscope objective (attached to the camera) can move back and forth inside the other - open - end of the cylinder. Then one can make a small hole half away in the cylinder, and place an external flash ~2-3m away in the way that its light would reach the metal ball through the small hole. Finally, one can place a disk of black paper on the camera around the objective's base, to eliminate any light from reaching the metal ball from the open end of the cylinder. Something like this:

Imageartificial_star by First Last, on Flickr

This could be interesting - if done properly, I should be able to see the Airy diffraction disk from this artificial star (flash reflected in the ball). This could be an ultimate test of the resolving power of my objective and the stability of my rail, in addition to providing me with experimental 3D PSF.

Of course 3D PSF at the frame edges will be different from the one at the center, but my hope is that the central PSF can still do a reasonable deconvolution job at the edges.

g4lab
Posts: 1479
Joined: Fri May 23, 2008 11:07 am

Post by g4lab »

You should look up:

http://www.drjohnruss.com/

http://www.reindeergraphics.com/index.html

They have Photoshop plug-ins that do a variety of deconvolution tricks.
Whether they will be useful for your purposes I cannot guess.

pulsar123
Posts: 146
Joined: Fri Jun 12, 2015 12:36 pm

Post by pulsar123 »

g4lab wrote:You should look up:

http://www.drjohnruss.com/

http://www.reindeergraphics.com/index.html

They have Photoshop plug-ins that do a variety of deconvolution tricks.
Whether they will be useful for your purposes I cannot guess.
Thanks for the links, but the first one provide a PS plugin which doesn't show up inside my PS5 (probably some incompatibility). The second page's download links are broken (I'm getting 404 error).

g4lab
Posts: 1479
Joined: Fri May 23, 2008 11:07 am

Post by g4lab »

In one of his books he (Dr. Russ)makes the source code available for most of those plug ins but you have to compile them yourself. But iirc there is a CD so you don't have to type them in.
http://www.amazon.com/Introduction-Imag ... d+analysis
Try calling them. The owner of Reindeer Graphics is Dr. Russ' son, a PhD software engineer.

rjlittlefield
Site Admin
Posts: 24055
Joined: Tue Aug 01, 2006 8:34 am
Location: Richland, Washington State, USA
Contact:

Post by rjlittlefield »

pulsar123 wrote:I actually have to step back here - after numerous attempts, I couldn't produce great results (much better than with Zerene) with open source software. The cases where I sort of solved the glowing halo issue happened to have other significant issues (lack of contrast for certain spatial frequences).
That's disappointing. I had great hopes that some of the wide range of options available in enfuse would turn out to give a big improvement. But that still might be a fruitful path for experiment, since it is far simpler to run experiments by driving enfuse than by programming that same math from scratch.
The only correct method to remove the halos (and also increase sharpness at all scales) seems to be 3D deconvolution using an experimentally measured 3D PSF (point spread function) for my system (camera + lens). This is what apparently all microscopic scientists do for their research (in biology etc.).


It has significant challenges...
One additional challenge is that with opaque subjects, the geometry of the subject will affect which parts of the 3D PSF actually contributed to the captured images. This makes the deconvolution process even more complicated than it is with transparent subjects.

I think it's peripheral to your application, but you might want to take a look at 3D Deconvolution or Not on Fluorescence Stack. The discussion as it evolves on pages 2 and 3 of the thread is interesting, and Charles Krebs' results at http://www.photomacrography.net/forum/v ... 954#134954 may be especially thought-provoking.

--Rik

pulsar123
Posts: 146
Joined: Fri Jun 12, 2015 12:36 pm

Post by pulsar123 »

I actually still prefer the look of enfuse vs. Zerene, even before any PP (deconvolution and sharpening). Be the judge:

ImageZerene vs. Enfuse by First Last, on Flickr

- Top: Zerene DMap
- Middle: Zerene PMax
- Bottom: Enfuse

I like the Enfuse result better, because it is sharper without too much noise. It does create other artifacts (halos around bright details), but apparently there are some ways to deal with it. And DMap has terrible artifacts in my tests.

And this is what I get after applying Smart deBlur (Auto PSF):

Imagedeblur by First Last, on Flickr

Top is Zerene Pmax, bottom is Enfuse. Even after sharpening Enfuse is almost noise free, whereas Pmax is pretty noisy.

So Enfuse does look interesting, it just needs more tinkering.

rjlittlefield
Site Admin
Posts: 24055
Joined: Tue Aug 01, 2006 8:34 am
Location: Richland, Washington State, USA
Contact:

Post by rjlittlefield »

Excellent -- thanks for the further information.

In your DMap result, what attracts my attention is a lot of fine blotches in what should be uniform areas. That's typically caused by a combination of small radius setting and a contrast threshold that is set too low, causing decisions to be dominated by image noise rather than actual detail. Depth map methods in general tend to have trouble with halos around edges and bristles, but the blotches that I see here look like they're caused by inappropriate parameter settings. (One of the very nice things about PMax versus DMap is that there are no settings to go wrong.)

--Rik

nsomnius
Posts: 14
Joined: Wed Nov 25, 2015 6:24 pm
Location: Berkeley, California

Post by nsomnius »

Sadly, Reindeer Graphics seem to have stopped developing their software, a long time ago at that. The last time it worked in Photoshop was many versions ago, CS2 possibly. Optipix had a Power Median tool that was amazing for removing power lines and things.

In talking about deconvolution sharpening, are you referring to Richardson-Lucy Deconvolution? If not, I think that's worth a try as well. I know that Raw Therapee (free) offers it as an option as well as the not so free Maxim DL. Probably others I don't know about.

pulsar123
Posts: 146
Joined: Fri Jun 12, 2015 12:36 pm

Post by pulsar123 »

There are many options for vanila deconvolution; I am specifically interested in "blind deconvolution" which is apparently a rare beast, at least in free software.

I just stumbled across this reasearcher-written software (only Windows, so will try it when I get home):

http://www.deconvolve.net/index.html

Anyone tried it? They claim blind deconvolution support for 2D and 3D (bright field - so it is focus stacking as far as I understand), including spatially variable.

JH
Posts: 1310
Joined: Sat Mar 09, 2013 9:46 am
Location: Vallentuna, Stockholm, Sweden
Contact:

Post by JH »

pulsar123 wrote: Pmax is pretty noisy
You have solved this with the use of another program. For me that - for a lot of reasons - prefer Zerene Stacker I usually handle noise before stacking with PMax. Low ISO, good lighting helps and sometimes gives me almost noiseless pictures to begin with. When I convert my raw files to tiff or jpg before stacking I do not sharpen the single pictures at all and most of the times I check at high magnification if I have to reduce noise further before converting.
When sharpening the picture I have come to like the easiness of adobe smart sharpen. Here is an example of what I usually do.

http://www.photomacrography.net/forum/v ... 470#157470

Regards Jörgen

pulsar123
Posts: 146
Joined: Fri Jun 12, 2015 12:36 pm

Post by pulsar123 »

^ Thanks, looks good, though I see quite a bit of large scale fuzziness - something I am struggling with myself, and something I hope a proper 3D PSF would fix. I also make sure there's no sharpening before focus stacking, as from my tests this results in better outcome.

Here is a new example: my Arduino rail with 5um steps, 310 shots, Canon electronic shutter (with Magic Lantern + my rail control for the external flash). Two-stage stacking (first stage: 23 frame slabs with 30% overlap), all done with open source (align_image_stack + enfuse), 3-scale sharpening at the end with ImageMagick:

ImageFly at 10:1 by First Last, on Flickr

This is from the box of pinned insects I got from our University entomologist. The eyes are totally dry, correct? Is there a way to bring them to life without some rare chemicals, and without distroying the specimen? Perhaps spraying with water (I have very fine cold water "steam" sprayer)?

I am still not happy with the result - I've seen sharper looking photos made at the same magnification, with the same objective. Ans this is not a small scale blur (so e.g. my rail is not to blame), it is more of the large-scale "haloness", due to the long wings of the PSF.

Here is another idea on how to measure 3D PSF experimentally: I can buy a very small laser-drilled pinhole online, 100um or perhaps even smaller. Then I can place a flash behind, and shoot a stack of the pinhole with my macro lens. Of course it is much larger than the light wavelength, but this is a well defined target - circular with a known diameter and sharp boundary - should be fairly easy to recover the true 3D PSF with blind deconvolution software?

Post Reply Previous topicNext topic