Table of Contents ▸ List of Commands ▸ Features Extraction ▸ pca | ◀ patches | matchpatch ▶ |
pca
Arguments:
- _output_mode,_target_dim[%]>0,_normalization_mode={ 0:None | 1:Center | 2:Center+scale }
Description:
Perform PCA (Principal Component Analysis) on selected images, viewed as sets of vector-valued samples Xk.Bits of output_mode selects what output data are returned on the image stack:
1: Output image of vector-valued samples Yk = Mt*(Xk - avg)/std, that are the projections of the Xk in a vector sub-space of (lower) dimension target_dim. avg is the average vector of all Xk (or zero vector if normalization_mode==0). std is the standard deviation vector of all Xk (or all-ones vector if normalization_mode<2). Mt is the transpose of M, the matrix of the target_dim first eigenvectors (arranged by columns) of the covariance matrix of the Xk.
2: Output vector avg: average of the Xk.
4: Output vector std: standard deviations of the Xk.
8: Output matrix M: projection matrix (orthonormal).
Knowing avg, std and M makes it possible to (approximately) retro-project the Yk in the initial vector space, by computing Xk = avg + std*M*Yk for each image pixel.
Default values:
output_mode=15, target_dim=100% and normalization_mode=1.
Example of use:
shape_dragonfly 400 mul 128 0 eval.. "i?da_push([x,y])" da_freeze. pca. 11,2 eval "C = I[#-2,0]; M = transpose(crop(#-1),2); repeat(2,k,polygon(#0,-2,C-1000*M[2*k,2],C+1000*M[2*k,2],1,0xF0F0F0F0,180)); ellipse(#0,C,5,5,0,1,255)" k[0]
