---
title: "Why subtracting a halo also subtracts a companion"
description: "Derive angular and spectral self-subtraction, including the two-frame Gaussian limit and a measured five-channel response."
canonical_url: "https://sandboxphysics.com/stories/direct-imaging/rotation-and-self-subtraction/"
language: "en"
page_type: "story"
alternate_languages:
  zh-CN: "https://sandboxphysics.com/zh/stories/direct-imaging/rotation-and-self-subtraction/"
last_modified: "2026-10-28"
---

[Direct imaging, from glare to a spectrum](https://sandboxphysics.com/stories/direct-imaging/)

L2 · Direct imaging

# Why subtracting a halo also subtracts a companion

Sandbox Physics · 2026-10-28

A reference made from science images contains some companion light. Subtraction acts on that light as well as the stellar halo. We can calculate the loss by applying the same reference, rotation and measurement to a known source.

## Before you begin

Read From a pupil wave to counted camera pixels first. You need averages and rotations. A linear operator is a rule that preserves sums and scale factors; that definition will tell us when a single response calibration can be reused.

## Write the image operation in its actual order

Let each detector frame be a list of pixel counts. The reference is the mean of all eighteen frames, including the current one. Subtract this same mean from each frame. Then rotate every residual back to the sky orientation and average the rotated images. Subtracting after sky alignment would instead put the companion into the same reference pixels and remove it almost completely.

Use a signed rotation operator that samples detector coordinates at the rotated sky position. Interpolation is part of that operator. A mathematical rotation preserves flux in continuous space, but a finite sampled camera also has interpolation and edge losses; the injection passes through those numerical operations too.

$$
\bar D=\frac1T\sum_{t=1}^T D_t,\qquad S=\frac1T\sum_{t=1}^T R_{\psi_t}(D_t-\bar D)
$$

The reference mean includes the target frame. The sign convention is output sky position sampling detector position rotated forwards by the exposure angle. All terms have camera-count units.

Reading: Marois et al. · Soummer

## First inspect the zero-rotation limit

When every rotation is the identity, the final mean of the mean-subtracted images is zero. This is true for a changing halo, a companion and noise. The signed image can contain frame-by-frame residuals, but their average cancels. A nonzero stationary companion cannot be recovered from that coadded mean-ADI image.

With a small rotation, the source shifts slightly between frames. Its positive core overlaps much of its negative reference imprint. The motion on the camera is the chord of a circle: twice the separation times the sine of half the angle. This geometric displacement sets the scale for how well the source separates from itself.

$$
d=2\rho\sin(\Delta\psi/2)\simeq\rho\Delta\psi\quad(\Delta\psi\text{ in radians})
$$

Displacement and source separation use the same angular unit. The small-angle expression applies only when the angle is small in radians.

Reading: Marois et al.

## Derive a response that can be checked without the optical code

Replace the source PSF with a circular Gaussian of standard deviation sigma. For two exposures, the mean reference contains half of each source image. After subtraction, each source therefore has a positive half and a displaced negative half. Measure the result with a matched filter: multiply it by the centered Gaussian and integrate over the image.

The overlap of two equal Gaussians separated by a distance is an exponential. Completing the square in their product gives the exponent below. Divide the processed projection by the unprocessed Gaussian power to obtain the recovered amplitude.

The factor of one half matters. A leave-one-out reference made entirely from the other frame gives twice this response. Naming a method ADI does not specify which reference convention it used. The numerical check here integrates the two Gaussians on an independent dense grid, so it can catch a reference-normalization error.

$$
|\boldsymbol x|^2+|\boldsymbol x-\boldsymbol d|^2=2|\boldsymbol x-\boldsymbol d/2|^2+d^2/2
$$

Completing the square separates a centered Gaussian from a displacement factor. The integral sums small image-area contributions; shifting the Gaussian center does not change its whole-plane integral.

$$
\frac{\int P(\boldsymbol x)P(\boldsymbol x-\boldsymbol d)\,d^2x}{\int P(\boldsymbol x)^2\,d^2x}=\exp[-d^2/(4\sigma^2)]
$$

The normalization of the Gaussian cancels. This is a matched-filter calculation in continuous space, not a universal aperture-throughput law.

$$
\eta_{\rm two\ frames}=\frac12\left[1-e^{-d^2/(4\sigma^2)}\right]\simeq\frac{d^2}{8\sigma^2}
$$

The reference includes both frames. Very small displacement produces a response quadratic in displacement. Eighteen-frame, masked, sampled optical images use their own measured response.

Reading: Marois et al. · Pueyo

## Work through two saved observations

The default source is five reference angular units from the star. Fifty degrees of rotation move it by 4.23 reference units across the endpoints. With the same source and only three degrees of rotation, that displacement falls to 0.262 units. The input brightness has not changed; the reference sees a much more stationary source.

The table uses the saved synthetic seed 22022, five finite bands and eighteen exposures from the preceding chapter. The middle-band entrance contrast is 0.00124. The processed aperture response is the ratio of its calibrated derivative to the aperture measurement with subtraction disabled. It includes the implemented interpolation. The spectrum uncertainty also includes estimated source photon noise. This fixed low-rotation realization lies several conditional standard errors from the input; repeated acquisitions test how those bars behave.

| Synthetic sequence | Middle-band response | Extracted contrast | Conditional standard error |
| --- | --- | --- | --- |
| Fifty-degree rotation | 0.685 | 0.001240 | 0.00000750 |
| Three-degree rotation | 0.0159 | 0.001401 | 0.0000616 |
| Source near mask edge | 0.506 | 0.001226 | 0.0000310 |

![A faint source rotates between two noisy synthetic camera frames; the derotated residual has a positive source and negative subtraction lobes.](https://sandboxphysics.com/stories/direct-imaging/synthetic-processing.svg)

Two actual sampled synthetic frames and their mean-ADI residual. Raw images share a fixed logarithmic electron-count stretch; the residual uses a signed scale. The camera and sky axes use the reference angular unit.

Reading: Marois et al. · Pueyo

## Resizing wavelengths introduces a second kind of motion

A diffraction speckle tends to move radially with wavelength. To align such structure, resize every channel to a reference wavelength before subtracting a spectral mean. A sky companion stays at a fixed angular separation in the original camera, so this resizing moves it instead. This is spectral differential imaging, or SDI.

Flux conservation supplies the area factor. If an image is expanded by a scale factor, the same photons cover its square in area. The resized count density is the old image sampled at the inverse coordinate and divided by the square of the scale. Applying a geometric resize without that factor changes a source spectrum even before subtraction.

The default source moves from about 5.44 to 4.63 reference units between the resized endpoints of the five-channel set. Its images still overlap substantially. A source injected into one band now enters the common spectral reference, so several output bands change.

$$
s_\ell=\lambda_{\rm ref}/\lambda_\ell,\qquad I'_\ell(\boldsymbol u)=s_\ell^{-2}I_\ell(\boldsymbol u/s_\ell)
$$

This is the rescaled intermediate coordinate, not a change in the astronomical source angle. After subtraction each channel is restored to its physical sky scale before angular derotation.

Reading: Greco & Brandt · Pueyo

## Measure the complete response and check its range

Inject one channel at a time before resizing or making a reference. Repeat the whole processing with small positive and negative increments and measure the difference in every output channel. Each experiment supplies one column of the response matrix. The diagonal describes direct response; off-diagonal entries describe spectral mixing.

For the saved ADI-plus-SDI sequence, the first normalized response column is approximately 0.130, minus 0.0284, minus 0.0230, minus 0.0158 and minus 0.0103. Those numbers are output electrons per unit contrast divided by the stellar entrance count. Dividing each recovered band by its own diagonal response would leave the negative contributions from all the other bands uncorrected.

Mean subtraction and fixed interpolation are linear. KLIP learns principal image patterns from the reference data and removes a chosen number of them. A source changes both the direct image and those learned patterns. Full finite injections recompute the patterns. Comparing different injection amplitudes then tests how far a local derivative can describe the nonlinear reduction.

$$
A_{ij}\simeq\frac{y_i(D+\delta c_j P_j)-y_i(D-\delta c_j P_j)}{2\delta c_j}
$$

The response is the derivative of the measured output counts with respect to entrance channel contrast. Positive and negative increments define a numerical derivative on one frozen photon realization.

Reading: Soummer · Pueyo · Greco & Brandt

## Try the observation

### [Predict a loss, then inspect a mixed response](https://sandboxphysics.com/labs/pupil-engineering-coronagraph/)

1. Compare A companion turns with Almost no rotation, keeping the entrance contrast fixed.
2. Choose spectral plus angular subtraction in the advanced group and inspect the off-diagonal response cells.
3. Try KLIP with one and then three modes. Compare the sharper image with the change in extracted light; choose a processing rule using both spectral response and noise.

## Exercises and explained answers

Two identical Gaussian images are separated by one Gaussian standard deviation. What response does the two-frame inclusive-mean matched filter recover?

Use $\eta=\tfrac12(1-e^{-1/4})\simeq0.111$. A leave-one-out reference gives about 0.221. The factor differs because the first reference contains half of the target frame itself.

A planet has the same contrast in all five bands. Does SDI necessarily erase it exactly?

Its constant spectrum alone does not decide the result. Resizing moves the companion between pixels, so the channel images differ even when entrance contrasts are equal. At small separation the images overlap more strongly, and some spectral combinations can become poorly measured. Evaluate the full sampled response.

You double an image size but forget the area factor. Diagnose the error using a source far from the edges.

The integrated source count grows by roughly four. A correctly flux-conserving expansion keeps that count approximately fixed, apart from interpolation. This test diagnoses a coordinate-density error before any PSF subtraction is involved.

[Previous: From a pupil wave to counted camera pixels](https://sandboxphysics.com/stories/direct-imaging/from-pupil-to-pixels/) [Next: Recover a spectrum without losing its uncertainty](https://sandboxphysics.com/stories/direct-imaging/recovering-a-coupled-spectrum/)

## Sources and calculation scope

1. [Marois et al., Angular Differential Imaging (2006)](https://arxiv.org/abs/astro-ph/0512335v1)

   Fixed v1, observing geometry and reference subtraction. Field rotation supplies diversity between an astronomical source and pupil-fixed structure.

2. [Soummer, Pueyo & Larkin, KLIP (2012)](https://arxiv.org/abs/1207.4197v1)

   Fixed v1, Sections 2.1–2.3 and 3.1, Equations 5–12, Figures 1–2. The reference library, eigenimages and projection define a particular subtraction operator.

3. [Pueyo, Detection and Characterization of Exoplanets Using Projections on Karhunen–Loève Eigenimages (2016)](https://arxiv.org/abs/1604.06097v1)

   Fixed v1, Sections 2.1–2.5, 3.1–3.3 and 4.1–4.2; Appendix E, Equations E18/E20, and Appendix F, Equations F8–F12. Source contamination changes the reference basis. The illustrative J-band spectra use synthetic injections.

4. [Greco & Brandt, The Measurement, Treatment, and Impact of Spectral Covariance and Bayesian Priors in Integral-Field Spectroscopy of Exoplanets (2016)](https://arxiv.org/abs/1602.00691v1)

   Fixed v1, Section 2, Equations 1–6; Sections 3.1–3.2, Equations 7–8. Spectral covariance changes the weighting of broad spectral structures.
