Topic: finding points
Where are the small bright things, how many are there, and exactly where is each one? The question comes up on many days of this course, often under another name. A fluorescent spot, a blob of unknown size, the shift between two images, a line in a Hough accumulator and a keypoint all come down to one task: find the peaks of some map, keep the real ones, and say where they are to a fraction of a pixel.
This page puts those approaches side by side. It explains what each one assumes, what it costs and when it fails, and links to the units where each is taught. Read the plain text for the ideas. The one The math box near the end ties the approaches together, and you can skip it.
Do the point detection day (four units). Before it you need filtering and scale space. The camera noise and PSF units help too. After it come object matching and F1 and linking spots into tracks.
The question in plain words
A point-like object (a single molecule, a vesicle, a bead, a star) is smaller than what the microscope can resolve. Its image is therefore a copy of the point spread function, a blob a few pixels wide, sitting on a background and buried in noise. To find it we have to answer four separate questions:
- Where could a spot be? Make the spots stand out from noise and background.
- Which candidates are real? Choose a threshold. Every threshold lets some noise through and misses some dim spots.
- Exactly where is each one? The brightest pixel is only good to ± half a pixel, and the spot’s other pixels hold more information than that.
- How good is the list? Compare it with the truth, one point against one point.
tools/figs/topics-point-detection/). Step 1: a zero-mean filter of the spot’s width turns each spot into a peak and cancels the sloping background. Step 2: local maxima give 20 candidates. Step 3: a threshold of 4 × the noise of the filtered profile keeps exactly the 6 spots. Step 4: fitting a spot model to the raw pixels places them. The errors are −0.04 and 0.28 px for the close pair in the zoom, and 0.77 px for the dimmest spot (pixel 108).One recipe, many days
Look closely and the same recipe appears on many days of the course: build a response map whose peaks are the things you want, take its local maxima, keep those above a threshold, refine each peak to sub-pixel precision, and evaluate the list against the truth. What changes from day to day is what the map is and what a peak means.

| Day / unit | What is a “point” | The response map | What the peak gives |
|---|---|---|---|
| Finding spots | a diffraction-limited spot | the image filtered with the spot shape (Gaussian, LoG/DoG, à trous) | position (x, y) |
| Scale space, blobs | a round blob of unknown size | scale-normalised LoG in (x, y, \sigma) | position and size |
| The Hessian | a blob, as opposed to a ridge or saddle | the two curvatures (eigenvalues) per pixel | position and shape type |
| Top-hat, h-maxima | a peak that rises above its surroundings | the image minus its opening; the height above the saddle | regional maxima, chosen by height |
| Keypoints | a corner or blob that can be found again | DoG pyramid, corner score | position, scale, orientation |
| Template matching | a copy of a template | normalised cross-correlation | where the template fits |
| Phase correlation, stitching | the shift between two images | the whitened cross-correlation | shift, to sub-pixel |
| Hough lines, circles | a line or circle | votes in parameter space | (\theta, \rho) or centre and radius |
| Boosted detectors | a face (or object) in a window | classifier score per window and scale | window position and size |
| Boxes | an object | box scores, or a heat map of centres | a box per object, after suppression |
| Sub-pixel localisation | a single molecule | the fit of a PSF model | position to ~10 nm, with an error bar |
The rest of this page follows the recipe step by step and compares the choices at each step.
Step 1: make the spots stand out
Noise alone has a local maximum every few pixels, so the raw image is a poor map. A filter of the spot’s own shape collects the spot’s light from all of its pixels and averages the noise away. This is the matched filter: it gains about a factor \sqrt{\pi}\,\sigma/\text{pixel} in SNR. For a spot of σ = 1 px that is 1.8×, worth about three times the exposure time (spot-filters, B2).
The trouble is the background. A plain Gaussian sums to 1, so a bright background region raises the response there as much as a spot does. Filters that sum to zero (zero-mean Gaussian, LoG, DoG, à trous detail levels) ignore a constant or sloping background.

| Approach | Assumes | Costs | Fails when | Taught in |
|---|---|---|---|---|
| raw local maxima | spots brighter than every noise pixel | nothing | almost always: noise has a maximum every few pixels | spot-filters |
| Gaussian (matched filter) | known spot width, flat background | one separable blur | uneven background (false spots); a filter too wide merges close spots | spot-filters, kernels |
| zero-mean Gaussian, LoG, DoG | known width; background smooth over the filter | one or two blurs | background curved at the spot’s own scale; spots closer than about 2σ | spot-filters, scale-space |
| top-hat, then Gaussian | background wider than the structuring element | min and max filters | objects as large as the element; an element too small erodes spots | morph-grey |
| à trous multiscale product | spots live in a few dyadic scales; noise is white | a few smoothings with holes | spot sizes between the levels; dense clusters | spot-filters |
| LoG over many σ (blobs) | round blobs of unknown size | one filtered image per scale | elongated or touching blobs; sizes outside the scale range | scale-space, keypoints |
| Hessian determinant | blobs are curved both ways, ridges only one way | second derivatives per scale | noise (second derivatives amplify it); one scale per pass | hessian |
| learned heat map | training images like the test images | labelled data, training, a network | new microscope, new density, new background: domain shift | detection |
Choosing the width. All of these filters have a size. Make it about the spot’s own size σ (the PSF). A filter that is too narrow leaves the noise; one that is too wide merges close spots and drowns dim ones. When the size is unknown, search over scales, as the blob detectors do. Their peaks in σ give the size: a disc of radius r responds most at σ ≈ r/\sqrt 2.
Try it
The point detection day’s main demo: 80 spots on an uneven background. Switch between the presets and filters and watch the green (true), red (false) and yellow (missed) marks.
The same demo with questions is in the spot-filters exercise. In 1D: spots in 1D. Blobs over scales: scale-space demo.
Step 2: one candidate per peak
A local maximum is a pixel at least as large as everything in a window of radius r around it. The window decides how close two real points may be:
- too small: a noisy spot gets two candidates;
- too large: a dim spot next to a bright one is swallowed.
Other days use the same step under other names. The Hough day calls it non-maximum suppression in the accumulator. The modern deep learning day uses box NMS, which removes boxes that overlap a higher-scoring box (detection). h-maxima select peaks by their height above the saddle to a higher peak, whatever the distance (morph-reconstruct). The keypoint detector looks for maxima in three dimensions (x, y, \sigma) (keypoints).
| Rule | Keeps a peak if… | Good for | Fails when |
|---|---|---|---|
| local maximum, radius r | it is the largest within r | spots with a known minimum spacing | spacing varies; plateaus need a tie rule |
| h-maxima | it rises h above the saddle to any higher peak | peaks of varying spacing | h is in intensity units, not noise units |
| greedy box NMS | no higher-scoring box overlaps it by more than a set IoU | objects with extent | two real objects overlap more than the set limit |
| maxima in scale space | it beats its 26 neighbours in (x, y, \sigma) | blobs of unknown size | elongated structures (respond along their length) |
Step 3: which peaks are real?
A threshold must be stated in units of the noise of the response map, or it means nothing. Two steps are needed:
- Estimate the noise from the image itself. The median absolute deviation of fine differences is robust to the spots (spot-threshold, wavelet shrinkage).
- Carry it through the filter: a filter changes the noise level by a known factor, the root of the sum of its squared weights.
The surprise is how many false spots a “3 sigma” rule lets through. Smoothed noise has thousands of local maxima per image (4 898 per 512 × 512 image here), and a maximum is higher than a typical pixel. Multiplying the number of maxima by the 0.13 % tail probability of a Gaussian therefore underestimates the false spots by a factor of about 15 at k = 3.
So choose k from the number of false spots per image you can accept. With Poisson noise the noise grows with the brightness, so one threshold cannot serve the whole image. Use a variance-stabilising transform first, or a threshold that depends on the local mean (spot-threshold).
The same reasoning applies elsewhere. A Hough peak needs more votes than clutter gives by chance (hough-lines). A phase correlation peak needs to stand out from the noise floor of the surface (phasecorr: how much to trust a peak). A boosted detector tests hundreds of thousands of windows per image, so even a tiny false-positive rate per window gives false detections (viola-jones).
Step 4: exactly where?
The brightest pixel is good to ± half a pixel. Using the neighbouring pixels gets far better than that, and the methods differ in what they assume about the peak’s shape.
| Method | Assumes | Costs | Fails when | Taught in |
|---|---|---|---|---|
| brightest pixel | nothing | nothing | always ±0.5 px | spot-fit |
| centroid | background removed; small window | a weighted mean | background left in pulls it to the window centre | spot-fit, stitching |
| three-point parabola | the peak is locally quadratic | three samples per axis | biased towards whole pixels (“pixel locking”) | stitching, keypoints |
| parabola of the logarithm | the peak is Gaussian | three samples per axis | background not subtracted; noise in the low samples | spot-fit |
| least-squares fit of a PSF + background | a correct spot model | an iterative fit per spot | overlapping spots; wrong PSF model | spot-fit |
| maximum likelihood (Poisson) | photon counts and a correct model | an iterative fit | the same, but reaches the best possible precision | spot-fit |
How precise can it get? A spot built from N photons with PSF width s can be located to about s/\sqrt N. With 1 000 photons and s = 100 nm that is about 3 nm, far below the diffraction limit of about 250 nm. Localisation microscopy is built on this. Resolution (telling two points apart, resolution) and precision (placing one point, spot-fit) are different questions. Background photons and large pixels make the precision worse, and they dominate for dim spots, as the 0.77 px error of the dimmest spot in the first figure shows.
Step 5: crowded points, and is the list any good?
When two spots are closer than about twice their width they merge into one peak, and no threshold can split them. The options are to fit one model and two models and compare them, to deconvolve first, to treat the image as a sparse sum of PSFs, or to switch on only a few molecules at a time (spot-crowd).
To evaluate a detector, match each detection to at most one true point within a distance gate. Then report two kinds of error separately: detection (precision, recall, F1) and localisation (the error of the matched pairs). Optimal matching can beat greedy matching when points are dense. The same logic, with IoU in place of distance, scores objects (object-eval) and boxes (detection).
| Question | Tool | Taught in |
|---|---|---|
| which detection belongs to which true point? | one-to-one matching within a gate (assignment) | spot-crowd, object-eval |
| how many found, how many invented? | precision, recall, F1 at a threshold; the threshold sweep | spot-crowd, seg-eval |
| how well placed? | RMSE of matched pairs (truncated by the gate) | spot-crowd |
| is a point pattern clustered? | nearest-neighbour distances, Ripley’s K | point-patterns, ripley-k |
| which spot is which over time? | linking detections into tracks | track-linking |
All approaches at a glance
| Approach | Best when | Assumes | Main cost | Main failure |
|---|---|---|---|---|
| matched / zero-mean filter + maxima | spots of known size | one PSF, white noise, smooth background | one blur | merges close spots; uneven background (if not zero-mean) |
| scale-space LoG / DoG | blobs of unknown size | round blobs | one blur per scale | elongated or touching blobs |
| morphology (top-hat, h-maxima) | uneven background; peaks of varying spacing | shape of the background or a height h | min/max filters, reconstruction | parameters in intensity units, not noise units |
| correlation peaks (template, phase) | finding a shift or a known pattern | the pattern is a copy (shifted, maybe scaled) | FFTs | rotation, scale change, repeating patterns (several peaks) |
| Hough voting | lines, circles, shapes from edge points | a parametric shape | one accumulator cell per parameter combination | many parameters; clutter |
| PSF fitting | precision matters (localisation) | a correct PSF model | an iterative fit per spot | overlapping spots; wrong model |
| learned detectors | complex objects, many training images | test images like the training images | labels and training | domain shift; confident errors |
Every response map is a correlation with a template. Model a patch as I(\mathbf x) = A\,p(\mathbf x - \mathbf x_0) + n(\mathbf x) with white Gaussian noise of variance \sigma_n^2. The log-likelihood ratio of “a spot of shape p at \mathbf x_0” against “no spot”, maximised over the amplitude A, is
\Lambda(\mathbf x_0) = \frac{\big(\sum_{\mathbf x} p(\mathbf x - \mathbf x_0)\,I(\mathbf x)\big)^2}{2\sigma_n^2\sum_{\mathbf x} p^2},
a monotone function of the correlation (p \star I)(\mathbf x_0). So the best detector of a known shape is: correlate with the shape, take maxima, threshold. With an unknown constant background, replace p by p - \bar p (zero mean). The same structure appears elsewhere:
| Map | Template p | Image I |
|---|---|---|
| spot filter | the PSF | the image |
| template matching | the template (normalised) | the image |
| phase correlation | the other image, whitened (|\hat p| = 1 per frequency) | the image, whitened |
| Hough transform | the shape, in parameter space | the edge map |
The threshold is a statement about the noise of the map: the filtered noise has standard deviation \sigma_n\sqrt{\sum_k w_k^2}, and a threshold k in these units sets the false-alarm rate. For maxima of smoothed noise the expected number above u is about A\,u\,e^{-u^2/2}/\big(2\sigma_f^2(2\pi)^{3/2}\big) (spot-threshold).
Sub-pixel refinement fits a parabola to three samples L_{-1}, L_0, L_1 around the peak. Its vertex is at
\delta = \frac{L_{-1} - L_{1}}{2\,(L_{-1} - 2L_0 + L_{1})}.
On the raw values this is the three-point parabola. On L = \log I it is exact for a Gaussian peak, because the logarithm of a Gaussian is a parabola. In 3D (keypoints in x, y, \sigma) the same fit is a quadratic through the 3 × 3 × 3 cube. Under Poisson noise the best precision of any unbiased estimate is \mathrm{Var}(\hat x_0) \ge s^2/N (Cramér–Rao, spot-fit).
Demos on this topic
| Demo | What it shows |
|---|---|
| Spots in 1D | filter width, window, close pairs |
| Spot detection | filters against background, à trous, maxima window |
| How many false spots? | thresholds in noise units, false spots per image |
| Localising one spot | centroid, parabola, fit; precision against photons |
| Two spots and evaluating a detector | merging, matching, F1 |
| Blobs over scales | scale-normalised LoG, size from scale |
| The Hessian per pixel | blob, ridge, saddle |
| Top-hat on an uneven background | background removal by morphology |
| Reconstruction on images | h-maxima |
| Two points on a pixel grid | resolving against localising |
| Phase correlation and sub-pixel estimates | a shift as a peak |
| Line detection and circle detection | peaks of votes |
| The DoG pyramid | maxima in (x, y, \sigma), refinement |
| Boxes and suppression | NMS on boxes |
| Linking two frames | from detections to tracks |