Loading...
Compute the covariance matrix of image patches for PCA-based texture analysis.
Given an image and patch size, extract all overlapping patches, flatten them to vectors, and compute the covariance matrix. This is a fundamental step in texture analysis and eigenface computation.
Algorithm:
The covariance matrix Σ captures correlations between pixel positions within patches.
Applications:
image = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
patch_size = 2[[2.5, 2.5, 2.5, 2.5], [2.5, 2.5, 2.5, 2.5], [2.5, 2.5, 2.5, 2.5], [2.5, 2.5, 2.5, 2.5]]
Step 1: Extract 2×2 patches From 3×3 image, we get 4 overlapping patches:
Step 2: Create data matrix X (4×4) X=1245235645785689
Step 3: Compute mean and center Mean vector: [3, 4, 6, 7] Xc=X−mean
Step 4: Compute covariance Σ=31XcTXc
All entries are 2.5 due to the regular structure of this simple example.