usnistgov / MIST

Microscopy Image Stitching Tool
Other
120 stars 33 forks source link

Why isn't FFT-based Normalized Cross-Correlation used? #45

Open zacharynevin-stemcell opened 5 months ago

zacharynevin-stemcell commented 5 months ago

Hi there,

The Matlab documentation has a function called normxcorr2 that does normalized cross-correlation in the FT domain, operating much much faster than normalized cross-correlation without FFT.

As I understand it, the MIST algorithm first does phase-cross correlation and then uses a peak-searching algorithm to find the image offset that corresponds to the maximum NCC.

I'm just curious, especially because I don't have a lot of experience with image analysis, what is the reason that a peak-search algorithm is used instead of something like normxcorr2?

tblattner commented 5 months ago

There are two stages in the algorithm for MIST. First we find the relative displacements for all neighbors. Then we do a global optimization.

In the first stage we apply normalized cross correlation in the FT domain when finding the candidate regions. In the second stage we calculate stage parameters (or passed in from advanced options) to fine-tune the search space based around the candidate regions. Then we do cross correlations without FFT in a hill-climbing fashion to find the final relative displacement. The search area is much smaller at this point, so we found it unnecessary to operate in the FFT domain at this stage, although it might be worthwhile to analyze the implications here further.

@joechalfoun can add additional insights. I'm not sure if we use the normxcorr2 routine or not.