Correlated double sampling

From wenmin-wu/ds-skills · View interactive version

Correlated double sampling is an AI agent skill from the GitHub repository wenmin-wu/ds-skills. Subtract paired reference frames from signal frames to cancel readout noise and common-mode bias

How to use this skill

Skill file

Correlated Double Sampling (CDS)

Overview

For sensors with paired read/reset cycles, subtract even frames from odd frames (or vice versa) to cancel common-mode noise (kTC noise, bias drift, readout offsets). Halves the frame count but dramatically improves SNR. Common in astronomical detectors, IR sensors, and scientific imaging.

Quick Start

import numpy as np

def correlated_double_sampling(signal):
    """Subtract even (reset) frames from odd (read) frames.
    
    Args:
        signal: (..., T, ...) with T frames in read/reset pairs
    Returns:
        (..., T//2, ...) CDS-processed signal
    """
    return signal[..., 1::2, :] - signal[..., ::2, :]

# Often followed by temporal binning
def cds_and_bin(signal, bin_size=10):
    cds = correlated_double_sampling(signal)
    n_bins = cds.shape[-2] // bin_size
    binned = np.zeros((*cds.shape[:-2], n_bins, *cds.shape[-1:]))
    for i in range(n_bins):
        binned[..., i, :] = cds[..., i*bin_size:(i+1)*bin_size, :].mean(axis=-2)
    return binned

Key Decisions

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.