I tried to implement PCA based image fusion with C++ and OpenCV, but I can't understand, that exactly I have to do. As I read in some of tutorials on PCA based image fusion, when there are two pictures I1 and I2 of the same scene of sizes NxM in greyscale, algorithm is:
- Create a matrix of size NMx2, where column 1 is a pixel values of I1, and column 2 is a pixel values of I2 .
- In some of tutorials that I found this is necessary to find average value of 1 column and extract it from 1 column, and average value of 2 column and extract it from second column. Is it necessary?
- Find a covariance matrix of this matrix MNx2.
- Find eigenvalues and eigenvectors of this covariance matrix. In one of tutorials, I read that it necessary to choose an eigenvector, which is corresponding to larger eigenvalue and normalize this eigenvector. In OpenCV, when use cv::eigen() function, it returns eigenvectors, which yet are normalized. And in one of tutorials, I read that sum of obtained components should be P1+P2=1.
So, if I get eigenvector, correcponding to larger eigenvalue, for example like this eigen = (0,705353; 0,71453) = (u, v)
, that is a formula for fused image I_fus
?
I_fus = u*I1+v*I2
? Or
I_fus = u/(u+v)*I1+v/(u+v)*I2
?
Or I wrong and there is another formula for fused image?