Automatically combining trichrome and pseudochrome images

In a previous post, I was manually combining the RGB channels, with a bunch of experimentation to try to select the right channels, and a decent amount of color correction. I've not been able to maintain a stable shoot order, especially for full color/no filter and full spectrum shots, up to the digital files. For example, from a shoot from last year, a single image ended up with 6 images total. To go through each of these would take a while, and while I could probably sus out which image is green (folliage, dark sky) vs IR (folliage, bright sky), I'm lazy.

So I forced a computer to write a script that would force a different computer to do it for me. I'm using imagemagick, and some openCV. The openCV is needed to align the images, by producing an intermediate aligned image. The images are all different spectra, so a more smart approach is needed, because the contrast is all different. The other issue I ran into that the script writing computer had trouble with is, after I made it parallel, the intermediate files would have the same name between different output files, so I had to massage the script a bit.

This script will produce all the permutations of the input filenames, and produce an output image that is aligned, and color corrected (simple image magick --auto-color), for each permutation of images. So for 6 input files, there would be 120 output files if I got my money's worth for my stats class. This can be a lot, but it is easy to have the computer do the math, walk away, and pick the one(s) that look right.

One other thing, my input files are all multi-page .tif raw files from my nikon film scanner, so I needed to use [0] on the inputs.

Here's some output: I'm honestly not happy with any of the 120 photos of the water scene, the HR50 didn't do too good, and none of the colors are great. The grafiti looks great though, and you can see some weird IR effects on the shopping cart. In the future, I need to be better about only taking the 4-5 shots and making sure they are well exposed.

Here's the code, it is not great, auto generated and all, but it is functional.