9
\$\begingroup\$

I have several collections of 400 or so photos that I took using interval shooting. Sometimes the camera moves very slightly while shooting. My goal is to align all the images at full resolution so that I can combine them into a single image. (The combining will be done in software I wrote myself.)

Usually I use Photoshop's auto-align feature for aligning images, which produces excellent results, but with this many images it seems either to not work or to be extremely slow. Photoshop stopped responding and was still taking 100% CPU days later when I killed it. I tried changing it to perspective transform only (rather than auto) but it didn't seem to help.

From a bit of google searching some people say you can do the aligning in Photoshop in batches. However, as far as I can tell this is not possible. If I align the first twenty images separately from the next twenty, then the two sets of images won't be aligned with each other. Unless there is a way to speed up Photoshop's auto-align feature, I'm looking for software that's designed for the task of aligning this many images.

One option I've tried is align_image_stack, which is part of Hugin. However, this had problems of its own. On my most recent try, it took days to run and didn't correctly align the images; it also saves the files in an inconvenient format. (See the edit history for details.) I suspect that both Hugin and Photoshop are optimised for aligning a few dozen images at most and aren't really designed for large batches.

These are RAW files straight out of my Pentax K50 and they're about 14-15Mb each, so it's a lot of data when you put all of them together - they can't all fit into memory, and I'm looking for a tool that's designed with this in mind.

I should mention also that I'm on a Mac.

\$\endgroup\$
6
  • \$\begingroup\$ Do not align the images in sets, Use one main as a reference and aligh the rest with this basic one, or try using the last one of the previous set. \$\endgroup\$
    – Rafael
    Nov 12, 2016 at 16:24
  • 1
    \$\begingroup\$ @Rafael how does one do that, though? Photoshop doesn't seem to give me the option to set one layer as the reference for aligning the rest. The only option is to choose the types of transformation that are allowed, and then it tries to align all the layers with each other. \$\endgroup\$
    – N. Virgo
    Nov 12, 2016 at 16:38
  • \$\begingroup\$ you can try macros (recording Action) to automate this \$\endgroup\$ Mar 1, 2017 at 16:27
  • \$\begingroup\$ I have the same problem than you; however, I haven't found any answer. Did you solve the problem? How? \$\endgroup\$
    – Daniel
    Jan 12, 2018 at 6:13
  • \$\begingroup\$ @Daniel I can't remember what I did in the end, but I think it was more along the lines of working around the problem rather than solving it. I'd still like a good solution. I'm sorry I can't be more helpful. \$\endgroup\$
    – N. Virgo
    Jan 12, 2018 at 7:36

8 Answers 8

6
\$\begingroup\$

I could not find a solution with raw files, I know the recent version of hugin is supposed to support raw files using dcraw but I cannot test it myself. The next good solution in my opinion is to convert all of your raws to tif files or other lossless image format and use them.

For my method I mainly hugin_tools on the terminal but I also use the GUI so keep in mind you need both installed. You can find the hugin suit here for download. Also I am using Ubuntu on my machine but the procedure on mac should be the same.

First thing you need to put all the photos in one folder, this is mainly for convenience' sake but will help with the commands later.

Generate a pto file

Next you need to generate a pto file, that is the file where all the image transformation data is saved. You can do so by typing:

pto_gen *.jpg

in the terminal where all the photos are.

Cropping to still area

Now you need to find matches between all of your images, before you do that there is an optional part which will greatly reduce errors if there are moving objects in your set.

Open the hugin project you generated and change the interface to advanced.

interface changing

In the window that opened go to the masks tab and there chose the crop tab and select your first image. Now make sure 'all images of selected lens' is checked and then drag from the edges of the image and crop to the area with the least or no amount of movement. This will constrict the match finder to that area and reduce error in the remapping stage. Now you can save and exit the program.

image cropping

Finding control points

Now you can find the matches, type:

cpfind --linearmatch *.pto

into the terminal, this will find matches between pairs of images. You can also find matches between all images by simply omitting the ‘linearmatch’ option but if you have hundreds of images it will take a very long time and is also probably unnecessary. You can learn more about cpfind here.

Next you need to clean the control points you found, there are two commands for that purpose:

celeste_standalone -i default.pto -o default.pto

will try to erase control points on clouds (More information here). And

cpclean -o default.pto default.pto

will remove control points with high error value. (cpclean help page)

Reset crop

Now that we are done with control points open the new generated project called default and head back to the masks tab like before, here select the crop tab again and click the reset button, this will disable the crop from all the images.

Optimizing

After that you need to optimize the control points. Type:

pto_var --opt="y, p, r, TrX, TrY, TrZ" -o default.pto default.pto
autooptimiser -n -o default.pto default.pto

That will optimize the position and distortion of your image set, you can learn more about this process here.

You are almost done, now just type:

pano_modify -o default.pto --projection=0 --fov=AUTO --center --canvas=AUTO --crop=AUTOHDR --output-type=REMAPORIG default.pto

to change the project configuration.

Remmaping

Lastly just type:

nona -m TIFF_m -o remapped default.pto

to output the remapped images. If you want to also stack the images together you can also use:

hugin_stacker --output=median --mode=median remapped*.tif

More information about hugin command-line tools can be found here.

That's it, that my take on your problem, there are a few missing links because this is my first answer so i was limited to 8. If there are any mistakes or you have any problems please let me know, also my English is not the best so sorry if I made any grammar or spelling mistakes. Cheers!

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Welcome! This is a nicely formatted answer, and quite detailed. Well done. Keep it up. \$\endgroup\$ May 8, 2019 at 0:00
  • \$\begingroup\$ This looks great, thank you so much for including detailed instructions. I will try to follow these instructions the next time I need to do this, and will let you know how it goes. (I am not sure when that will be.) \$\endgroup\$
    – N. Virgo
    May 8, 2019 at 3:17
  • 2
    \$\begingroup\$ Awesome answer. In one of the steps, I got an error that celeste.model could not be found. So copying /Applications/Hugin/Hugin.app/Contents/Resources/xrc/celeste.model into the project directory solved it. (the issue was also mentioned here bugs.launchpad.net/hugin/+bug/789934) \$\endgroup\$
    – narengi
    Oct 14, 2021 at 22:43
2
\$\begingroup\$

ImageJ was developed for processing images for microscopy and astronomy, where this problem comes up frequently.

Here's a tutorial which relies on importing all the images into a "stack" first and aligning to a feature. It can probably do your "combining" too (I've used it to add multiple extreme-low-light images, for example).

A more modern fork is Fiji, which might be easier to use. Both are free/opensource and cross-platform.

\$\endgroup\$
2
  • \$\begingroup\$ It seems ImageJ is limited to data sets that can fit into memory, which makes it unsuitable for my images. Or am I wrong about that? Please correct me if so! \$\endgroup\$
    – N. Virgo
    Feb 12, 2018 at 7:45
  • \$\begingroup\$ @Nathaniel I could believe that the entire stack must fit into memory (including swap but that would be stupidly slow). You might have to run or script it to do a batch at a time, as I did when I needed the average of 1000 images \$\endgroup\$
    – Chris H
    Feb 12, 2018 at 8:38
1
\$\begingroup\$

SOLVED! I found Bruno Postle's solution (https://groups.google.com/forum/#!searchin/hugin-ptx/nona-deshake%7Csort:date/hugin-ptx/yFE6VF-mtGk/U8OYAuNYCgAJ) and implemented it on Windows. https://sites.google.com/site/alistargazing/home/image-processing/time-lapse-deshake. Takes 4 sec per image on an old laptop, and less than 5 minutes to launch a new project [once you have got the preliminary setup done] My use-case problem was that during the time-lapse, my tripod very gradually shifted. When I stacked the 500+ images, they were not aligned. P.S. I can now go back a decade and save a few other projects!

\$\endgroup\$
1
  • \$\begingroup\$ Cool, thank you for posting this! I'm on a Mac, but I might try getting the original script to run some time. \$\endgroup\$
    – N. Virgo
    Feb 4, 2020 at 5:55
0
\$\begingroup\$

Import in After Effect as sequence, stabilize, export as images. Don't know the exact details, but you'll be able to find it online. Wouldn't know how to do it automatically in PS, doubt it's possible..

\$\endgroup\$
2
  • \$\begingroup\$ Will that work at full resolution? In the end I'm combining these into a single image, so I'd need to keep the full resolution of the frames. (I don't have After Effects.) \$\endgroup\$
    – N. Virgo
    Nov 12, 2016 at 14:18
  • \$\begingroup\$ You need to do the tests, because you are the one that have your own photos. I dont know what is the full resolution for example, or how fast your computer is. :o( I know that the program has limitations on the resolution but when using video because the codec. But I am not sure about still images. \$\endgroup\$
    – Rafael
    Nov 12, 2016 at 17:10
0
\$\begingroup\$

I've used Canon Photo Stitch and had success with many images. You may want to process smaller groups of photos and then process the groups.

If you have access to a computer with gigs and gigs of RAM, and you should be able to process in Photoshop.

\$\endgroup\$
0
\$\begingroup\$

Not a photoshop expert.

Try this: Open one image. Set it as background, and lock.

Import N images. Align them. Hide the result layers.

Import another N. Align.

Unhide the first batch.

Play your interval set.

If it doesn't work there will be 2 jerks -- one right after the first shot, (because the align with the second batch changed it.) and one between N and N+1

To save time, I'd start with N equal to around 10 or 20, and only do 2 batches.

If it works, you can play with increasing the size of N. In this scenario, you keep adding batches and hiding/locking the non-current batch.

\$\endgroup\$
0
\$\begingroup\$

Your're looking for a panaroma stitching software, which is able to do Gigapixels.

If you google "How to create a gigapixel image", the usual suspects that turn up are (in no particular order):

  • PTgui
  • Hugin
  • Gigapan Stitch
  • Microsoft ICE (Image Composite Editor)

This list is proabably not complete. YMMV.

\$\endgroup\$
4
  • 2
    \$\begingroup\$ Panorama stitching isn't exactly what I want to do. The images are all of more or less the same scene (the camera movement was accidental/unavoidable), and I want to keep them all as separate files, just align them. (I will then combine them into a single image using a special algorithm that I wrote myself.) Still, perhaps some of this software can do this task. \$\endgroup\$
    – N. Virgo
    Mar 19, 2017 at 23:14
  • \$\begingroup\$ For alignment you could use autopano-sift or similar tools to identify control-points and use these to calculate the necessary tilt and shift. Can be done, but requires deep knowledge of the tools and how to tweak them to make them do, what you want them to do. I'd ask in the respective mailing lists of these tools. \$\endgroup\$
    – Grimaldi
    Mar 20, 2017 at 17:41
  • \$\begingroup\$ Hugin will definitely work for this. \$\endgroup\$
    – user39557
    Jan 14, 2018 at 3:57
  • \$\begingroup\$ @cegaton I mentioned Hugin in the question - it sometimes produces malformed tif files, which is why I'm looking for another solution. \$\endgroup\$
    – N. Virgo
    Feb 12, 2018 at 7:46
0
\$\begingroup\$

To properly align the images in batches you must include one particular image as the anchor image for all the batches. So, if you take image nr. 1 as your anchor image, then you can align images 1 to 20 in a batch, and for the next batch you choose images 1, 21, 22, ..., 39. The next batch consists of images 1, 40, 41,...59. This way all the images will be aligned to image nr. 1.

\$\endgroup\$
6
  • \$\begingroup\$ I assume you are talking about Photoshop? If so, please could you tell me how to set an image as the anchor image for alignment? I don't want to say I'm certain, but I believe this can't be done. It aligns all the images to each other, not to one specified image. \$\endgroup\$
    – N. Virgo
    Mar 22, 2018 at 0:41
  • \$\begingroup\$ @Nathaniel I had Hugin in mind, but in general, if you have N pictures then there are N-1 alignments to be done as you can always shift, rotate etc. all the N images by the same amount without affecting alignment. A program that doesn't constrain the alignments by anchoring one of the pictures will risk rotating or translating all the pictures by some uncontrolled amount. \$\endgroup\$ Mar 22, 2018 at 1:06
  • \$\begingroup\$ Ok, but then could you tell me how to set an anchor image in Hugin? There is nothing in the instructions for align_image_stack (the backend it uses for alignment) that indicates this is possible. \$\endgroup\$
    – N. Virgo
    Mar 22, 2018 at 1:13
  • \$\begingroup\$ @Nathaniel With Hugin you just load the images, right clicking on the entry of an the image opens a menu where you can select it to be the anchor for position. \$\endgroup\$ Mar 22, 2018 at 4:16
  • 1
    \$\begingroup\$ align_image_stack assumes the first images is the anchor. So you could use the command line: align_image_stack -a aligned Anchor.jpg image000[0-9].jpg for example if you wanted to use align_image_stack in batches. \$\endgroup\$
    – moo
    Jan 23, 2020 at 18:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.