Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Chapter 5: Feature Engineering and Statistical Anomaly Detection

Authors
Affiliations
University of Alberta
University of Alberta

1Overview

SHM depends on extracting meaningful information from raw sensor data to indicate the presence and extent of damage. Damage-sensitive features (DSFs) are quantitative metrics extracted from sensor measurements that change measurably when structural damage occurs. They transform large volumes of raw time series, frequency spectra, or images into a small set of interpretable numbers that guide engineering decisions.

A well-chosen DSF must be highly sensitive to structural damage while remaining insensitive to operational and environmental variations. The natural frequency of a structure is a classic example: it relates directly to structural stiffness through f=12πk/mf = \frac{1}{2\pi}\sqrt{k/m}, so a stiffness reduction kk from damage produces a measurable frequency decrease. However, the same frequency also varies with temperature, loading conditions, and boundary condition changes, so feature selection and interpretation require care.

Chapter 3 introduced time-domain analysis for computing statistical moments, correlation functions, and other temporal characteristics from vibration signals. Chapter 4 extended this to the frequency domain, showing how Fourier transforms, power spectral densities, and modal analysis reveal spectral signatures of structural behavior. These tools compute features; selecting which features to extract and understanding how they respond to damage is the core challenge addressed in this chapter.


2Time-Domain and Frequency-Domain Features

SHM features span multiple domains. Time-domain features capture the statistical properties of raw sensor signals, while frequency-domain features reveal the spectral characteristics and modal properties that often correlate with physical damage mechanisms.

Table 1:Time-Domain Features Summary

FeatureMathematical ExpressionPhysical InterpretationDamage Sensitivity
Meanμ=1N∑i=1Nxi\mu = \frac{1}{N}\sum_{i=1}^{N} x_iDC offset, static displacementLow (sensor drift indicator)
Root Mean SquarexRMS=1N∑i=1Nxi2x_{\text{RMS}} = \sqrt{\frac{1}{N}\sum_{i=1}^{N} x_i^2}Signal energy, vibration amplitudeModerate (increases with looseness)
Standard Deviationσ=1N∑i=1N(xi−μ)2\sigma = \sqrt{\frac{1}{N}\sum_{i=1}^{N} (x_i - \mu)^2}Signal variabilityModerate (reflects amplitude changes)
SkewnessS=E{(X−μ)3}σ3S = \frac{E\{(X-\mu)^3\}}{\sigma^3}Distribution asymmetryHigh for asymmetric damage
KurtosisK=E{(X−μ)4}σ4K = \frac{E\{(X-\mu)^4\}}{\sigma^4} (raw fourth standardized moment; K=3K=3 for a Gaussian, K>3K>3 for impulsive signals; note that scipy.stats.kurtosis with default fisher=True returns the excess form K−3K-3)Tail heaviness, impulsivenessHigh (detects impacts, cracks)
Crest FactorCF=max⁡∣x[n]∣xRMS\text{CF} = \frac{\max|x[n]|}{x_{\text{RMS}}}Peak-to-RMS ratioHigh for impulsive events
Zero Crossing RateZCR=1N−1∑n=0N−21[x[n]⋅x[n+1]<0]\text{ZCR} = \frac{1}{N-1}\sum_{n=0}^{N-2} \mathbb{1}[x[n] \cdot x[n+1] < 0]Dominant frequency indicatorLow to moderate

Table 2:Frequency-Domain Features Summary

FeatureMathematical ExpressionPhysical InterpretationDamage Sensitivity
Peak Frequenciesfi=arg⁡max⁡fSxx(f)f_i = \arg\max_f S_{xx}(f)Resonant frequencies reflecting stiffness/mass distributionHigh for global stiffness loss; moderate for local damage
Spectral MomentsMn=∫0∞fnSxx(f) dfM_n = \int_{0}^{\infty} f^n S_{xx}(f)\, dfSpectral centroid/spread; energy distribution across frequencyModerate (shifts with mass/stiffness changes)
Band Energy RatioEbandEtotal=∫f1f2Sxx(f) df∫0∞Sxx(f) df\dfrac{E_{\text{band}}}{E_{\text{total}}} = \dfrac{\int_{f_1}^{f_2} S_{xx}(f)\, df}{\int_{0}^{\infty} S_{xx}(f)\, df}Fraction of energy in a band; highlights sideband growth and shiftsModerate to high (band-specific signatures)
Spectral EntropyH=−∑ipilog⁡piH = -\sum_i p_i \log p_i
pi=Sxx(fi)∑jSxx(fj)p_i = \dfrac{S_{xx}(f_i)}{\sum_j S_{xx}(f_j)}
Spectral complexity/regularityModerate (increases with cracks, rubbing, looseness)
Natural Frequenciesfnrf_{nr} from peak picking in Sxx(f)S_{xx}(f)Global dynamic stiffnessHigh for global stiffness reduction; moderate for localized damage
Damping Ratiosζr=fb2−fb12fnr\zeta_r = \dfrac{f_{b2} - f_{b1}}{2 f_{nr}} (half-power bandwidth)Energy dissipation; friction/viscoelasticityHigh for contact/frictional/nonlinear damage
Mode Shapesϕr\phi_r from Frequency Domain Decomposition (FDD)Deformation patterns (nodes/antinodes)High near damage location (local stiffness changes)
MACMAC(ϕd,ϕu)=∣ϕdTϕu∣2(ϕdTϕd)(ϕuTϕu)\text{MAC}(\phi_d, \phi_u) = \dfrac{\lvert \phi_d^T \phi_u \rvert^2}{(\phi_d^T \phi_d)(\phi_u^T \phi_u)}Modal Assurance Criterion; correlation between damaged and undamaged mode shapesHigh (decreases from ~1.0 with mode shape changes)
COMACCOMAC(i)=(∑jϕd,ijϕu,ij)2∑j(ϕd,ij)2×∑j(ϕu,ij)2\text{COMAC}(i) = \dfrac{(\sum_{j} \phi_{d,ij} \phi_{u,ij})^2}{\sum_{j}(\phi_{d,ij})^2 \times \sum_{j}(\phi_{u,ij})^2}Coordinate MAC; local mode shape consistency across modesHigh (decreases from 1.0 near damage location)
Modal FRFH(ω)=(−ω2M+iωC+K)−1H(\omega) = (-\omega^2 M + i\omega C + K)^{-1}Input–output dynamic complianceHigh across resonance and anti-resonance regions

These features form the foundation of damage detection algorithms, but their effectiveness depends on understanding their statistical behavior in both healthy and damaged states. The transformation from raw measurements to features achieves significant data reduction (from thousands of time samples or frequency bins to a dozen key metrics) while preserving the information relevant to structural condition.


3Anomaly Detection Framework for Structural Health Monitoring

Feature extraction transforms raw sensor data into interpretable quantities, but the key question remains: when does a feature value indicate damage rather than normal variability? This section establishes the framework for anomaly detection in SHM, introducing baselines, damage scores, and threshold-based decision making.

3.1Defining Anomalies in SHM Context

An anomaly in SHM is any observation that deviates significantly from the expected behavior of the healthy structure. Unlike general anomaly detection, where unusual patterns may reflect various outlier types, SHM anomaly detection targets changes that correlate with physical damage mechanisms: cracks, stiffness degradation, connection loosening, or material deterioration.

The main challenge is distinguishing damage-induced changes from natural variability caused by environmental and operational conditions. A bridge’s natural frequencies fluctuate daily with temperature, traffic loading, and humidity. Mode shapes shift with boundary condition changes, and time-domain features vary with ambient vibration levels. Effective anomaly detection must account for this normal variability while remaining sensitive to damage.

3.2Damage Scores and Baselines

The damage score (also called damage index or health index) quantifies how far a current observation deviates from the healthy baseline. For a single feature xx, the damage score might be as simple as:

Damage Score=∣x−μbaseline∣σbaseline\text{Damage Score} = \frac{|x - \mu_{\text{baseline}}|}{\sigma_{\text{baseline}}}

where μbaseline\mu_{\text{baseline}} and σbaseline\sigma_{\text{baseline}} are the mean and standard deviation from a baseline period when the structure is known to be healthy. This normalization yields a dimensionless score: values near zero indicate normal behavior, while large positive values suggest potential damage.

The baseline establishment process requires careful consideration:

  1. Duration: Collect sufficient data to capture normal variability (typically weeks to months)

  2. Conditions: Include diverse environmental and operational states

  3. Verification: Confirm structural health through inspection or other means

  4. Update strategy: Decide whether baselines remain static or adapt over time

For a newly constructed bridge, the baseline period might span the first year of operation to capture seasonal variations. For an existing structure, using the current state as a baseline requires validation that no significant damage is present.

3.3Monitoring Over Time and Threshold Setting

Continuous monitoring turns the damage score into a time series that tracks structural condition. Figure 1 illustrates this workflow: baseline measurements establish the normal range, threshold lines mark the boundary between normal and anomalous behavior, and post-event measurements reveal whether damage has occurred.

Statistical anomaly-detection workflow for structural health monitoring: a baseline period computes \mu_0 and \sigma_0 to set the threshold \tau = \mu_0 \pm 3\sigma_0; during monitoring each observation is checked against |x - \mu_0| > 3\sigma_0; outcomes branch to normal (continue monitoring) or anomaly (inspect structure).

Figure 1:Statistical anomaly-detection workflow for structural health monitoring: a baseline period computes μ0\mu_0 and σ0\sigma_0 to set the threshold τ=μ0±3σ0\tau = \mu_0 \pm 3\sigma_0; during monitoring each observation is checked against ∣x−μ0∣>3σ0|x - \mu_0| > 3\sigma_0; outcomes branch to normal (continue monitoring) or anomaly (inspect structure).

The detection threshold balances two competing risks:

Common threshold choices include:

The appropriate threshold depends on the consequences of each error type. For life-safety critical structures like bridges, lower thresholds (higher sensitivity) minimize missed detections at the cost of more false alarms.

3.4From Single Values to Distributions

Monitoring individual measurements provides real-time damage alerts, but comparing entire distributions of features gives deeper insight. Instead of asking “Is this frequency measurement anomalous?”, we can ask “Has the distribution of frequency measurements shifted between baseline and current periods?”

Distribution-level comparison is particularly useful when multiple measurements are available from the same structural state, when gradual damage produces subtle shifts in mean or variance, or when the goal is to quantify the magnitude of change rather than just detect it.

The remainder of this chapter develops three complementary approaches:

  1. Z-score method: Point-wise comparison for individual measurements

  2. Mahalanobis distance: Multivariate extension accounting for feature correlations

  3. Wasserstein distance: Distribution-to-distribution comparison quantifying overall shift

These methods all require understanding the statistical distributions underlying the features, beginning with the Gaussian distribution.


4Statistical Distribution Fundamentals: The Gaussian Distribution

Statistical distributions underpin quantitative anomaly detection. The Gaussian (normal) distribution is central to SHM because of the Central Limit Theorem: when a feature results from many independent random effects (sensor noise, ambient vibrations, environmental fluctuations), its distribution tends toward Gaussian regardless of the individual effect distributions.

4.1The Gaussian Distribution: Intuition and Properties

The Gaussian distribution is characterized by its familiar bell-shaped curve, described mathematically by two parameters:

p(x)=1σ2πexp⁡(−(x−μ)22σ2)p(x) = \frac{1}{\sigma\sqrt{2\pi}} \exp\left(-\frac{(x-\mu)^2}{2\sigma^2}\right)

where μ\mu is the mean and σ\sigma is the standard deviation. For a bridge’s natural frequency, μ\mu is the typical value under normal conditions and σ\sigma quantifies variation from environmental effects and measurement uncertainty.

The Gaussian distribution has several properties that make it suitable for damage detection:

  1. Symmetry: Equal probability of deviations above and below the mean

  2. Concentration: Most values cluster near the mean; extreme values are rare

  3. Parameterization: Completely specified by just two numbers (μ,σ\mu, \sigma)

  4. Additivity: Sum of independent Gaussians is also Gaussian

4.2Confidence Intervals and the 68-95-99.7 Rule

The standard deviation σ\sigma provides a natural scale for measuring distances from the mean. For Gaussian distributions, fixed percentages of data fall within specific ranges:

This 68-95-99.7 rule (the empirical rule) provides the basis for threshold setting in damage detection. A frequency value more than 3σ from the baseline mean has only a 0.3% probability of arising from normal variability, making it strong evidence for damage.

4.3Visualizing Gaussian Behavior with Bridge Frequency Data

Consider a two-span highway bridge (30 m + 30 m continuous spans) with a first natural frequency of approximately 3.5 Hz. Over 150 baseline measurements, variations arise from temperature, traffic, and measurement noise. Figure 2 shows the Gaussian fit to this data and the resulting confidence intervals.

Key Python Implementation for Gaussian Statistics:

1
2
3
4
5
6
7
8
9
10
11
12
13
import numpy as np
from scipy import stats

# Compute sample statistics
mean = np.mean(data)
std = np.std(data, ddof=1)  # ddof=1 for sample std

# Create Gaussian PDF  
x_range = np.linspace(mean - 4*std, mean + 4*std, 300)
pdf = stats.norm.pdf(x_range, mean, std)

# Check normality with Q-Q plot
stats.probplot(data, dist="norm", plot=ax)

The emphasized lines show the key operations: computing statistics with numpy and generating probability distributions with scipy.stats. The ddof=1 parameter gives the sample standard deviation (dividing by n-1 instead of n).

<Figure size 1050x750 with 4 Axes>

Figure 2:Gaussian distribution fitted to 150 first natural frequency measurements from a two-span bridge showing 68%, 95%, and 99.7% confidence intervals.

Figure 2 shows the statistical characterization of baseline monitoring data. The histogram (top-left) displays 150 frequency measurements overlaid with the fitted Gaussian PDF (μ=3.50 Hz, σ=0.12 Hz). The shaded confidence intervals (top-right) illustrate the 68-95-99.7 rule: approximately 68% of measurements fall within μ±σ, 95% within μ±2σ, and 99.7% within μ±3σ. Any new measurement beyond 3σ from the baseline mean would occur less than 0.3% of the time under normal conditions, providing strong evidence of structural change.

The CDF (bottom-left) compares empirical data against the theoretical Gaussian, while the Q-Q plot (bottom-right) shows excellent agreement (R²≈1.0), confirming that frequency measurements under normal conditions follow Gaussian statistics. This validates the use of parametric statistical methods throughout the chapter.

4.4Establishing the Baseline Distribution

Given NN baseline measurements {x1,x2,…,xN}\{x_1, x_2, \ldots, x_N\} of a feature, the baseline establishment process is as follows:

  1. Compute sample mean:

μ^=1N∑i=1Nxi\hat{\mu} = \frac{1}{N}\sum_{i=1}^{N} x_i
  1. Compute sample standard deviation:

σ^=1N−1∑i=1N(xi−μ^)2\hat{\sigma} = \sqrt{\frac{1}{N-1}\sum_{i=1}^{N} (x_i - \hat{\mu})^2}

The N−1N-1 denominator (Bessel’s correction) gives an unbiased estimate when the true mean is unknown.

  1. Verify Gaussian assumption: Use Q-Q plots, Shapiro-Wilk test, or Anderson-Darling test

  2. Set detection threshold: Typically μ^±3σ^\hat{\mu} \pm 3\hat{\sigma} for two-sided detection

These baseline parameters (μ^\hat{\mu}, σ^\hat{\sigma}) enable quantitative damage detection through the methods developed in subsequent sections.


5Single Feature Analysis: 1D Statistical Methods

This section develops two methods for damage detection using a single feature: the z-score method for point-wise comparisons and the Wasserstein distance for distribution-level comparisons. Both are illustrated using the first natural frequency of the two-span bridge (30 m + 30 m), a feature that reflects global structural stiffness.

5.1Method 1: Z-Score for Point-Wise Anomaly Detection

The z-score (also called standard score) measures how many standard deviations an individual observation lies from the baseline mean:

z=x−μ0σ0z = \frac{x - \mu_0}{\sigma_0}

where xx is the new measurement and μ0\mu_0, σ0\sigma_0 are the baseline mean and standard deviation from (3) and (4). The z-score has several useful properties:

For damage detection, a two-sided test with threshold ∣z∣>3|z| > 3 is standard, though one-sided tests are appropriate when damage affects features in a known direction (e.g., frequency decreases with stiffness loss).

Example: If baseline frequency measurements yield μ0=3.50\mu_0 = 3.50 Hz and σ0=0.12\sigma_0 = 0.12 Hz, and a new measurement gives x=3.26x = 3.26 Hz, then:

z=3.26−3.500.12=−2.0z = \frac{3.26 - 3.50}{0.12} = -2.0

This z-score of -2.0 falls within the normal range (∣z∣<3|z| < 3), suggesting no damage despite the 0.24 Hz difference. The 0.24 Hz gap corresponds to only two standard deviations of normal variability.

5.2Method 2: Wasserstein Distance for Distribution Comparison

While z-scores assess individual points, the Wasserstein distance (also called Earth Mover’s Distance) compares entire distributions. It measures the minimum work required to transform one probability distribution into another, where work equals probability mass moved times distance moved.

Conceptual illustration of the 1-Wasserstein distance as “Earth Mover’s Distance”. The baseline distribution P and damaged distribution Q are visualized as histograms of probability mass; the orange arcs represent transport plans. The Wasserstein distance W_1(P, Q) quantifies the minimum total work (amount × distance) needed to reshape P into Q, providing a geometric interpretation that compares entire distributions rather than individual points.

Figure 3:Conceptual illustration of the 1-Wasserstein distance as “Earth Mover’s Distance”. The baseline distribution PP and damaged distribution QQ are visualized as histograms of probability mass; the orange arcs represent transport plans. The Wasserstein distance W1(P,Q)W_1(P, Q) quantifies the minimum total work (amount × distance) needed to reshape PP into QQ, providing a geometric interpretation that compares entire distributions rather than individual points.

For two univariate distributions PP and QQ with CDFs FPF_P and FQF_Q, the 1-Wasserstein distance is:

W1(P,Q)=∫−∞∞∣FP(x)−FQ(x)∣ dxW_1(P, Q) = \int_{-\infty}^{\infty} |F_P(x) - F_Q(x)| \, dx

For empirical distributions with finite samples of equal size, this reduces to comparing sorted values. If {x1,…,xn}\{x_1, \ldots, x_n\} and {y1,…,yn}\{y_1, \ldots, y_n\} are equal-size samples from PP and QQ:

W1(P,Q)≈1n∑i=1n∣x(i)−y(i)∣W_1(P, Q) \approx \frac{1}{n} \sum_{i=1}^{n} |x_{(i)} - y_{(i)}|

where (i)(i) denotes the ii-th sorted value. For samples of unequal size (as in the worked example, where baseline and damage sets have different nn), the sorted-pair shortcut does not apply directly; one must evaluate the CDF-integration form of (7) using the empirical CDFs, which is exactly what scipy.stats.wasserstein_distance computes internally.

Interpretation:

The Wasserstein distance has several advantages over simpler metrics like comparing means:

  1. Robust to outliers: Uses all data, not just summary statistics

  2. Captures shape changes: Detects shifts in variance, skewness, or modality

  3. Metric properties: Satisfies the triangle inequality

5.3Detailed Bridge Monitoring Example

Consider monitoring the first natural frequency over 150 baseline measurements, then observing 25 measurements after a potentially damaging event. Figure 4 demonstrates both z-score and Wasserstein approaches.

Key Python Implementation for Z-Score and Wasserstein Distance:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
from scipy.stats import wasserstein_distance

# Z-score for point-wise anomaly detection
mu_baseline = np.mean(baseline_data)
sigma_baseline = np.std(baseline_data, ddof=1)
z_scores = (new_measurements - mu_baseline) / sigma_baseline

# Wasserstein distance for distribution comparison
w_distance = wasserstein_distance(baseline_data, damaged_data)
w_normalized = w_distance / sigma_baseline  # Normalize

# Decision rules
anomalies_z = np.abs(z_scores) > 3  # 99.7% confidence
damage_detected = w_normalized > 1.0  # > 1 sigma shift

The emphasized lines show the two core computations: z-score normalizes individual points relative to baseline statistics; Wasserstein distance quantifies the overall shift between distributions.

<Figure size 1050x825 with 4 Axes>
======================================================================
DAMAGE DETECTION SUMMARY: 1D Analysis
======================================================================

Baseline vs Post-Event Statistics:
Loading...

Detection Method Comparison:
Loading...

⚠️  FINAL VERDICT: DAMAGE DETECTED

Figure 4:Z-score and Wasserstein distance methods for 1D anomaly detection applied to bridge first natural frequency monitoring.

Figure 4 compares the two detection methods on bridge frequency monitoring. The time series (top) shows 150 baseline measurements followed by 25 post-event measurements, with the ±3σ envelope. For this moderate 5.7% frequency drop, no single post-event point crosses the |z| > 3 threshold, yet the z-score distribution (middle-left) is clearly shifted left of the expected N(0,1), with a mean z-score near -1.3.

The PDF comparison (middle-right) shows the distributional shift between baseline and damaged states, while the CDF plot (bottom) visualizes the Wasserstein distance as the area between curves. The Wasserstein distance (W₁ = 0.16 Hz, about 1.3σ) captures this overall shift even when point-wise z-scores raise no alert, which illustrates why distribution-level comparison can detect moderate damage that threshold tests miss.

5.4Choosing Between Z-Score and Wasserstein Distance

The two methods serve complementary roles in structural health monitoring:

Use z-score when:

Use Wasserstein distance when:

In practice, both methods complement each other: z-scores support continuous monitoring with immediate alerts, and Wasserstein distance supports periodic assessment of overall condition. Agreement between both methods strengthens confidence in a damage diagnosis.


6Bivariate Analysis: Two Natural Frequencies

Monitoring multiple features simultaneously improves detection performance. This section extends the univariate methods to bivariate analysis, monitoring the first two natural frequencies jointly. Joint monitoring captures the correlation between frequencies and provides richer information about structural condition than either frequency alone.

6.1The Bivariate Gaussian Distribution

Two correlated features follow a bivariate Gaussian distribution. The probability density function for x=[x1,x2]T\mathbf{x} = [x_1, x_2]^T is:

p(x)=12π∣Σ∣exp⁡(−12(x−μ)TΣ−1(x−μ))p(\mathbf{x}) = \frac{1}{2\pi\sqrt{|\boldsymbol{\Sigma}|}} \exp\left(-\frac{1}{2}(\mathbf{x} - \boldsymbol{\mu})^T \boldsymbol{\Sigma}^{-1} (\mathbf{x} - \boldsymbol{\mu})\right)

where μ=[μ1,μ2]T\boldsymbol{\mu} = [\mu_1, \mu_2]^T is the mean vector and Σ\boldsymbol{\Sigma} is the 2×22 \times 2 covariance matrix:

Σ=[σ12ρσ1σ2ρσ1σ2σ22]\boldsymbol{\Sigma} = \begin{bmatrix} \sigma_1^2 & \rho\sigma_1\sigma_2 \\ \rho\sigma_1\sigma_2 & \sigma_2^2 \end{bmatrix}

Here, σ1\sigma_1 and σ2\sigma_2 are the standard deviations of the two features, and ρ\rho is the correlation coefficient, ranging from -1 (perfect negative correlation) to +1 (perfect positive correlation).

For this bridge, both natural frequencies are expected to be positively correlated: environmental effects (temperature, moisture) that increase stiffness raise both frequencies, while damage that reduces stiffness lowers both.

6.2Visualizing the Bivariate Gaussian: Covariance Ellipse

The bivariate Gaussian produces elliptical contours in 2D feature space. The ellipse orientation and shape encode the correlation structure; its center is the mean. Figure 5 shows this for the two-span bridge.

<Figure size 1050x480 with 2 Axes>

Figure 5:Bivariate Gaussian distribution for two natural frequencies showing scatter plot with 95% confidence ellipse and 3D probability density surface.

Figure 5 shows the structure of correlated features. When the first frequency rises (for example, from temperature-induced stiffening), the second tends to rise as well, producing the elongated elliptical scatter. The correlation coefficient ρ=0.65\rho = 0.65 quantifies this tendency. The 3D surface shows probability density concentrated near the mean, with the ridge aligned along the correlation direction.

6.3Applying the Three Methods to Bivariate Data

The three detection methods (z-score, Mahalanobis distance, and Wasserstein distance) extend from 1D to 2D, and this extension shows the benefit of accounting for feature correlations.

The straightforward extension of z-scores treats each feature independently, computing:

z1=x1−μ01σ01,z2=x2−μ02σ02z_1 = \frac{x_1 - \mu_{01}}{\sigma_{01}}, \quad z_2 = \frac{x_2 - \mu_{02}}{\sigma_{02}}

A point is flagged as anomalous if ∣z1∣>3|z_1| > 3 or ∣z2∣>3|z_2| > 3. This approach ignores correlations and may miss damage that shifts both frequencies in a correlated direction while each remains within its individual threshold.

6.3.1Method 2: Mahalanobis Distance (Correlation-Aware)

The Mahalanobis distance extends z-scores to account for correlations, yielding a single distance measure in multivariate space:

DM(x)=(x−μ0)TΣ0−1(x−μ0)D_M(\mathbf{x}) = \sqrt{(\mathbf{x} - \boldsymbol{\mu}_0)^T \boldsymbol{\Sigma}_0^{-1} (\mathbf{x} - \boldsymbol{\mu}_0)}

where x=[x1,x2]T\mathbf{x} = [x_1, x_2]^T is the measurement vector, μ0\boldsymbol{\mu}_0 is the baseline mean vector, and Σ0−1\boldsymbol{\Sigma}_0^{-1} is the inverse covariance matrix.

Comparison of Euclidean and Mahalanobis distance metrics for correlated features. The Euclidean metric D_E = \sqrt{(x_1 - \mu_1)^2 + (x_2 - \mu_2)^2} uses concentric circles and treats all directions equally; the Mahalanobis metric D_M = \sqrt{(\mathbf{x} - \boldsymbol{\mu})^\top \boldsymbol{\Sigma}^{-1} (\mathbf{x} - \boldsymbol{\mu})} uses tilted ellipses aligned with the data covariance, so a point perpendicular to the correlation axis is correctly flagged as more anomalous.

Figure 6:Comparison of Euclidean and Mahalanobis distance metrics for correlated features. The Euclidean metric DE=(x1−μ1)2+(x2−μ2)2D_E = \sqrt{(x_1 - \mu_1)^2 + (x_2 - \mu_2)^2} uses concentric circles and treats all directions equally; the Mahalanobis metric DM=(x−μ)⊤Σ−1(x−μ)D_M = \sqrt{(\mathbf{x} - \boldsymbol{\mu})^\top \boldsymbol{\Sigma}^{-1} (\mathbf{x} - \boldsymbol{\mu})} uses tilted ellipses aligned with the data covariance, so a point perpendicular to the correlation axis is correctly flagged as more anomalous.

The Mahalanobis distance has three key properties:

  1. Dimensionless: Combines features with different units coherently

  2. Correlation-aware: Accounts for the joint variability of features

  3. Chi-squared distributed: Under Gaussian assumptions, DM2∼χ2(p)D_M^2 \sim \chi^2(p) where pp is the number of features

For bivariate data (p=2p=2), the 95% confidence threshold is DM=χ0.952(2)≈2.45D_M = \sqrt{\chi^2_{0.95}(2)} \approx 2.45.

6.3.2Method 3: Wasserstein Distance (Distribution Comparison)

Comparing entire distributions in 2D using the Wasserstein distance becomes computationally costly as dimensionality increases. A practical approach computes the 1D Wasserstein distance for each feature separately and aggregates:

Wagg=W1(f1base,f1test)2+W1(f2base,f2test)2W_{agg} = \sqrt{W_1(f_1^{base}, f_1^{test})^2 + W_1(f_2^{base}, f_2^{test})^2}

For small sample sizes, the 2-Wasserstein distance can be computed directly on the joint distribution, though this requires more specialized algorithms.

6.4Detailed Bivariate Example: Bridge Frequency Monitoring

Consider the two-span bridge with baseline monitoring of both f1f_1 and f2f_2, followed by post-event measurements. Figure 7 shows all three methods detecting a 6% reduction in both frequencies from distributed damage.

Key Python Implementation for Mahalanobis Distance:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
from scipy import stats

# Compute baseline covariance and inverse
mu_baseline = np.mean(baseline_data, axis=0)  # Mean vector
cov_baseline = np.cov(baseline_data.T)  # Covariance matrix
inv_cov = np.linalg.inv(cov_baseline)  # Inverse

# Calculate Mahalanobis distance for new measurement
for x in new_measurements:
    diff = x - mu_baseline
    D_M = np.sqrt(diff @ inv_cov @ diff.T)  # Matrix multiplication
    
# Threshold from chi-square distribution (95% for 2D)
threshold = np.sqrt(stats.chi2.ppf(0.95, df=2))  # ≈ 2.45

The emphasized lines show covariance matrix computation and the Mahalanobis distance formula. The @ operator performs matrix multiplication, which accounts for feature correlations.

<Figure size 1050x750 with 4 Axes>
======================================================================
BIVARIATE DAMAGE DETECTION: Bridge (30m+30m), Features: f₁, f₂
======================================================================

Baseline vs Damaged Statistics:
Loading...

Method Comparison:
Loading...

⚠️  VERDICT: DAMAGE DETECTED by all methods
    Mahalanobis provides best detection (50%) by exploiting correlation

Figure 7:Three statistical methods (z-score, Mahalanobis, Wasserstein) applied to bivariate frequency monitoring detecting correlated frequency reductions.

Figure 7 compares three detection methods applied to bivariate frequency monitoring of the bridge under correlated reductions (~6%) in both natural frequencies. The feature space (top-left) shows the key difference: component-wise z-scores define a rectangular ±3σ boundary, while Mahalanobis distance defines an elliptical boundary aligned with the correlation structure. Some damaged measurements (red triangles) fall inside the rectangular boundary but outside the Mahalanobis ellipse, which explains why correlation-aware detection outperforms the independent z-score approach.

6.5Python Implementation: Mahalanobis Distance for Bivariate Data

The following code implements Mahalanobis distance for monitoring two correlated frequencies, with key lines highlighted:

1
2
3
4
5
6
7
8
9
10
# Compute baseline statistics
mu_baseline = np.mean(baseline_data, axis=0)  # Mean vector [μ₁, μ₂]
cov_baseline = np.cov(baseline_data.T)  # 2x2 covariance matrix

# Compute Mahalanobis distance for each new measurement
inv_cov = np.linalg.inv(cov_baseline)  # Inverse covariance matrix

diff = new_data_point - mu_baseline
# D_M = sqrt((x - μ)ᵀ Σ⁻¹ (x - μ))
mahalanobis_distance = np.sqrt(diff @ inv_cov @ diff.T)

The emphasized lines show the core operations: computing the mean and covariance from baseline data (lines 10-11), inverting the covariance matrix (line 16-17), and calculating the Mahalanobis distance using matrix multiplication (lines 21-24) which accounts for both feature variances and their correlation.

Source
Baseline: μ = [3.500, 9.002] Hz
Correlation: ρ = 0.996
Detection threshold: D_M > 2.45

Loading...

Figure 8:Python implementation of Mahalanobis distance for bivariate anomaly detection with correlated bridge frequencies.

The emphasized lines show the key steps: computing the covariance matrix, inverting it, and calculating the Mahalanobis distance using matrix multiplication. This accounts for both the scale and correlation of the features.


7Mode Shape Features: MAC and COMAC as Statistical Indicators

Mode shapes provide spatial information about structural dynamics that goes beyond natural frequencies. Rather than analyzing mode shape vectors directly (which are high-dimensional), scalar features that quantify similarity relative to a reference configuration are more practical. The Modal Assurance Criterion (MAC) and Coordinate Modal Assurance Criterion (COMAC) transform spatial mode shape data into interpretable, damage-sensitive scalars.

7.1MAC and COMAC: From Spatial Patterns to Scalar Features

Recall from the frequency-domain features table that:

MAC (Modal Assurance Criterion): Measures correlation between two mode shapes:

MAC(ϕi,ϕj)=∣ϕiTϕj∣2(ϕiTϕi)(ϕjTϕj)MAC(\boldsymbol{\phi}_i, \boldsymbol{\phi}_j) = \frac{|\boldsymbol{\phi}_i^T \boldsymbol{\phi}_j|^2}{(\boldsymbol{\phi}_i^T \boldsymbol{\phi}_i)(\boldsymbol{\phi}_j^T \boldsymbol{\phi}_j)}

where ϕi\boldsymbol{\phi}_i and ϕj\boldsymbol{\phi}_j are mode shape vectors. MAC ranges from 0 (orthogonal modes) to 1 (identical modes).

COMAC (Coordinate Modal Assurance Criterion): Assesses spatial consistency at each measurement location:

COMACk=∣∑i=1Nmϕkirefϕkitest∣2(∑i=1Nm(ϕkiref)2)(∑i=1Nm(ϕkitest)2)COMAC_k = \frac{\left|\sum_{i=1}^{N_m} \phi_{ki}^{ref} \phi_{ki}^{test}\right|^2}{\left(\sum_{i=1}^{N_m} (\phi_{ki}^{ref})^2\right)\left(\sum_{i=1}^{N_m} (\phi_{ki}^{test})^2\right)}

where kk indexes spatial locations and ii indexes modes.

7.2Statistical Approach: Distributions vs Thresholds

Traditional deterministic approaches apply fixed thresholds (e.g., “MAC < 0.9 indicates damage”). A statistical approach recognizes that mode shapes vary due to environmental effects (temperature, humidity), measurement noise, identification algorithm uncertainty, and traffic loading. Instead of rigid thresholds, baseline distributions of MAC/COMAC values are established from multiple intact-state measurements. Post-event values that fall outside these distributions are flagged as anomalies, providing probabilistic damage assessments that account for measurement uncertainty.

7.3Example: MAC Values as Features

For the two-span bridge (30 m + 30 m), the following example generates mode shapes, computes MAC values relative to a reference configuration, and applies the three statistical methods (z-score, Mahalanobis, Wasserstein) to detect damage-induced mode shape changes.

Source
<Figure size 1050x1200 with 7 Axes>
================================================================================
MAC-BASED DAMAGE DETECTION: Bridge (30m+30m), 3 Mode Shapes
================================================================================

MAC Statistics by Mode:
Loading...

Detection Method Comparison:
Loading...

Figure 9:Statistical analysis of MAC features for damage detection applied to three mode shapes of a two-span bridge.

Figure 9 shows statistical damage detection using MAC values as features. The mode shape comparison (top) displays reference and damaged configurations for three modes; damage at the first span midpoint produces subtle distortions. The MAC distributions (second row, left) show that damage reduces MAC values, but with overlap between baseline and damaged distributions, confirming the need for statistical rather than threshold-based assessment.

The z-score analysis (second row, right) evaluates each mode independently and flags anomalies when |z| > 3. Mode 1 shows the clearest separation because it is most sensitive to the damage location. The Mahalanobis distance (third row, left) combines all three MAC values into a single multivariate metric, accounting for correlations between modes. This improves detection because modes do not vary independently: all reflect the same underlying stiffness reduction.

The Wasserstein distances (third row, right) quantify distribution-level shifts per mode, with normalized values giving interpretable effect sizes. The feature space (bottom) plots MAC values for Modes 1 vs 2, showing that while individual MAC values may appear normal, their joint distribution clearly separates baseline from damaged states.


8Feature Fusion and Multivariate Analysis

Practical SHM systems typically track many features simultaneously: multiple natural frequencies, damping ratios, mode shape amplitudes, time-domain statistics (RMS, kurtosis), and modal correlation values (MAC, COMAC). Feature fusion combines these sources into a robust damage indicator.

The challenge is managing high-dimensional feature spaces where visualization is impractical and computational costs rise. This section presents strategies for combining many features while preserving interpretability and computational efficiency. The focus is on correlations between features (distinct from sensor correlations covered in Chapter 3), which reveal redundancies and guide dimensionality reduction.

8.1Understanding Feature Correlation vs Sensor Correlation

Chapter 3 examined sensor correlations: statistical relationships between measurements at different spatial locations. Two accelerometers on adjacent bridge deck points produce correlated signals because they respond to the same global structural motion. These spatial correlations inform data quality assessment, sensor placement, and detection of localized anomalies.

This section focuses on feature correlations: statistical relationships between different types of features extracted from the same measurement data. The first natural frequency f1f_1 and RMS acceleration often correlate because both depend on the overall energy in the structural response. Natural frequencies f1f_1 and f2f_2 also tend to correlate because they share common dependencies on mass and stiffness.

Understanding feature correlation matters for three reasons:

  1. Redundancy identification: Highly correlated features carry similar information, so dimensionality can be reduced without losing damage sensitivity.

  2. Multivariate distance metrics: Correlation-aware metrics like Mahalanobis distance account for feature covariance, improving detection over Euclidean distance.

  3. Feature selection: Identifying which features carry unique information guides sensor design and resource allocation.

8.2Computing the Feature Correlation Matrix

Consider a monitoring campaign with mm measurements, each yielding nn extracted features. This produces a feature matrix X∈Rm×n\mathbf{X} \in \mathbb{R}^{m \times n}:

X=[x1,1x1,2⋯x1,nx2,1x2,2⋯x2,n⋮⋮⋱⋮xm,1xm,2⋯xm,n]\mathbf{X} = \begin{bmatrix} x_{1,1} & x_{1,2} & \cdots & x_{1,n} \\ x_{2,1} & x_{2,2} & \cdots & x_{2,n} \\ \vdots & \vdots & \ddots & \vdots \\ x_{m,1} & x_{m,2} & \cdots & x_{m,n} \end{bmatrix}

Each row is one measurement occasion and each column is one feature type. For this bridge example, columns correspond to [f1,f2,ζ1,ζ2,RMS,Kurtosis,MAC1,MAC2,EHF][f_1, f_2, \zeta_1, \zeta_2, \text{RMS}, \text{Kurtosis}, \text{MAC}_1, \text{MAC}_2, E_{\text{HF}}].

The feature correlation matrix R∈Rn×n\mathbf{R} \in \mathbb{R}^{n \times n} quantifies the linear relationship between each feature pair:

R=[1ρ1,2⋯ρ1,nρ2,11⋯ρ2,n⋮⋮⋱⋮ρn,1ρn,2⋯1]\mathbf{R} = \begin{bmatrix} 1 & \rho_{1,2} & \cdots & \rho_{1,n} \\ \rho_{2,1} & 1 & \cdots & \rho_{2,n} \\ \vdots & \vdots & \ddots & \vdots \\ \rho_{n,1} & \rho_{n,2} & \cdots & 1 \end{bmatrix}

where ρi,j\rho_{i,j} is the Pearson correlation coefficient between features ii and jj:

ρi,j=Cov(xi,xj)σxiσxj=∑k=1m(xk,i−xˉi)(xk,j−xˉj)∑k=1m(xk,i−xˉi)2∑k=1m(xk,j−xˉj)2\rho_{i,j} = \frac{\text{Cov}(x_i, x_j)}{\sigma_{x_i} \sigma_{x_j}} = \frac{\sum_{k=1}^{m} (x_{k,i} - \bar{x}_i)(x_{k,j} - \bar{x}_j)}{\sqrt{\sum_{k=1}^{m} (x_{k,i} - \bar{x}_i)^2} \sqrt{\sum_{k=1}^{m} (x_{k,j} - \bar{x}_j)^2}}

Here, xˉi=1m∑k=1mxk,i\bar{x}_i = \frac{1}{m}\sum_{k=1}^{m} x_{k,i} is the mean of feature ii. The correlation coefficient ranges from -1 to +1:

The matrix is symmetric (ρi,j=ρj,i\rho_{i,j} = \rho_{j,i}) with ones on the diagonal, so only n(n−1)/2n(n-1)/2 unique off-diagonal elements need to be computed.

8.3Practical Implementation in Python

The feature correlation matrix can be computed in Python using NumPy:

1
2
3
4
5
6
7
8
9
10
# Assume X is the feature matrix (m measurements × n features)
import numpy as np

# Compute correlation matrix between features (not sensors!)
corr_matrix = np.corrcoef(X.T)  # Transpose to correlate features, not measurements

# Or using Pandas for labeled output
import pandas as pd
df_features = pd.DataFrame(X, columns=feature_names)
corr_matrix = df_features.corr()  # Returns labeled correlation matrix

Transposing the feature matrix (X.T) directs np.corrcoef to correlate features (columns) rather than measurements (rows). The following example demonstrates a complete workflow for a multi-feature bridge monitoring system.

Source
<Figure size 1050x975 with 5 Axes>

Figure 10:Multi-feature fusion analysis for a two-span bridge monitoring system with 9 features, emphasizing feature correlation matrix computation, damage sensitivity, and statistical distance metrics comparison.


9Dimensionality Reduction

When SHM systems generate dozens or hundreds of features from multiple sensors and analysis domains, the resulting high-dimensional feature space creates challenges. Features may be redundant, have different scales, or exhibit complex dependencies that obscure damage signatures. Principal Component Analysis (PCA) transforms these high-dimensional observations into lower-dimensional representations that preserve the information needed for damage detection.

9.1Understanding Feature Correlations: Dependent vs Independent Features

Before introducing PCA, consider why feature correlations matter. Figure 11 contrasts correlated (dependent) features with uncorrelated (independent) features using bridge monitoring examples.

<Figure size 1050x825 with 4 Axes>

======================================================================
FEATURE CORRELATION COMPARISON
======================================================================
Loading...

Figure 11:Comparison of correlated vs uncorrelated features showing how correlation manifests in scatter plots, correlation matrices, and bivariate Gaussian PDFs.

9.2Principal Component Analysis: Mathematical Foundation

PCA identifies orthogonal directions in feature space that capture the maximum variance. Given a data matrix X∈Rn×p\mathbf{X} \in \mathbb{R}^{n \times p} with nn observations of pp features, PCA seeks a transformation matrix W\mathbf{W} that projects the data onto principal components:

Y=(X−μ)W\mathbf{Y} = (\mathbf{X} - \boldsymbol{\mu}) \mathbf{W}

where μ\boldsymbol{\mu} is the mean vector and W\mathbf{W} contains the eigenvectors of the covariance matrix C=1n−1(X−μ)T(X−μ)\mathbf{C} = \frac{1}{n-1}(\mathbf{X} - \boldsymbol{\mu})^T(\mathbf{X} - \boldsymbol{\mu}). The eigenvalue decomposition:

Cwi=λiwi\mathbf{C} \mathbf{w}_i = \lambda_i \mathbf{w}_i

The eigenvalues λi\lambda_i give the variance along each principal component direction wi\mathbf{w}_i. Components are ordered by decreasing eigenvalue, so the first few components capture most of the variance. This property makes PCA useful for noise reduction and feature compression in SHM.

9.3Practical Implementation: PCA for Multi-Domain Feature Analysis

The following example combines time-domain and frequency-domain features from a monitored structure and shows how the number of retained principal components affects detection accuracy, using the Wasserstein distance as the anomaly metric.

Key Python Implementation for PCA:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from sklearn.preprocessing import StandardScaler
from sklearn.decomposition import PCA

# Step 1: Standardize features (zero mean, unit variance)
scaler = StandardScaler()
baseline_scaled = scaler.fit_transform(baseline_data)
test_scaled = scaler.transform(test_data)

# Step 2: Apply PCA
pca = PCA()  # Or PCA(n_components=k) for specific number
pca.fit(baseline_scaled)
baseline_pca = pca.transform(baseline_scaled)
test_pca = pca.transform(test_scaled)

# Step 3: Analyze variance explained
variance_ratio = pca.explained_variance_ratio_
cumulative_variance = np.cumsum(variance_ratio)

9.4Optimal Component Selection Strategy

Selecting the number of principal components requires balancing information retention against noise suppression. Several criteria guide this decision:

Retain k components where: ∑i=1kλi∑i=1pλi≥τ\text{Retain } k \text{ components where: } \frac{\sum_{i=1}^{k} \lambda_i}{\sum_{i=1}^{p} \lambda_i} \geq \tau

where τ\tau is the variance retention threshold (typically 0.90-0.95). The Kaiser criterion retains components with eigenvalues above the mean, and scree plot analysis identifies the “elbow” where eigenvalues level off. For damage detection, cross-validation on labeled data often provides the most reliable selection criterion because it directly optimizes detection performance rather than variance retention.

The Wasserstein distance quantifies distribution separation in the reduced space. Unlike Euclidean distance, it measures the work needed to transform the baseline distribution into the damaged distribution, giving a physically interpretable measure of structural change. The analysis shows that two principal components can achieve meaningful separation, enabling effective detection while reducing both computational cost and noise sensitivity.

10End-to-End Example of Feature Engineering

This section integrates the three statistical methods (z-score, Mahalanobis, Wasserstein) and PCA in a realistic damage detection scenario.

10.1Bridge System and Measurement Campaign

The example uses a two-span continuous bridge (30 m + 50 m = 80 m total length) monitored under three structural conditions: intact baseline, light damage in span 1, and moderate damage in span 1. Each scenario includes 20-30 measurements that capture natural variability.

Loading...

10.2Raw Feature Extraction

Modal testing yields two fundamental feature types: natural frequencies (global indicators) and mode shapes (spatial indicators). The following extracts these for the first three vibration modes.

Loading...

10.3Frequency-Based Features

Natural frequencies are computationally efficient global indicators, but they have limited damage sensitivity and cannot localize damage. The code below examines their distributions and statistical separability.

<Figure size 1080x360 with 3 Axes>
Loading...

Mode shapes capture spatial damage patterns but require comparison to a reference. The MAC quantifies similarity between operational and baseline mode shapes. Values near 1 indicate consistency; significant drops suggest damage.

<Figure size 1080x360 with 3 Axes>
Loading...

10.5Feature Sensitivity Analysis

Each feature’s damage sensitivity is quantified using the Wasserstein distance, which measures distribution shifts. Higher values indicate stronger damage detectability.

<Figure size 1050x420 with 2 Axes>
Loading...

10.6Bivariate Feature Space

Single features have limited discriminative power. Examining joint feature distributions exploits correlations between features. The frequency pair (f1f_1, f2f_2) reveals coupling between fundamental modes.

<Figure size 1080x390 with 3 Axes>
Loading...

10.7Mahalanobis Distance Detection

Mahalanobis distance accounts for feature correlations and variance structure. The distances below are computed relative to the intact baseline distribution.

<Figure size 1050x420 with 2 Axes>
Loading...

10.8Principal Component Analysis

PCA transforms correlated features into uncorrelated principal components that capture the dominant patterns of variation, reducing dimensionality while retaining the information most useful for damage detection.

<Figure size 1050x420 with 2 Axes>
Loading...

10.9PC1-PC2 Projection

The first two principal components capture most of the variance. Projecting data onto this subspace reveals cluster separation and damage progression.

<Figure size 1050x600 with 1 Axes>
Loading...

10.10Feature Engineering Summary

This analysis shows the systematic transformation of raw modal parameters into discriminative features. Key findings:

Feature Sensitivity Hierarchy:

Multivariate Advantages:

Dimensionality Reduction:

Practical Implications:


11Feature Extraction from Digital Images

Vibration-based methods detect global changes in structural behavior, but vision-based inspection remains the standard approach for locating and characterizing surface damage. Cracks, spalling, corrosion, and delamination appear as distinct visual patterns in inspection images. Manually analyzing large numbers of inspection photos is time-consuming, subjective, and error-prone, which motivates automated image analysis methods that extract quantitative features from visual data.

Digital images are discrete 2D functions I(x,y)I(x,y) where each pixel intensity encodes local brightness. The fundamental operation for feature extraction is convolution: a mathematical kernel slides across the image, computing local weighted sums that highlight specific patterns such as edges, corners, or textures. This section develops the mathematical foundations of image feature extraction.

11.1Mathematical Foundations: Convolution and Filtering

Two-dimensional discrete convolution for an image II and kernel hh of size (2k+1)×(2k+1)(2k+1) \times (2k+1):

C(x,y)=(I∗h)(x,y)=∑i∑jI(x−i,y−j)⋅h(i,j)C(x,y) = (I * h)(x,y) = \sum_{i} \sum_{j} I(x-i, y-j) \cdot h(i,j)

This operation slides the kernel across the image, computing weighted sums of local neighborhoods, with zero padding at boundaries. Each output pixel is the sum of element-wise products between the kernel and the local image patch. Any mathematical operation on local image regions can be expressed as convolution with some kernel.

Two-dimensional convolution operation demonstrating the kernel sliding across the image matrix with zero padding at boundaries. The kernel (filter) performs element-wise multiplication with the local image patch, then sums the results to produce a single output pixel.

Figure 12:Two-dimensional convolution operation demonstrating the kernel sliding across the image matrix with zero padding at boundaries. The kernel (filter) performs element-wise multiplication with the local image patch, then sums the results to produce a single output pixel.

11.1.1Understanding Convolution Through 1D Edge Detection

Before examining 2D gradient operators, consider a 1D example that shows the fundamental connection between convolution and discrete differentiation. A horizontal slice through an image gives a 1D intensity profile I(x)I(x) that changes sharply at edges (transitions between concrete and cracks, or light and shadow). Locating edges requires computing dI/dxdI/dx, which peaks wherever intensity changes rapidly.

Since images are discrete, derivatives are approximated numerically. The central difference formula dIdx≈I(x+1)−I(x−1)2\frac{dI}{dx} \approx \frac{I(x+1) - I(x-1)}{2} compares neighboring pixels. Written for every position, this is equivalent to sliding the weight pattern [−1,0,+1][-1, 0, +1] across the signal and summing the products, which is convolution. The kernel [−1,0,+1][-1, 0, +1] encodes the central difference operator.

One-dimensional edge detection through convolution.

Figure 13:One-dimensional edge detection through convolution.

Every feature extraction operation (computing gradients, detecting corners, measuring texture) reduces to convolution with an appropriately designed kernel. The kernel values encode the mathematical operation applied at every image location.

11.1.2Gradient Operators

The image gradient components are approximated using the central difference method:

∂I∂x≈I(x+1,y)−I(x−1,y)2\frac{\partial I}{\partial x} \approx \frac{I(x+1,y) - I(x-1,y)}{2}
∂I∂y≈I(x,y+1)−I(x,y−1)2\frac{\partial I}{\partial y} \approx \frac{I(x,y+1) - I(x,y-1)}{2}

These operations are implemented as convolutions with kernels:

hx=12[000−101000],hy=12[0−10000010]h_x = \frac{1}{2}\begin{bmatrix} 0 & 0 & 0 \\ -1 & 0 & 1 \\ 0 & 0 & 0 \end{bmatrix}, \quad h_y = \frac{1}{2}\begin{bmatrix} 0 & -1 & 0 \\ 0 & 0 & 0 \\ 0 & 1 & 0 \end{bmatrix}

The gradient magnitude and direction then become:

∣∇I∣=(I∗hx)2+(I∗hy)2,θ=arctan⁡(I∗hyI∗hx)|\nabla I| = \sqrt{(I * h_x)^2 + (I * h_y)^2}, \quad \theta = \arctan\left(\frac{I * h_y}{I * h_x}\right)

11.1.3Second Derivative: The Laplacian

The second partial derivatives using central differences:

∂2I∂x2≈I(x+1,y)−2I(x,y)+I(x−1,y)1\frac{\partial^2 I}{\partial x^2} \approx \frac{I(x+1,y) - 2I(x,y) + I(x-1,y)}{1}

The Laplacian combines both second derivatives:

∇2I=∂2I∂x2+∂2I∂y2=I∗hLap\nabla^2 I = \frac{\partial^2 I}{\partial x^2} + \frac{\partial^2 I}{\partial y^2} = I * h_{Lap}

where the Laplacian kernel is:

hLap=[0101−41010]h_{Lap} = \begin{bmatrix} 0 & 1 & 0 \\ 1 & -4 & 1 \\ 0 & 1 & 0 \end{bmatrix}

11.2Key Python Implementation for Image Convolution

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from scipy import signal, ndimage
import cv2

# Load and preprocess image
img = cv2.imread(image_path, cv2.IMREAD_GRAYSCALE)
# Apply Gaussian smoothing to reduce noise
img_smooth = ndimage.gaussian_filter(img.astype(float), sigma=1.0)

# Define convolution kernels for derivatives
central_x = np.array([[0, 0, 0],
                      [-0.5, 0, 0.5],
                      [0, 0, 0]])
                    
central_y = np.array([[0, -0.5, 0],
                      [0, 0, 0],
                      [0, 0.5, 0]])

# Apply 2D convolution
grad_x = signal.convolve2d(img_smooth, central_x, mode='same')
grad_y = signal.convolve2d(img_smooth, central_y, mode='same')

# Compute gradient magnitude (edge strength)
gradient_magnitude = np.sqrt(grad_x**2 + grad_y**2)

The emphasized lines show the core operations: Gaussian smoothing reduces noise before edge detection, and 2D convolution extracts directional derivatives. The mode='same' parameter maintains image dimensions using symmetric boundary conditions.

11.3Crack Detection Example

The operators developed above form the basis for automated crack detection in bridge inspection images. Figure 14 applies them to a concrete crack image from a loaded beam experiment, showing how kernel operators transform raw pixel intensities into interpretable damage features.

Source
<Figure size 1080x825 with 14 Axes>

Figure 14:Mathematical kernel operators for crack detection applied to real concrete beam image showing filter responses and complete detection pipeline.


12Convolutional Neural Networks: Learned Feature Extraction for Damage Detection

The kernel operators developed in the previous section (Sobel, Laplacian, Prewitt) are hand-engineered filters that embody intuition about edges, corners, and textures. They work well for many applications, but require designers to specify in advance what visual patterns constitute damage. For complex damage types (corrosion textures, spalling, overlapping cracks), manually designing optimal filters is not practical.

Convolutional Neural Networks (CNNs) take the opposite approach: kernel coefficients are learnable parameters optimized from labeled training data. A CNN with randomly initialized kernels discovers, through iterative training, the convolution operators that maximize damage classification accuracy for the specific structural system and damage types in the training set.

12.1The Learning Paradigm: From Fixed to Optimized Kernels

Consider the first derivative operator with fixed coefficients:

hx=12[000−101000]h_x = \frac{1}{2}\begin{bmatrix} 0 & 0 & 0 \\ -1 & 0 & 1 \\ 0 & 0 & 0 \end{bmatrix}

This kernel detects vertical edges because its coefficients emphasize horizontal intensity gradients. CNNs answer the question of whether other coefficient values might work better by learning from data: kernels are initialized randomly, applied to labeled images (cracked vs intact concrete), and adjusted to reduce classification error. After many training iterations, the kernels converge to values tuned for the specific damage detection task, which may differ from classical operators.

Figure 15 shows how CNNs transform raw images into damage classifications. The architecture processes 224×224 RGB images through two convolutional layers (detecting edges and textures) alternating with max-pooling layers (reducing spatial dimensions), followed by dense layers for classification. The example learned kernels show that the network discovers edge detectors, corner detectors, and texture analyzers through training, identifying damage patterns that are difficult to capture with fixed operators.

Convolutional Neural Network architecture for automated damage detection. The pipeline (Input → Conv1 → MaxPool → Conv2 → MaxPool → Flatten → Dense → Output) shrinks spatial dimensions (224^2 \to 112^2 \to 56^2) while growing feature depth (3 \to 32 \to 64); a sigmoid head \sigma(z) collapses to the scalar probability P(\text{damage}). The four example 3\times3 kernels (vertical/horizontal edge, corner, Laplacian-of-Gaussian texture) illustrate features learned via backpropagation.

Figure 15:Convolutional Neural Network architecture for automated damage detection. The pipeline (Input → Conv1 → MaxPool → Conv2 → MaxPool → Flatten → Dense → Output) shrinks spatial dimensions (2242→1122→562224^2 \to 112^2 \to 56^2) while growing feature depth (3→32→643 \to 32 \to 64); a sigmoid head σ(z)\sigma(z) collapses to the scalar probability P(damage)P(\text{damage}). The four example 3×33\times3 kernels (vertical/horizontal edge, corner, Laplacian-of-Gaussian texture) illustrate features learned via backpropagation.

12.2Mathematical Formulation of Convolutional Layers

Each convolutional layer performs the fundamental operation:

Fj(l)(x,y)=σ(∑i=1Cl−1∑m=−kk∑n=−kkWij(l)(m,n)⋅Fi(l−1)(x+m,y+n)+bj(l))F_j^{(l)}(x,y) = \sigma\left(\sum_{i=1}^{C_{l-1}} \sum_{m=-k}^{k} \sum_{n=-k}^{k} W_{ij}^{(l)}(m,n) \cdot F_i^{(l-1)}(x+m, y+n) + b_j^{(l)}\right)

where:

This formulation shows three key CNN properties:

  1. Weight sharing: The same kernel Wij(l)W_{ij}^{(l)} applies at all spatial locations, greatly reducing parameters relative to fully connected layers

  2. Local connectivity: Each output pixel depends only on a local neighborhood of size 2k+12k+1

  3. Translation equivariance: Shifting the input shifts the output correspondingly, allowing crack detection regardless of image position

12.3Hierarchical Feature Representation: What CNNs Learn

Visualization of learned kernels and feature activations shows that CNNs build interpretable hierarchies:

Layer 1 (early features): Kernels resembling Sobel/Prewitt operators emerge automatically: horizontal, vertical, and diagonal edge detectors; color blob detectors; high-frequency texture analyzers.

Layers 2-3 (mid-level features): Feature maps respond to corners and junctions (crack branching points), repeated textures (concrete aggregate vs smooth crack faces), and oriented patterns.

Deep layers (high-level semantics): Features activate for complete crack segments, spalling regions, and corrosion patches with characteristic shapes and textures.

<Figure size 1080x690 with 15 Axes>

Figure 16:Evolution of CNN kernels during training from random initialization to converged damage-specific operators.

Figure 16 shows kernel evolution during 100 epochs of training. Three kernel types progress from random initialization to converged operators. At initialization, coefficients show no structure. By Epoch 10, patterns emerge as gradients guide the coefficients toward damage-relevant features. At convergence, the kernels become interpretable operators.

The Edge kernel converges to a Sobel-like vertical edge detector, showing that CNNs rediscover classical operators when appropriate. The Corner kernel develops an L-shaped pattern for detecting crack branching points, which classical operators do not emphasize. The Texture kernel learns a Laplacian-like second derivative operator for highlighting crack boundaries.

CNNs discover task-specific variations rather than copying hand-crafted operators: the learned edge detector differs subtly from standard Sobel coefficients, adapting to crack characteristics in the training data. The kernels optimize specifically for bridge damage patterns rather than generic edge detection.


13Conclusion

This chapter developed a framework for detecting structural damage through statistical comparison of monitoring data, starting from a single question: how do we know when a measurement is abnormal? The answer follows from establishing baseline distributions from healthy-structure measurements, then quantifying how far new observations deviate from those baselines.

Three detection methods were presented. The z-score method flags individual measurements that fall outside confidence intervals. Mahalanobis distance extends this to multiple correlated features simultaneously, recognizing that damage often appears across many features at once (frequencies decrease, damping changes, mode shapes shift). Wasserstein distance compares entire distributions rather than individual points, which is useful for assessing trends over time or population-level changes. Each method suits different situations depending on whether the data consists of single new measurements, continuous monitoring streams, or baseline-versus-post-event comparisons.

The analysis progressed from single features (natural frequency), to correlated pairs, to combinations of time-domain and frequency-domain features with mode shape indicators, and finally to systems with twelve or more features. More features improve detection sensitivity but introduce complexity. PCA addresses this by identifying which feature combinations carry the most useful information, often reducing twelve dimensions to three or four without sacrificing detection performance. This also filters measurement noise, improving reliability.

Image analysis extends the same statistical principles to visual inspection data. Operators like Sobel and Laplacian filters extract numerical features from crack images (edge strengths, orientation patterns, texture characteristics), which feed into the same statistical framework used for vibration data. CNNs automate this feature extraction by learning optimal filters from labeled images rather than using hand-designed operators. The underlying task is the same: transform raw measurements into features, establish baseline distributions, and detect deviations.