How this PCA code written here .can someone plz explain.

조회 수: 2 (최근 30일)
praveen singathi
praveen singathi 2021년 3월 20일
답변: Amish 2024년 10월 8일
Im adding this PCA function into DWTPCAv code but i dont undrstand what is happening with this code.here ca is the dwt coefficient plzz help
[ca{i},ch{i},cv{i},cd{i}] = dwt2(a{i},'db3');
[fca m1]=fuse_pcaany(ca,n);
function [y1 a1] = fuse_pcaany(ca,n)
for i=1:1:n
M(:,i)=ca{i}(:);
end
[V, D] = eig(cov(M));
[z1 s1] = size(D);
for i=1:1:s1
D1(i)=D(i,i);
end
D2=max(D1(i));
for i=1:1:s1
if D1(i)==D2;
a1 = V(:,i)./sum(V(:,i));
end
end
[z2 s2]=size(ca{1});
% and fuse
y1=zeros(z2,s2);
for i=1:1:n
y = a1(i)*ca{i};
y1=y1+y;
end

답변 (1개)

Amish
Amish 2024년 10월 8일
Hi Praveen,
It seemsl like you are trying to understand how the above-mentioned code is functioning. It looks like the code snippet that you have provided is part of a larger process to perform Discrete Wavelet Transform (DWT) and Principal Component Analysis (PCA) based image fusion.
The function function "[y1 a1] = fuse_pcaany(ca, n)", constructs a matrix "M" where each column is a vectorized form of the approximation coefficients from each image. "eig" computes the eigenvectors V and eigenvalues D of the covariance matrixof M.
Then the vector 'a1' is found using maximum eigen values(D2) and its corresponding vector 'v' from the diagonal values of 'D'. The final loop does the fusion by adding weighted approximation coefficients from each image to "y1" using the previously calculated weights "a1".
To summarize, the DWT is used to get wavelet coefficients out of the images which is then used with PCA to find the most significant coefficients to fuse these components across multiple images using the PCA-derived weights.
The documentation for the eig and cov functions can be referred here:
Hope this helps!

카테고리

Help CenterFile Exchange에서 Dimensionality Reduction and Feature Extraction에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by