CelScan
A desktop tool that measures foam cell size and anisotropy from microscope images and sends the results to the lab notebook.

CelScan measures the cell structure of foam from a microscope image of a cut sample. It runs as a desktop program on the lab PC, next to PIR-ELN: the image analysis happens locally, and only the results go to the notebook.
You open an image, calibrate the scale by drawing a line over the scale bar (calibrations per microscope and magnification are saved), optionally select a region, and press Analyse. The result is an overlay of every detected cell and a summary: mean and median cell size, spread (CV, D10, D90), cell density and anisotropy between the rise direction and the cross direction.
What was interesting to solve
- Separating cells. Walls are found with a threshold after flattening uneven lighting. A watershed then splits the walls between neighbouring cells. Interrupted walls tend to merge two cells into one, and a first version also cut long cells in two by mistake; a solidity check now decides when a narrowing really means two cells.
- Two measurements that check each other. Besides per-cell measurements, CelScan does an intercept count along parallel lines in both directions, following ASTM D3576. That gives a second, independent cell size and anisotropy ratio.
- Testing without real images. A generator makes fake foam with a known cell size, noise, uneven lighting, stretched cells and broken walls. On those images the mean diameter comes out within 2 to 3 percent of the true value. Tuning on real microscope photos is still to do.
- Hand correction. Users can delete, merge or split cells in the image, with undo, and the measurements update without re-segmenting.
Results can be sent straight to an experiment (as a new replicate) or a QC inspection in the notebook, with the source image, calibration and corrections attached.
The cover image shows synthetic test foam: raw on the left, the analysis overlay on the right.
Stack
Python, PySide6 (Qt), NumPy, SciPy, scikit-image, Matplotlib, pytest.