PCA Compression
PCA Compression reduces the spectral dimensionality of the current hyperspectral dataset using principal component analysis.
Overview
PCA Compression reduces the spectral dimensionality of the current hyperspectral dataset using principal component analysis.
IDCubePro standardizes every spectral band, computes principal components, and retains the minimum number of components required to reach the selected cumulative explained variance.
The current working cube is replaced by the PCA score cube. The original dataset is not overwritten on disk unless you later save or export it.
1. Load a hyperspectral dataset.
2. Open PCA Compression from the Preprocessing Center.
3. Enter the percentage of cumulative variance to preserve.
4. Click Apply PCA Compression.
5. IDCubePro standardizes the spectral bands and computes PCA.
6. The smallest number of principal components reaching the requested variance is retained.
7. The current working dataset is replaced by the PCA component cube.
8. Review the PCA Compression Results window.
9. Optionally click Export Details to save the compression summary and component statistics.
10. Use Reset Preprocessing if you want to restore the original dataset.
The Variance to preserve (%) field controls how many principal components are retained.
A higher value retains more of the original variance but usually keeps more components and therefore provides less compression.
A lower value usually keeps fewer components and produces stronger dimensionality reduction, but more spectral variation is discarded.
For example, a value of 95 retains the minimum number of principal components whose cumulative explained variance reaches at least 95%.
PCA transforms the original correlated spectral bands into a new set of orthogonal principal components.
PC1 captures the largest amount of variance in the standardized dataset. PC2 captures the largest remaining variance orthogonal to PC1, and subsequent components capture progressively smaller amounts of variance.
The PCA score cube therefore contains component scores rather than physical reflectance or intensity values at specific wavelengths.
Before PCA, each spectral band is centered by subtracting its mean and scaled by its standard deviation.
This gives each non-constant band comparable weight in the covariance calculation and prevents bands with numerically larger intensity scales from automatically dominating the PCA solution.
Constant or effectively constant bands are handled safely by assigning a standard-deviation scale of 1.
NaN or infinite pixel values are replaced independently within each band using that band's finite mean before PCA is calculated.
If an entire band contains no finite values, PCA Compression stops and reports an error.
After PCA Compression, myData.Images contains the PCA score cube.
The third axis no longer represents physical wavelength. IDCubePro replaces the wavelength vector with component indices 1, 2, 3, and so forth and enables band/component index mode.
This distinction is important: PC1, PC2, and PC3 are mathematical components derived from all original wavelengths, not new wavelengths.
For this reason, the number shown after PCA should be interpreted as Retained PCA Components rather than spectral bands remaining.
After PCA is complete, IDCubePro opens a PCA Compression Results window.
- Original number of spectral bands
- Number of retained PCA components
- Number of dimensions removed
- Dimensionality compression ratio
For example, if a 510-band dataset is reduced to 18 principal components, the dimensionality compression ratio is approximately 28.3:1.
The number of retained components is the third dimension of the PCA score cube after compression.
IDCubePro stores PCA metadata in the PCACompression field of the current dataset.
The stored information includes:
- Target variance percentage
- Number of retained components
- Explained variance of retained components
- Cumulative explained variance
- PCA coefficient/loadings matrix
- Original band standard deviations
- Original wavelength vector when available
IDCubePro refreshes the Modern GUI after compression.
When three or more components are retained, separated component indices are assigned to the RGB display so that the compressed cube can be visualized immediately.
When fewer than three components are retained, the display switches to Single Band mode.
The completion results report the dimensionality compression ratio as:
Original number of bands / Number of retained principal components For example, reducing 200 spectral bands to 20 principal components corresponds to a 10:1 dimensionality compression ratio.
This ratio describes reduction of the spectral dimension. It is not necessarily identical to the final file-size compression ratio because file format, numeric precision, and metadata also affect storage size.
The PCA Compression Results window includes an Export Details button.
Export Details saves the PCA compression summary and retained-component variance information to a CSV file.
The exported summary includes:
- Target variance percentage
- Number of retained PCA components
- Number of dimensions removed
- Dimensionality compression ratio
The exported component table includes:
- Principal component number
- Explained variance percentage for each retained component
- Cumulative explained variance percentage
This CSV file is intended as a human-readable record of the PCA compression operation and can be opened in Excel, MATLAB, Prism, or other analysis software.
Pca Loadings And Model Parameters
The CSV export is intended for summary statistics and retained-component variance information.
The complete PCA model may contain larger arrays, including the coefficient/loadings matrix, means, standard deviations, and original wavelengths.
These model parameters remain stored in myData.PCACompression and are better preserved in MATLAB format when the full PCA model needs to be reused or inspected.
When Pca Compression Is Useful
PCA compression can be useful for:
- Reducing the number of variables before downstream analysis
- Removing low-variance components that may contain substantial noise
- Producing compact component representations for visualization
- Reducing memory requirements for later operations
- Exploring dominant spectral variation
Important Interpretation Note
PCA components maximize statistical variance; they do not automatically correspond to chemically, biologically, or physically meaningful spectral features.
A low-variance component can sometimes contain scientifically important information, while a high-variance component can be dominated by illumination, background, or other nuisance variation.
Choose the retained-variance threshold according to the scientific purpose of the analysis rather than assuming that one percentage is optimal for every dataset.
PCA results depend on the state of the dataset at the time PCA is applied.
Background correction, scatter correction, normalization, band removal, smoothing, and other preprocessing operations can change the PCA solution.
For comparisons across multiple datasets, use a consistent preprocessing workflow whenever possible.
The progress dialog can be canceled while PCA is running.
If cancellation occurs before the dataset update step, the current dataset remains unchanged.
PCA Compression changes only the current working dataset in IDCubePro.
Use Reset Preprocessing from the Preprocessing Center to restore myDataOriginal when the original dataset is available.
PCA Compression does not automatically write the compressed datacube to disk.
Use the IDCubePro Save / Export workflow when you want to save the PCA component cube itself.
Export Details is different: it saves the numerical compression summary and PCA variance statistics rather than the entire compressed image cube.
PCA is a linear transformation and may not capture nonlinear relationships in hyperspectral data.
The amount of variance explained is a statistical measure and is not by itself a measure of classification accuracy, biological relevance, chemical specificity, or image quality.
PCA is also sensitive to preprocessing choices and to strong outliers.
Strong compression may discard low-variance information that is scientifically important even when the retained components explain a high percentage of total variance.
); break; end catch end end if isempty(c) c = defaultValue; end end %% ========================================================= % ICON % ========================================================= function setHelpIcon(fig) try candidates = {}; rootFolder = ... getappdata(0, ); if ~isempty(rootFolder) candidates{end+1} = ... fullfile( ... rootFolder, ...
); end functionFolder = ... fileparts(mfilename( )); candidates{end+1} = ... fullfile( ... functionFolder, ...
); candidates{end+1} = ... fullfile( ... fileparts(functionFolder), ...
); candidates{end+1} = ... fullfile( ... fileparts(fileparts(functionFolder)), ...