Jump to content
UltravioletPhotography

I have written a golang tool to align images for combining them into R, G, B channels


lukaszgryglicki

Recommended Posts

lukaszgryglicki

Feel freee to use: https://github.com/lukaszgryglicki/align.

 

You just need to install "golang" on mac/linux/windows and then install that package.

 

Like this: *go install github.com/lukaszgryglicki/align/cmd/align*.

 

Then you can align and combine R, R, B images into resulting image like this: *align R.JPG G.JPG B.JPG Aligned.JPG*.

 

See examples on the GitHub repo - it's a very simple but useful program (IMHO). It detects how many pixels movements are needed to align all images together. More details about algorithm here: https://github.com/lukaszgryglicki/align#some-details

 

 

Link to comment
Andy Perrin

Nice, although you don’t account for rotations. I use the phase correlation method with Fourier transforms for this usually in MATLAB, because it can handle both, in a computationally efficient way, and works better when the channels are very different (like UV vs IR, where just subtracting doesn't work so well). 
 

https://en.m.wikipedia.org/wiki/Phase_correlation

Link to comment
lukaszgryglicki

Yes, I don't account for rotations, I just optimise for best shifts possible without modifying source images.

Also note that this is a simple program written in just a few hours to fit my particular needs.

 

I want debayered TIFFs from "AccuRaw monochrome" which were shot with different filters on Nikon D600 mono (and Fuji 50R in the near future) and to combine them into RGB image, for example R-G-B <-> IR-Vis-UV.

 

BTW: min(sum(all px, abs(px1-px2))) worked well for me to combine IR, Vis and UV shots into a single file - it found exact translations needed.

 

 

 

Link to comment
Andy Perrin

BTW: min(sum(all px, abs(px1-px2))) worked well for me to combine IR, Vis and UV shots into a single file - it found exact translations needed.

 

You will find that it depends on the subject. For example, a flower that is white in IR and has complex dark UV patterns will probably not work so well. 

Link to comment
lukaszgryglicki

So min will be higher, but still finds amount of shift needed. Like values around that min will still be higher - that's the idea.

But yes, this will need to be battle tested and probably updated if needed.

Unless I just find any other program that just do this for me - exactly this - given 3 channel images, compose them into RGB image and do necesarry shifts/rotations even maybe scaling needed.

 

 

Link to comment
Andy Perrin

Nah, hypothetically, suppose you have a grey background in both UV and IR, with an all white flower in IR and all black in UV. If they are offset, the MAX will be when they are aligned (black - white). Try making some fake images like that with just a circle to represent the flower.

 

Should be easy to google a phase correlation program. Examples:

https://github.com/dpark6060/Phase_correlation_registration

 

https://cgcooke.github.io/Blog/computer vision/nuketown84/2020/12/19/FFT-Phase-Correlation.html

 

That second link is probably easy to translate to golang if you have the right libraries for FFT etc.

Link to comment
lukaszgryglicki

I'm 100% sure it wont work for all cases and for special images designed to make it fail. But it will work for most of my cases and does exactly what I need.

It is also in golang (statically typed, compiled language) and uses multiple CPU cores - I also think there are many such programs (I was searching for "align" not for "phase correlation") but I (probably?) don't need that much and your example is in python and that would be much slower (I guess).

 

Anyway, I just prefer to write something myself sometimes over trying to adapt something already existing... currently it does the job for me and I decided that this may be useful for someone here - if not - no problem, just wanted to share some small contribution.

 

Link to comment
Andy Perrin

Okay, well I guess until it doesn't work for something you want it is going to be fine, but when you need to improve it you will know which direction to go in.

 

You can parallelize the phase correlation method also, by the way, there is nothing preventing the use of multiple cores or writing in golang.

Link to comment
lukaszgryglicki

It is perallelized - different shifts are computed in parallel in as many threads as the number of CPU cores that golang detects.

 

Link to comment

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...