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 times the total energy of the samples. It is when all channels hold the same value, as for an echo from a point at the focus, about 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 per pixel.
Definition
Let be the delayed channel samples of one pixel: complex (IQ or analytic) values, or real RF values. The coherence factor is
for , and by convention. With the mean and the spread of the samples, : the fraction of the channel energy that lies in the mean.
CF weighting with an exponent replaces the DAS value by . The exponent is a design choice that trades the suppression of clutter against the darkening of speckle; is common, and other values must be tuned for the task.
The definition has these consequences, each proved in proofs/correctness.md.
- Range. , by the Cauchy-Schwarz inequality. It is if and only if all samples are equal, and if and only if they sum to . This is a theorem.
- Scale invariance. for every , so CF does not depend on the echo strength. The weighted output is homogeneous of degree one.
- Noise. For independent circular complex Gaussian samples of equal variance, . This is a theorem for that model.
- Speckle. For the triangular channel correlation , 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 times the expected total energy is , near . The formula is a theorem for the model; that real speckle follows the model is a heuristic.
Computing it
CF(s_1 … s_M, p) ▷ returns CF and the weighted value- 1
C ← |Σ_i s_i|² ▷ coherent energy - 2
E ← M Σ_i |s_i|² ▷ M times the incoherent energy - 3
if E = 0 then CF ← 0 - 4
else CF ← C / E - 5
y ← CF^p · Σ_i s_i ▷ CF weighting of the DAS value
All lines run in 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. gives . Any constant nonzero vector gives , whatever its phase.
One channel. gives : a signal on one channel only is as incoherent as independent noise on average.
Cancellation. gives . The DAS value is too, but CF also says that the zero comes from disagreement, not from silence.
Partial agreement. gives . The DAS value becomes with and with .
Noise. For independent complex Gaussian samples, the mean CF over 3000 trials in the test is within of .
Speckle. The triangular coherence gives for and for . A simulation with this correlation matches within .
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 , 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.
Related definitions
- 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 of delayed channel samples at one pixel, and
for , with by convention (line L3).
Theorem 1 (range). For , . The value is if and only if all are equal, and if and only if .
Proof. The numerator and the denominator are nonnegative and the denominator is positive. By the Cauchy-Schwarz inequality, , with equality if and only if is a multiple of . The numerator is exactly when the sum is .
Theorem 2 (mean and spread). Let and . Then for
Proof. , 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 .
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 , .
Proof. The numerator and the denominator are both multiplied by .
So CF does not depend on the echo strength, only on how well the channels agree, and the weighted output of line L5 is homogeneous of degree one in .
Theorem 4 (independent noise). Let be independent circular complex Gaussian variables with mean and the same variance. Then .
Proof. Let , so , and with probability one. Choose a unitary matrix with , the first unit vector. Then and , and has the same distribution as , because the distribution of is invariant under unitary maps. So . The entries are exchangeable, so this expectation is the same for every index, and the expectations add to .
The test measures a mean of within for 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 and the correlation with . Then
which tends to as grows.
Proof. The denominator is . The numerator is . There are pairs with and pairs at distance , so the sum is . Since , the sum is . Divide by .
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 , between the of noise and the of a point target. The test checks the closed form directly for several and by a simulation with moving sums of independent samples, which have exactly this correlation, within for .
Theorem 6 (cost). Lines L1 to L5 cost per pixel.
Proof. Each line is one pass over the samples or work.
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.
# 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
- 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)
- 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.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H2 full proof |
|
| Lean | L0 no Lean part |
|
| Code (python) | I0 not checked yet |
|
| Visual | V0 none |
|
| Writing | W4 complete |
|
Tag BGW13T Edit this page History Report an error Markdown