Initial implementation of the matching algorithm has both the aforementioned
fillValue input of the
padCut() function call being -1 and the error-calculation belimited to only matrices with values that are not -1 (essentially, masking the calculation to only parts of the original matrix still "visible" after shifting the matrice) in addition to normalizing the error by how many pixels were included in the calculation. However, this is prone to producing color-layer "match-displacement" calculations that "prefers" a lower number of pixels that still remain in viewing window, due to the lower number producing a higher possibility of a smaller number. This is especially impactive when using SSD and the pyramid-search, as there are less pixels to count over.
Further experimentations led to the removal of the masking and the setting of the fillValue input to 0.5, as 0.5 worked best for all pictures -- further study implies that 0.5 works best due to 0.5 being a "neutral" value, sitting right in the middle of the grayscale range. In contrast, setting the fillValue to a 0 will push the error-value calculation towards displacements that places darker parts of a color layer on top of the "empty"/fillValue-filled spots, while setting the fillValue to a 1 will push the error-value calculation towards displacements that places lighter parts of a color layer on top of the "empty"/fillValue-filled spots.
2.
Each 3-color negatives come with a border that can affect calculations significantly, especially if the the 3-color negatives are split apart to 1-color negatives in a way that the borders don't align exactly. To fix this, simply cutting the border improves matching calculations significantly.
Before, without border cropping.
After, with border cropping.
3.
Alignment order (G to B then R to B vs G to B then R to G, etc.) matters, especially in situations where the color glass pictures have wildly different contrast levels. Most of these alignments used a specific order for alignment: G to B, and R to B. While this worked for most cases, it particularly fails in emir.tif.
Alignment order: G to B, R to B
Post-matched R color negative
Post-matched G color negative
Post-matched B color negative
Final result
Alignment order: G to B, R to (post-match shifted) G
Post-matched R color negative
Post-matched G color negative
Post-matched B color negative
Final result