Algorithm Search⌘K

Definitionadvanced

Coherence factor

Also called coherence factor weighting.

The energy of the coherent sum of the delayed channel samples at a pixel, over M times their total energy. It lies in [0, 1] and is used as a pixel weight to suppress clutter and side lobes.

The coherence factor (CF) of a pixel measures how well the channels of an array agree after the focusing delays. It is the energy of the coherent sum of the delayed samples, the value that delay-and-sum (DAS) forms, divided by MM times the total energy of the MM samples. It is 11 when all channels hold the same value, as for an echo from a point at the focus, about 1/M1/M for independent noise, and lower for clutter and side lobes, where the channels disagree. CF is not a beamformer by itself: in CF weighting, the DAS output of each pixel is multiplied by its CF, or by a power of it, which keeps coherent targets and darkens incoherent parts of the image. Unlike the fixed weights of DAS and other linear beamforming, the weight comes from the data of the pixel, so CF weighting is a nonlinear, adaptive method, and it costs only O(M)O(M) per pixel.

Definition

Let s=(s1,…,sM)s = (s_1, \ldots, s_M) be the delayed channel samples of one pixel: complex (IQ or analytic) values, or real RF values. The coherence factor is

CF⁡(s)=∣∑i=1Msi∣2M∑i=1M∣si∣2\operatorname{CF}(s) = \frac{\left|\sum_{i=1}^M s_i\right|^2}{M \sum_{i=1}^M |s_i|^2}

for s≠0s \ne 0, and CF⁡(0)=0\operatorname{CF}(0) = 0 by convention. With the mean sˉ\bar s and the spread v=1M∑i∣si−sˉ∣2v = \frac1M \sum_i |s_i - \bar s|^2 of the samples, CF⁡(s)=∣sˉ∣2/(∣sˉ∣2+v)\operatorname{CF}(s) = |\bar s|^2 / (|\bar s|^2 + v): the fraction of the channel energy that lies in the mean.

CF weighting with an exponent p≥0p \ge 0 replaces the DAS value ∑isi\sum_i s_i by CF⁡(s)p∑isi\operatorname{CF}(s)^p \sum_i s_i. The exponent is a design choice that trades the suppression of clutter against the darkening of speckle; p=1p = 1 is common, and other values must be tuned for the task.

The definition has these consequences, each proved in proofs/correctness.md.

  1. Range. 0≤CF⁡≤10 \le \operatorname{CF} \le 1, by the Cauchy-Schwarz inequality. It is 11 if and only if all samples are equal, and 00 if and only if they sum to 00. This is a theorem.
  2. Scale invariance. CF⁡(as)=CF⁡(s)\operatorname{CF}(a s) = \operatorname{CF}(s) for every a≠0a \ne 0, so CF does not depend on the echo strength. The weighted output is homogeneous of degree one.
  3. Noise. For independent circular complex Gaussian samples of equal variance, E[CF⁡]=1/M\mathbb{E}[\operatorname{CF}] = 1/M. This is a theorem for that model.
  4. Speckle. For the triangular channel correlation 1−∣i−j∣/M1 - |i - j|/M, which the van Cittert-Zernike theorem predicts for fully developed speckle at the focus with equal transmit and receive apertures, the ratio of the expected coherent energy to MM times the expected total energy is (2M2+1)/(3M2)(2M^2 + 1)/(3M^2), near 2/32/3. The formula is a theorem for the model; that real speckle follows the model is a heuristic.

Computing it

  1. CF(s_1 … s_M, p) ▷ returns CF and the weighted value
  2. 1C ← |Σ_i s_i|² ▷ coherent energy
  3. 2E ← M Σ_i |s_i|² ▷ M times the incoherent energy
  4. 3if E = 0 then CF ← 0
  5. 4else CF ← C / E
  6. 5y ← CF^p · Σ_i s_i ▷ CF weighting of the DAS value

All lines run in O(M)O(M) time per pixel, the same order as DAS itself. For an image, the delayed samples come from any delay-based method: focused lines, synthetic transmit aperture, TFM, SAFT or plane-wave compounding.

Examples and non-examples

Perfect agreement. s=(1,1,1,1)s = (1, 1, 1, 1) gives ∣4∣2/(4⋅4)=1|4|^2 / (4 \cdot 4) = 1. Any constant nonzero vector gives 11, whatever its phase.

One channel. s=(1,0,0,0)s = (1, 0, 0, 0) gives 1/(4⋅1)=1/4=1/M1/(4 \cdot 1) = 1/4 = 1/M: a signal on one channel only is as incoherent as independent noise on average.

Cancellation. s=(1,−1,1,−1)s = (1, -1, 1, -1) gives 00. The DAS value is 00 too, but CF also says that the zero comes from disagreement, not from silence.

Partial agreement. s=(3,1,1,1)s = (3, 1, 1, 1) gives 36/(4⋅12)=0.7536 / (4 \cdot 12) = 0.75. The DAS value 66 becomes 4.54.5 with p=1p = 1 and 3.3753.375 with p=2p = 2.

Noise. For M=8M = 8 independent complex Gaussian samples, the mean CF over 3000 trials in the test is within 0.010.01 of 1/81/8.

Speckle. The triangular coherence gives 0.6718750.671875 for M=8M = 8 and 0.666750.66675 for M=64M = 64. A simulation with this correlation matches M=8M = 8 within 0.030.03.

A non-example: a strong point off the focus. A bright scatterer that is not at the pixel gives samples with a phase ramp across the array. CF is low, though the DAS value can be large in a side lobe. This is what CF weighting suppresses, and it shows that CF is not a measure of echo strength.

A non-example: a focusing error. With a wrong speed of sound, a true point target gives a curved phase across the channels and a CF below 11, so CF weighting darkens a real target. Mallart and Fink (1994) used a ratio of this kind as a criterion of focusing quality for this reason.

  • Delay-and-sum beamforming: its output is the coherent sum in the numerator of CF.
  • Van Cittert-Zernike theorem: it gives the spatial coherence of the echoes from a random medium across the aperture, and so the expected CF of speckle.
  • Delay-multiply-and-sum: another nonlinear combiner that rewards agreement, through pairwise products in place of a ratio of energies.
  • Capon beamformer: an adaptive beamformer that changes the weights of each channel, not the gain of the pixel.
  • Generalized coherence factor: the fraction of the energy of the aperture spectrum (the DFT across the channels) in a few low spatial frequencies, not only at the zero frequency. CF is the case of one frequency.
  • Short-lag spatial coherence: an image formed from the normalized correlation of channels at small lags, in place of a weight on DAS.
Proof: The coherence factor lies in [0, 1], is 1 only for equal samples, has mean 1/M for independent noise, and is near 2/3 for the triangular coherence of specklefull

We prove the facts behind the definition and lines L1 to L5 of the main page. The input is a complex vector s=(s1,…,sM)s = (s_1, \ldots, s_M) of delayed channel samples at one pixel, and

CF⁡(s)=∣∑isi∣2M∑i∣si∣2\operatorname{CF}(s) = \frac{|\sum_i s_i|^2}{M \sum_i |s_i|^2}

for s≠0s \ne 0, with CF⁡(0)=0\operatorname{CF}(0) = 0 by convention (line L3).

Theorem 1 (range). For s≠0s \ne 0, 0≤CF⁡(s)≤10 \le \operatorname{CF}(s) \le 1. The value is 11 if and only if all sis_i are equal, and 00 if and only if ∑isi=0\sum_i s_i = 0.

Proof. The numerator and the denominator are nonnegative and the denominator is positive. By the Cauchy-Schwarz inequality, ∣∑i1⋅si∣2≤(∑i1)(∑i∣si∣2)=M∑i∣si∣2|\sum_i 1 \cdot s_i|^2 \le (\sum_i 1)(\sum_i |s_i|^2) = M \sum_i |s_i|^2, with equality if and only if ss is a multiple of (1,…,1)(1, \ldots, 1). The numerator is 00 exactly when the sum is 00. □\square

Theorem 2 (mean and spread). Let sˉ=1M∑isi\bar s = \frac1M \sum_i s_i and v=1M∑i∣si−sˉ∣2v = \frac1M \sum_i |s_i - \bar s|^2. Then for s≠0s \ne 0

CF⁡(s)=∣sˉ∣2∣sˉ∣2+v.\operatorname{CF}(s) = \frac{|\bar s|^2}{|\bar s|^2 + v}.

Proof. 1M∑i∣si∣2=∣sˉ∣2+v\frac1M \sum_i |s_i|^2 = |\bar s|^2 + v, the usual split of the mean square into the square of the mean and the variance. Divide the numerator and the denominator of CF by M2M^2. □\square

So CF is the fraction of the channel energy that lies in the mean, the part that delay-and-sum keeps. A spread of the samples around their mean, from clutter, noise or a focusing error, lowers it.

Theorem 3 (scale invariance). For every complex a≠0a \ne 0, CF⁡(as)=CF⁡(s)\operatorname{CF}(a s) = \operatorname{CF}(s).

Proof. The numerator and the denominator are both multiplied by ∣a∣2|a|^2. □\square

So CF does not depend on the echo strength, only on how well the channels agree, and the weighted output CF⁡p∑isi\operatorname{CF}^p \sum_i s_i of line L5 is homogeneous of degree one in ss.

Theorem 4 (independent noise). Let s1,…,sMs_1, \ldots, s_M be independent circular complex Gaussian variables with mean 00 and the same variance. Then E[CF⁡(s)]=1/M\mathbb{E}[\operatorname{CF}(s)] = 1/M.

Proof. Let e=(1,…,1)/Me = (1, \ldots, 1)/\sqrt{M}, so CF⁡(s)=∣eHs∣2/∥s∥2\operatorname{CF}(s) = |e^H s|^2 / \|s\|^2, and s≠0s \ne 0 with probability one. Choose a unitary matrix UU with Ue=e1U e = e_1, the first unit vector. Then eHs=e1HUse^H s = e_1^H U s and ∥s∥=∥Us∥\|s\| = \|U s\|, and UsU s has the same distribution as ss, because the distribution of ss is invariant under unitary maps. So E[CF⁡(s)]=E[∣s1∣2/∥s∥2]\mathbb{E}[\operatorname{CF}(s)] = \mathbb{E}[|s_1|^2 / \|s\|^2]. The entries are exchangeable, so this expectation is the same for every index, and the MM expectations add to E[∥s∥2/∥s∥2]=1\mathbb{E}[\|s\|^2/\|s\|^2] = 1. □\square

The test measures a mean of 1/81/8 within 0.010.01 for M=8M = 8 and 3000 trials. Independent channels are a model of electronic noise; clutter and speckle are correlated across the aperture.

Theorem 5 (triangular coherence). Let the samples have mean 00 and the correlation E[sisˉj]=σ2(1−∣i−j∣/M)\mathbb{E}[s_i \bar s_j] = \sigma^2 (1 - |i - j|/M) with σ2>0\sigma^2 > 0. Then

E ∣∑isi∣2M E∑i∣si∣2=2M2+13M2,\frac{\mathbb{E}\,|\sum_i s_i|^2}{M\, \mathbb{E} \sum_i |s_i|^2} = \frac{2 M^2 + 1}{3 M^2},

which tends to 2/32/3 as MM grows.

Proof. The denominator is M⋅Mσ2M \cdot M \sigma^2. The numerator is σ2∑i,j(1−∣i−j∣/M)\sigma^2 \sum_{i,j} (1 - |i - j|/M). There are MM pairs with i=ji = j and 2(M−d)2(M - d) pairs at distance d≥1d \ge 1, so the sum is M2−2M∑d=1M−1d(M−d)M^2 - \frac{2}{M} \sum_{d=1}^{M-1} d (M - d). Since ∑d=1M−1d(M−d)=M(M2−1)6\sum_{d=1}^{M-1} d(M - d) = \frac{M(M^2 - 1)}{6}, the sum is M2−M2−13=2M2+13M^2 - \frac{M^2 - 1}{3} = \frac{2M^2 + 1}{3}. Divide by M2M^2. □\square

This is a ratio of expectations, not the expectation of CF. The triangular correlation is what the pulse-echo form of the van Cittert-Zernike theorem predicts for fully developed speckle from a uniform transmit aperture of the same width as the receive aperture, at the focus (Mallart and Fink 1994). Under that model, speckle has a coherence near 2/32/3, between the 1/M1/M of noise and the 11 of a point target. The test checks the closed form directly for several MM and by a simulation with moving sums of independent samples, which have exactly this correlation, within 0.030.03 for M=8M = 8.

Theorem 6 (cost). Lines L1 to L5 cost O(M)O(M) per pixel.

Proof. Each line is one pass over the samples or O(1)O(1) work. □\square

Code

Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.

coherence_factor.pyI0RawGitHub
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/coherence-factor/. The authors are listed in prov/BGW13T.jsonl.
"""The coherence factor of delayed array samples, and CF weighting.

For the delayed (focused) channel samples s_1, ..., s_M of one pixel,

    CF = |sum_i s_i|^2 / (M sum_i |s_i|^2),

the energy of the coherent sum over M times the total energy. It lies in
[0, 1] by the Cauchy-Schwarz inequality, and it is 1 exactly when all samples
are equal and not all zero. CF weighting multiplies the delay-and-sum output
by CF^p; the exponent p is a design choice (p = 1 is the common one).
"""


def coherence_factor(samples):
    """CF of one delayed channel vector; 0 when every sample is 0."""
    m = len(samples)
    coherent = abs(sum(samples)) ** 2  # @line L1
    incoherent = m * sum(abs(s) ** 2 for s in samples)  # @line L2
    if incoherent == 0:  # @line L3
        return 0.0
    return coherent / incoherent  # @line L4


def cf_weighted(samples, p=1.0):
    """The delay-and-sum value times CF^p."""
    return sum(samples) * coherence_factor(samples) ** p  # @line L5


def triangle_coherence_cf(m):
    """E|sum s|^2 / (M E sum |s|^2) when the channel correlation is 1 - |i - j| / M.

    This is the pulse-echo van Cittert-Zernike coherence of fully developed
    speckle for a uniform transmit aperture as wide as the receive aperture.
    The value is (2 M^2 + 1) / (3 M^2), which tends to 2/3.
    """
    return (2 * m * m + 1) / (3 * m * m)
test_coherence_factor.py 72 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/coherence-factor/. The authors are listed in prov/BGW13T.jsonl.

import math
import random

from coherence_factor import cf_weighted, coherence_factor, triangle_coherence_cf


def _cgauss(rng):
    return complex(rng.gauss(0, 1), rng.gauss(0, 1)) / math.sqrt(2)


def test_page_examples() -> None:
    assert coherence_factor([1.0, 1.0, 1.0, 1.0]) == 1.0
    assert coherence_factor([1.0, 0.0, 0.0, 0.0]) == 0.25
    assert coherence_factor([1.0, -1.0, 1.0, -1.0]) == 0.0
    assert abs(coherence_factor([3.0, 1.0, 1.0, 1.0]) - 36 / 48) < 1e-15
    assert coherence_factor([0.0, 0.0]) == 0.0


def test_range_and_equality_case() -> None:
    rng = random.Random(6601)
    for _ in range(500):
        m = rng.randint(1, 20)
        s = [_cgauss(rng) for _ in range(m)]
        v = coherence_factor(s)
        assert -1e-15 <= v <= 1 + 1e-12
    c = 0.3 - 2.0j
    assert abs(coherence_factor([c] * 9) - 1) < 1e-12
    # a phase ramp that is not constant lowers CF below 1
    assert coherence_factor([complex(math.cos(0.4 * k), math.sin(0.4 * k)) for k in range(9)]) < 0.9


def test_scale_invariance() -> None:
    rng = random.Random(6602)
    s = [_cgauss(rng) for _ in range(12)]
    for a in (5.0, -0.01, 2 - 3j):
        assert abs(coherence_factor([a * v for v in s]) - coherence_factor(s)) < 1e-12


def test_independent_channels_have_mean_one_over_m() -> None:
    rng = random.Random(6603)
    m, trials = 8, 3000
    mean = sum(coherence_factor([_cgauss(rng) for _ in range(m)]) for _ in range(trials)) / trials
    assert abs(mean - 1 / m) < 0.01


def test_triangle_coherence_closed_form() -> None:
    for m in (1, 2, 5, 16, 64):
        direct = sum(1 - abs(i - j) / m for i in range(m) for j in range(m)) / (m * m)
        assert abs(direct - triangle_coherence_cf(m)) < 1e-12


def test_triangle_coherence_by_simulation() -> None:
    # s_i = (g_i + ... + g_{i+M-1}) / sqrt(M) has the correlation 1 - |i - j| / M
    rng = random.Random(6604)
    m, trials = 8, 3000
    num = den = 0.0
    for _ in range(trials):
        g = [_cgauss(rng) for _ in range(2 * m - 1)]
        s = [sum(g[i:i + m]) / math.sqrt(m) for i in range(m)]
        num += abs(sum(s)) ** 2
        den += m * sum(abs(v) ** 2 for v in s)
    assert abs(num / den - triangle_coherence_cf(m)) < 0.03


def test_weighting() -> None:
    s = [3.0, 1.0, 1.0, 1.0]
    assert abs(cf_weighted(s) - 6 * 0.75) < 1e-12
    assert abs(cf_weighted(s, 2.0) - 6 * 0.75 ** 2) < 1e-12
    assert cf_weighted(s, 0.0) == 6.0

References

  1. Raoul Mallart and Mathias Fink, Adaptive focusing in scattering media through sound-speed inhomogeneities: The van Cittert Zernike approach and focusing criterion, Journal of the Acoustical Society of America 96(6), 1994, 3721 to 3732, the focusing criterion, a ratio of coherent to incoherent energy across the aperture, and its relation to the van Cittert-Zernike theorem (general locator)
  2. K. W. Hollman, K. W. Rigby and M. O'Donnell, Coherence factor of speckle from a multi-row probe, Proceedings of the 1999 IEEE Ultrasonics Symposium, vol. 2, 1257 to 1260, the coherence factor of speckle and its use as an image weight (general locator)

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH2 full proof
  • correctness: no review record reviews/BGW13T/proof-correctness.yaml
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
Code (python)I0 not checked yet
  • the tests did not run in this build
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW4 complete
  • a review of the text: no review record reviews/BGW13T/text.yaml