How to reduce the dimensions of an image after applying PCA.
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have an .tif image with 200x350x50 image which has 50 bands of data and I want to reduce it to 200x350x20 with 20 bands. I have selected few bands accordingly i.e(1,5,7,8,11,15,18,21,22,25,29,31,32,33,34,37,41,45,46,47) 20 bands.
I have used pca(X) to find the principal component and written it into a new file.
I_d = double(imread('clicker.tif')); X = reshape(I_d,size(I_d,1)*size(I_d,2),50); coeff = pca(X); Z = X*coeff; Ipc1 = reshape(Z(:,1),size(I_d,1),size(I_d,2)); Ipc2 = reshape(Z(:,2),size(I_d,1),size(I_d,2)); Ipc3 = reshape(Z(:,3),size(I_d,1),size(I_d,2)); Ipc4 = reshape(Z(:,4),size(I_d,1),size(I_d,2)); Ipc5 = reshape(Z(:,5),size(I_d,1),size(I_d,2)); Ipc6 = reshape(Z(:,6),size(I_d,1),size(I_d,2)); Ipc7 = reshape(Z(:,7),size(I_d,1),size(I_d,2)); Ipc8 = reshape(Z(:,8),size(I_d,1),size(I_d,2)); Ipc9 = reshape(Z(:,9),size(I_d,1),size(I_d,2)); Ipc10 = reshape(Z(:,10),size(I_d,1),size(I_d,2)); Ipc11 = reshape(Z(:,11),size(I_d,1),size(I_d,2)); Ipc12 = reshape(Z(:,12),size(I_d,1),size(I_d,2)); Ipc13 = reshape(Z(:,13),size(I_d,1),size(I_d,2)); Ipc14 = reshape(Z(:,14),size(I_d,1),size(I_d,2)); Ipc15 = reshape(Z(:,15),size(I_d,1),size(I_d,2)); Ipc16 = reshape(Z(:,16),size(I_d,1),size(I_d,2)); Ipc17 = reshape(Z(:,17),size(I_d,1),size(I_d,2)); Ipc18 = reshape(Z(:,18),size(I_d,1),size(I_d,2)); Ipc19 = reshape(Z(:,19),size(I_d,1),size(I_d,2)); Ipc20 = reshape(Z(:,20),size(I_d,1),size(I_d,2)); Ipc21 = reshape(Z(:,21),size(I_d,1),size(I_d,2)); Ipc22 = reshape(Z(:,22),size(I_d,1),size(I_d,2)); Ipc23 = reshape(Z(:,23),size(I_d,1),size(I_d,2)); Ipc24 = reshape(Z(:,24),size(I_d,1),size(I_d,2)); Ipc25 = reshape(Z(:,25),size(I_d,1),size(I_d,2)); Ipc26 = reshape(Z(:,26),size(I_d,1),size(I_d,2)); Ipc27 = reshape(Z(:,27),size(I_d,1),size(I_d,2)); Ipc28 = reshape(Z(:,28),size(I_d,1),size(I_d,2)); Ipc29 = reshape(Z(:,29),size(I_d,1),size(I_d,2)); Ipc30 = reshape(Z(:,30),size(I_d,1),size(I_d,2)); Ipc31 = reshape(Z(:,31),size(I_d,1),size(I_d,2)); Ipc32 = reshape(Z(:,32),size(I_d,1),size(I_d,2)); Ipc33 = reshape(Z(:,33),size(I_d,1),size(I_d,2)); Ipc34 = reshape(Z(:,34),size(I_d,1),size(I_d,2)); Ipc35 = reshape(Z(:,35),size(I_d,1),size(I_d,2)); Ipc36 = reshape(Z(:,36),size(I_d,1),size(I_d,2)); Ipc37 = reshape(Z(:,37),size(I_d,1),size(I_d,2)); Ipc38 = reshape(Z(:,38),size(I_d,1),size(I_d,2)); Ipc39 = reshape(Z(:,39),size(I_d,1),size(I_d,2)); Ipc40 = reshape(Z(:,40),size(I_d,1),size(I_d,2)); Ipc41 = reshape(Z(:,41),size(I_d,1),size(I_d,2)); Ipc42 = reshape(Z(:,42),size(I_d,1),size(I_d,2)); Ipc43 = reshape(Z(:,43),size(I_d,1),size(I_d,2)); Ipc44 = reshape(Z(:,44),size(I_d,1),size(I_d,2)); Ipc45 = reshape(Z(:,45),size(I_d,1),size(I_d,2)); Ipc46 = reshape(Z(:,46),size(I_d,1),size(I_d,2)); Ipc47 = reshape(Z(:,47),size(I_d,1),size(I_d,2)); Ipc48 = reshape(Z(:,48),size(I_d,1),size(I_d,2)); Ipc49 = reshape(Z(:,49),size(I_d,1),size(I_d,2)); Ipc50 = reshape(Z(:,50),size(I_d,1),size(I_d,2)); I_b = zeros(350,400,50) ; I_b(:,:,1) = Ipc1; I_b(:,:,2) = Ipc2; I_b(:,:,3) = Ipc3; I_b(:,:,4) = Ipc4; I_b(:,:,5) = Ipc5; I_b(:,:,6) = Ipc6; I_b(:,:,7) = Ipc7; I_b(:,:,8) = Ipc8; I_b(:,:,9) = Ipc9; I_b(:,:,10) = Ipc10; I_b(:,:,11) = Ipc11; I_b(:,:,12) = Ipc12; I_b(:,:,13) = Ipc13; I_b(:,:,14) = Ipc14; I_b(:,:,15) = Ipc15; I_b(:,:,16) = Ipc16; I_b(:,:,17) = Ipc17; I_b(:,:,18) = Ipc18; I_b(:,:,19) = Ipc19; I_b(:,:,20) = Ipc20; I_b(:,:,21) = Ipc21; I_b(:,:,22) = Ipc22; I_b(:,:,23) = Ipc23; I_b(:,:,24) = Ipc24; I_b(:,:,25) = Ipc25; I_b(:,:,26) = Ipc26; I_b(:,:,27) = Ipc27; I_b(:,:,28) = Ipc28; I_b(:,:,29) = Ipc29; I_b(:,:,30) = Ipc30; I_b(:,:,31) = Ipc31; I_b(:,:,32) = Ipc32; I_b(:,:,33) = Ipc33; I_b(:,:,34) = Ipc34; I_b(:,:,35) = Ipc35; I_b(:,:,36) = Ipc36; I_b(:,:,37) = Ipc37; I_b(:,:,38) = Ipc38; I_b(:,:,39) = Ipc39; I_b(:,:,40) = Ipc40; I_b(:,:,41) = Ipc41; I_b(:,:,42) = Ipc42; I_b(:,:,43) = Ipc43; I_b(:,:,44) = Ipc44; I_b(:,:,45) = Ipc45; I_b(:,:,46) = Ipc46; I_b(:,:,47) = Ipc47; I_b(:,:,48) = Ipc48; I_b(:,:,49) = Ipc49; I_b(:,:,50) = Ipc50; multibandwrite(I_b,'pca..tif','bsq');
0 commentaires
Réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!