Documentation  ›  Documentation Library  ›  Anomaly Detection & Removal
Advanced Toolboxes

Anomaly Detection & Removal

Anomaly Detection & Removal identifies pixels whose hyperspectral signatures are unusual relative to the global spectral distribution of the current datacube.

Overview

Anomaly Detection & Removal identifies pixels whose hyperspectral signatures are unusual relative to the global spectral distribution of the current datacube.

IDCubePro uses the global Reed-Xiaoli (RX) detector. Detection is performed in double precision and does not modify the loaded dataset.

After detection, anomalous pixels can optionally be corrected using valid non-anomalous neighboring pixels.

1. Load a hyperspectral datacube.

2. Select a Confidence value.

4. Inspect the RX score distribution, RX score map, anomaly mask, and RGB overlay.

5. If correction is required, enable Correct anomalies.

6. Select an odd correction Window size.

7. Choose whether to Apply to current dataset.

9. Export the anomaly mask or copy the summary if needed.

The RX detector measures how spectrally unusual each pixel is relative to the global distribution of all pixels in the cube.

For each pixel, the algorithm considers the distance of its spectral vector from the global mean while accounting for covariance between spectral bands.

Higher RX scores indicate pixels that are more statistically unusual relative to the global background distribution.

Confidence controls the percentile threshold used to convert RX scores into a binary anomaly mask.

For example, Confidence = 0.990 places the threshold near the 99th percentile of the RX-score distribution.

Pixels with RX scores above the calculated threshold are labeled anomalous.

A higher Confidence value is more selective and normally identifies fewer pixels. A lower Confidence value is less selective and normally identifies more pixels.

The exact anomaly percentage can differ slightly from 1 - Confidence because of tied values and the structure of the RX-score distribution.

Run RX Detection reshapes the hyperspectral cube into a spectral matrix, replaces non-finite values using finite band means, centers the spectra, estimates the global covariance matrix, and computes the RX score for every spatial pixel.

A small covariance regularization term is added to improve numerical stability when the covariance matrix is poorly conditioned or nearly singular.

The operation can be canceled from the progress window.

The upper-left graph shows the cumulative distribution of RX scores.

The vertical dashed line marks the anomaly threshold selected from the Confidence value.

Pixels to the high-score side of this threshold are classified as anomalies.

The upper-right image shows the spatial distribution of RX scores.

Brighter or higher-valued regions indicate pixels whose spectral signatures differ more strongly from the global spectral distribution.

The RX score itself is a statistical anomaly score and does not identify the physical or biological cause of the anomaly.

The lower-left panel displays the binary anomaly mask.

Pixels identified as anomalous are separated from pixels below the RX threshold.

The mask is also stored by IDCubePro for downstream use.

The lower-right panel displays an RGB preview with detected anomalous pixels overlaid in red.

The RGB preview is generated from representative bands across the cube and is intended as a spatial reference for the anomaly locations.

Enable Correct anomalies if detected anomalous pixels should be replaced.

Correction is optional. Running RX Detection alone never changes the current hyperspectral dataset.

Window specifies the local spatial neighborhood used for correction.

The value must be an odd positive integer such as 3, 5, or 7.

A 3 x 3 window uses a small local neighborhood. Larger windows use a broader spatial neighborhood and may produce stronger spatial smoothing.

Only valid, non-anomalous neighboring pixels are used when calculating replacement values.

Correction is performed independently for every spectral band.

For each anomalous spatial pixel, IDCubePro calculates the mean of valid non-anomalous neighboring pixels within the selected window and uses that value as the replacement.

If no valid local neighbor exists for a detected pixel in a particular band, the algorithm falls back to a finite global band mean.

When Apply to current dataset is selected, the corrected cube replaces appdata(0,'myData') as the active IDCube working dataset.

The operation is added to IDCube history when the history function is available, and the main display is refreshed.

When this option is not selected, the active dataset is left unchanged and the corrected result is stored separately as appdata(0,'myData_APcorrected').

When enabled, the lower-right panel shows the mean absolute difference between the corrected and original cubes after correction.

This image highlights where and how strongly the correction changed the data.

When disabled, the RGB anomaly overlay remains visible.

Apply Correction becomes available after RX detection when Correct anomalies is enabled.

Clicking the button performs correction using the current Window and Apply to current dataset settings.

The correction progress can be canceled before the dataset is updated.

Export Mask CSV saves the binary anomaly mask as a CSV matrix.

Values of 1 represent detected anomalous pixels and values of 0 represent pixels below the anomaly threshold.

Copy Summary places the RX analysis summary on the clipboard.

The copied information includes Confidence, RX threshold, number of anomalous pixels, anomaly percentage, and cube dimensions.

An RX anomaly is a pixel whose spectrum is statistically unusual relative to the global datacube distribution.

An anomaly is not automatically an artifact or bad pixel. It may represent a real rare material, tissue feature, edge, target, contamination, sensor artifact, illumination artifact, or another spectrally uncommon structure.

Therefore, detected anomalies should be inspected spatially and spectrally before correction is applied.

This implementation uses one global mean and covariance matrix for the entire image.

If the image contains several large and strongly different background populations, a global RX model may flag legitimate regions simply because they differ from the dominant global distribution.

For highly heterogeneous scenes, local or region-specific anomaly methods may sometimes be more appropriate.

There is no universal Confidence value that is optimal for every dataset.

0.990 is a useful starting point for exploratory analysis, but the appropriate threshold depends on image size, scene heterogeneity, sensor noise, preprocessing, and the scientific objective.

Inspect both the anomaly mask and the underlying spectra before treating detected pixels as errors.

Correction changes the measured datacube.

Only correct pixels when there is a scientific or technical reason to treat them as artifacts or invalid measurements.

If unusual pixels may contain meaningful rare spectral information, retain the original dataset and use detection without correction.

RX detection stores the analysis result in appdata(0,'IDCubeAnomalyResult').

The binary anomaly mask is also stored as appdata(0,'AP_bw'), and the RX score map is stored as appdata(0,'AP_rxScore').

If correction is performed without replacing the active dataset, the corrected cube is stored as appdata(0,'myData_APcorrected').

Close Anomaly Detection & Removal help.