◊ STRUCTURE·TENSOR·LAB ◊ v1.0
Gradient Covariance · Second-Moment Analysis

The structure
of an image.

A real-time pipeline that converts RGB to luminance, takes its partial derivatives, and computes the covariance of the gradient field. The resulting 2×2 matrix encodes local orientation, edges, and corners.

rec. 709
N × 2 → 2 × 2
eigen · decomp
Input
Synthetic Samples
Local Window (W) 7 px
Corner Threshold 35%
Input RGB i.
Source image · pixel space ℝ³
Luminance L(x,y) ii.
0.2126 R + 0.7152 G + 0.0722 B
‖∇L‖ — Gradient Magnitude iii.
√(Gₓ² + G_y²) · edge energy
Gₓ — ∂L/∂x iv.
Horizontal derivative · red(+) / blue(−)
G_y — ∂L/∂y v.
Vertical derivative · red(+) / blue(−)
Corner Response — λ₂ vi.
Shi-Tomasi · min eigenvalue of JW

Gradient Distribution

Each point is one pixel's gradient vector (Gₓ, G_y). The ellipse is the 2σ iso-contour of the global covariance matrix C. Its axes are the eigenvectors; their lengths are √λ.

pixel gradient
2σ covariance ellipse
major axis · v₁ · √λ₁
minor axis · v₂ · √λ₂

Pipeline formulas

1 · Luminance (Rec. 709) $$L(x,y) = 0.2126\,R + 0.7152\,G + 0.0722\,B$$
2 · Spatial Gradients $$G_x = \frac{\partial L}{\partial x}, \quad G_y = \frac{\partial L}{\partial y}$$
3 · Flatten — N pixels into M $$\mathbf{M} = \begin{bmatrix} G_x(1) & G_y(1) \\ G_x(2) & G_y(2) \\ \vdots & \vdots \\ G_x(N) & G_y(N) \end{bmatrix} \in \mathbb{R}^{N\times 2}$$
4 · Second-Moment Matrix $$\mathbf{C} = \frac{1}{N}\,\mathbf{M}^\top \mathbf{M}$$

Live statistics

N (pixels)
C · 2×2 second-moment
—    —
—    —
λ₁ · major eigenvalue
λ₂ · minor eigenvalue
anisotropy · 1 − λ₂/λ₁
dominant angle · v₁
trace · tr(C)
det · det(C)