Coin Community Family of Web Sites Join Thousands of Coin, Bullion, & Money Collectors
Royal Canadian Mint products, Canadian, Polish, American, and world coins and banknotes. Coin, Banknote and Medal Collectors's Online Mall Specializing in Modern Numismatics 300,000 items to help build your collection! Vancouvers #1 Coin and Paper Money Dealer Royal Estate Auctions - $1 Coin AuctionsJoin Thousands of Coin, Bullion, & Money Collectors








Username:
Password:
Save Password
Forgot your Password?


This page may contain links that result in small commissions to keep this free site up and running.

Welcome Guest! Registering and/or logging in will remove the anchor (bottom) ads. It's Free!

How I Focus Stack Using Open Source Tools..

To participate in the forum you must log in or register.
Author Previous TopicReplies: 7 / Views: 2,093Next Topic  
Valued Member
mamastinky's Avatar
United States
441 Posts
 Posted 11/29/2016  7:46 pm Show Profile   Bookmark this topic Add mamastinky to your friends list Get a Link to this Message Number of Subscribers
I have been working with a free focus-stacking program that produces excellent results for as simple as it is. Works on all platforms. It is called Enfuse.

It requires that you align the photos first with a command-line program called Hugin, but I have created a script that runs both programs with a simple mouse click. Focus stacked image is done. I will demonstrate the process here showing examples, and then explain how to install it in a new reply to this thread. I am running a Linux machine, but these programs will work on Windows and Mac as well.

This was done using a z-stage, but I have also done stacking without it by adjusting the bellows, you just won't have precisely measured incrementations between steps. The need for that increases with your magnification, I do believe.

So this is a 1942-D 42/41 Mercury dime. I took 8 photos using a z-stage each in 1 step increments. I then copied them to a folder containing my script. The script takes significantly longer to execute with large file sizes, so I always reduce the photos before running the script.

All one has to do now is call the script. One way is to just click it and wait for the finished jpeg to appear. This usually takes a minute or two, longer with more photos.

The script works by calling 2 different programs. First is Hugin, which will analyze the first photo, then compare each successive photo to the previous one. Hugin will create a new resized and realigned tiff for each file. Those will be the images input into Enfuse and stacked as a single tiff. For my purposes, I finish the script with a command to convert the finished tiff into jpeg using ImageMagick. Important note, I don't think Hugin likes RAW files.

There are several parameters within Hugin that can be changed, and I have tested various combinations of them. If one is working with photos with no huge changes in size or lighting, the settings used to create the stack below work best. If you use photos with certain significant differences between them, sometimes Hugin may misalign or resize improperly. 90% of the time, however, I have been able to overcome this by renaming the files to change the order in which they are input.

Here I will include the first and last photos only (remember I stacked 8) in the stacking sequence:

How-I-Focus-Stack-Using-Open-Source-Tools..

How-I-Focus-Stack-Using-Open-Source-Tools..


The result:


How-I-Focus-Stack-Using-Open-Source-Tools..

This is the only software I have ever used to accomplish this, so I would not be the one to ask about how my results compare to that using paid software. I am finicky about quality, and this seems to me to do a great job. If anyone out there with a high-end stacking tool could comment on that, I would be interested.

Pillar of the Community
pepactonius's Avatar
United States
9395 Posts
 Posted 11/29/2016  8:26 pm  Show Profile   Bookmark this reply Add pepactonius to your friends list Get a Link to this Reply
The final result looks very good, which is what counts in the end.


Quote:
but I have also done stacking without it by adjusting the bellows, you just won't have precisely measured incrementations between steps


I've used a micrometer (along with various metal parts) to move the rear standard of a bellows using measured steps.

I don't know how useful this method is with traditional coins, but sometimes leaving the lens in a fixed spot for the whole stack can be useful when shooting something with overlapping fibers, hairs, etc. This way the entrance pupil remains (almost?) in a fixed position for the whole stack. Of course you need something like Zerene Stacker that does a good job of handling magnification changes. Maybe this technique wouldn't work well for higher-NA finite-corrected microscope objectives, which are sensitive to tube length?

Maybe you'd need use this method with some of the modern 3-D NCLTs out there?
Pillar of the Community
Learn More...
United States
4038 Posts
 Posted 11/30/2016  1:54 pm  Show Profile   Bookmark this reply Add rmpsrpms to your friends list Get a Link to this Reply
The only thing missing is scaling, which is technically required if you don't use a telecentric lens. The canned programs perform scaling changes between images, or you can turn scaling off. I generally turn it off since I have seen very few drawbacks to doing this, and the result ends up being sharper since microscaling tends to blur the images a bit. So although you are not scaling, I would not say it is an absolute requirement.

If you mail me the 8 files (full size, probably in several emails) I will stack them using Helicon and post the results. It looks like some postprocessing of the final rendering may improve the overall look, so I can make some suggestions there as well.
Contact me for photographic equipment or visit my home page at:
http://macrocoins.com
Pillar of the Community
Learn More...
United States
4038 Posts
 Posted 12/01/2016  9:43 pm  Show Profile   Bookmark this reply Add rmpsrpms to your friends list Get a Link to this Reply
mamastinky...I got your files and processed them using Helicon, default settings. I also did just a bit of adjustment to "improve" the look. Here's the result:

How-I-Focus-Stack-Using-Open-Source-Tools..

edited to add: unprocessed (other than downsizing) rendering:

How-I-Focus-Stack-Using-Open-Source-Tools..

edited to add:

The Helicon result looks sharper, but this may be due to 2 orthogonal reasons:

1) I did the stacking at full resolution. This will result in a sharper image, because stacking leaves some artifacts similar to diffraction, and downsizing after stacking reduces or eliminates these effects

2) I downsized by an even 4x. This gives a bit better output resolution. You downsized by an odd amount (~3.74x) and this can cause interpolation errors.
Contact me for photographic equipment or visit my home page at:
http://macrocoins.com
Edited by rmpsrpms
12/02/2016 11:48 am
Valued Member
mamastinky's Avatar
United States
441 Posts
 Posted 12/02/2016  10:22 am  Show Profile   Bookmark this reply Add mamastinky to your friends list Get a Link to this Reply
Ray, that looks very good, although I don't like the lower right corner. How does it look before post-processing, for comparison?
Pillar of the Community
Learn More...
United States
4038 Posts
 Posted 12/02/2016  11:50 am  Show Profile   Bookmark this reply Add rmpsrpms to your friends list Get a Link to this Reply
I added the unprocessed (other than downsizing) rendering to my last post. Not much difference. I did not check the stack images to see if they were all in order. I just stacked them based on numbering. It looks like the area on the coin edge may be either missing from the stack, or out of order, which confuses the program. Did you do the stack shooting all in one sweep from top to bottom (or bottom to top)?
Contact me for photographic equipment or visit my home page at:
http://macrocoins.com
Valued Member
mamastinky's Avatar
United States
441 Posts
 Posted 12/02/2016  1:07 pm  Show Profile   Bookmark this reply Add mamastinky to your friends list Get a Link to this Reply
Yes, I shot from low to high. I was not aware about the interpolation issues related to downsizing ratio, I will have to look into that more, thanks. Helicon's result does look sharper, and what you said about downsizing after stacking makes sense to me.

I decided to try the stack again with Enfuse using the full size photos, for comparison. Then I downsized by 4x, just as you did. Strangely, my result using the full-sized images are less sharp. Here is the result:

How-I-Focus-Stack-Using-Open-Source-Tools..


Edit: I tried the stack after reducing 4x next, and I was so surprised by the result that I had to include it here as well:


How-I-Focus-Stack-Using-Open-Source-Tools..
Edited by mamastinky
12/02/2016 1:21 pm
Pillar of the Community
Learn More...
United States
4038 Posts
 Posted 12/02/2016  11:16 pm  Show Profile   Bookmark this reply Add rmpsrpms to your friends list Get a Link to this Reply
Hmm, I did the downsize first, then stacked, and it got rid of the odd area of out of focus in lower right near rim. It seems your images are confusing Helicon for some reason. The downsized-first stack looks pretty good, better than I expected. Maybe my early tests showing full res to be superior to downsized source images had something else going on. Anyway, here is Helicon's downsized-first output, no modifications:

How-I-Focus-Stack-Using-Open-Source-Tools..
Contact me for photographic equipment or visit my home page at:
http://macrocoins.com
  Previous TopicReplies: 7 / Views: 2,093Next Topic  

To participate in the forum you must log in or register.



    




Disclaimer: While a tremendous amount of effort goes into ensuring the accuracy of the information contained in this site, Coin Community assumes no liability for errors. Copyright 2005 - 2026 Coin Community Family- all rights reserved worldwide. Use of any images or content on this website without prior written permission of Coin Community or the original lender is strictly prohibited.
Contact Us  |  Advertise Here  |  Privacy Policy / Terms of Use

Coin Community Forum © 2005 - 2026 Coin Community Forums
It took 0.61 seconds to rattle this change. Forums