I drastically improved my matching algorithm by combining it with a histogram comparison.
My final matching probability is calculated like this:
probability = (matchingProbability * 2 + histProbability) / 3
Also I found that inverting images can improve template matching further.
this.tmplMeanStdDev = getMeanStdDev(tmpl)
const meanArr = tmpl.mean()
From Computational Frameworks for the Fast Fourier Transform:
Standard radix-2 procedures are based upon the fast synthesis of two half-length
DFTs. The split-radix algorithm is based upon a clever synthesis of one half-length
DFT together with two quarter-length DFTs
On the otherhand, Radix p uses divide and conquer to recursively split the dft into p ...