🚀 Jumpstart 2027: Custom, Secure AI Workflows to Adopt Now. Reserve your spot →

Chris Parmer

Chris Parmer

November 14, 2026

scikit-image demo

Image processing and analysis in Python, with Dash and Plotly

TL;DR

  • scikit-image is the image processing library of scientific Python: filters, thresholds, segmentation, registration and measurement on NumPy arrays. StĂ©fan van der Walt started it in 2009, and its community maintains it today.
  • Scientists and engineers use it to turn pictures into tables, whether the pictures come from a microscope, a rock core scanner, a satellite or a camera on an inspection line.
  • This demo walks through the core workflow (adjust contrast, threshold, split touching objects, outline them and measure them) on a public cell imaging screen, then runs it live in a Dash app.
  • Version 0.26 (December 20, 2025) adds intensity_median to regionprops, clearer max_size thresholds and from_estimate constructors, and it drops Python 3.10.
Three microscope images of MCF-7 breast cancer cells with nuclei outlined in yellow and cells in white: 225 nuclei in an untreated field, 88 after 3 ”M taxol and 119 after 30 ”M cytochalasin B, which leaves cells with two nuclei

What is scikit-image?

A lot of science and engineering now arrives as pictures. Drug discovery teams photograph millions of cells, geoscientists scan rock cores to measure pores and grains, materials labs image metal and battery microstructures, and factories photograph every part that leaves the line. The pictures only become data once you find the objects in them and measure each one, which stops working by hand after a few hundred images.

scikit-image does that work in Python. It treats an image as a NumPy array, so it fits into the same code as your tables and models, and it gives you well-tested textbook methods: exposure and color adjustments, filters and denoising, thresholds, morphology, watershed and other segmentation, feature detection, registration, and measurements of every labeled object. It handles 3D stacks and multichannel images as well as ordinary photos, and imaging tools like napari and CellProfiler build on it. Its gallery of examples is one of the best places to see the range.

The same few steps come up in almost every field, so this demo shows them on one dataset where the result is easy to check by eye: cells under a fluorescence microscope. For the other packages we use in Dash apps, see our guide to Python packages for data.

The data: 240 fields of view from a public drug screen

BBBC021, from the Broad Bioimage Benchmark Collection, is a compound profiling experiment by AstraZeneca (Caie et al., 2010). MCF-7 breast cancer cells were treated with small molecules at several doses, stained for DNA, F-actin and ÎČ-tubulin, and photographed under a fluorescence microscope. We used one of its 55 plates: 240 fields of view covering six compounds at eight doses, plus untreated controls that only got the solvent (DMSO).

Each field is three 16-bit grayscale TIFFs, one per stain, and a CSV maps each field to its well, compound and dose. ski.io.imread reads each one as a NumPy array.

Compound

What it does to cells

DMSO

Nothing, it's the solvent

taxol

Freezes microtubules, so cells can't divide

nocodazole

Takes microtubules apart, so cells can't divide

aphidicolin

Stops DNA copying

cytochalasin B

Blocks actin, so cells split their nucleus but not themselves

Here are the raw pixel values of one untreated field, one panel per stain: DNA shows the nuclei, tubulin the fibers that hold each cell's shape, and actin the cell edges.

Three grayscale heatmaps of raw 16-bit pixel values in the top-left 640 by 512 pixels of an untreated field: the DNA stain shows about 55 oval nuclei with values up to about 4,000, tubulin shows fibrous cell bodies up to about 18,000 and actin shows cell outlines up to about 8,000

Five things you can do with scikit-image

1. Adjust contrast so you can see the objects

Scientific cameras record far more levels than a screen shows, so raw images often look almost black. rescale_intensity stretches each channel to fill the display.

Two views of the same untreated cells: on the left, the raw values on the full 16-bit scale look nearly black with faint green; on the right, after rescale_intensity, nuclei are blue, tubulin green and actin red
lo, hi = np.percentile(img, (0.5, 99.8))
stretched = ski.exposure.rescale_intensity(img, in_range=(lo, hi), out_range=(0.0, 1.0))

Stretching between percentiles rather than the minimum and maximum keeps a few very bright pixels from washing out the rest.

2. Find objects with an automatic threshold

Otsu's method picks the brightness that best separates objects from background, and label gives each connected blob its own number.

Left, the DNA stain of untreated cells; right, the same area with each object found by the threshold in its own color: 55 objects in this quarter and 203 in the whole field of view
smooth = ski.filters.gaussian(dna, sigma=2, preserve_range=True)
mask = smooth > ski.filters.threshold_otsu(smooth)
mask = ski.morphology.remove_small_objects(mask, max_size=59) # new in 0.26: drop specks of 59 pixels or fewer
labels = ski.measure.label(mask)

This works for any bright objects on a dark background, from nuclei to pores in a scanned core. Some blobs are two objects touching, which the next step fixes.

3. Separate touching objects with a watershed

The watershed floods each blob from a marker at the center of every object and draws a line where the floods meet. The distance transform supplies the markers, because it's highest at the middle of round objects.

Two panels of the same field of cells treated with 30 ”M cytochalasin B: with the threshold only there are 72 objects, many shaped like peanuts; after the watershed there are 119 nuclei, with each peanut split in two
from scipy import ndimage as ndi
dist = ndi.distance_transform_edt(mask)
peaks = ski.feature.peak_local_max(dist, min_distance=7, labels=labels)
markers = np.zeros(dist.shape, dtype=np.int32)
markers[tuple(peaks.T)] = np.arange(1, len(peaks) + 1)
nuclei = ski.segmentation.watershed(-dist, markers, mask=mask)

Cytochalasin B stops dividing cells from pinching in two, so many nuclei sit in pairs, and the watershed splits each pair.

4. Grow regions outward from seeds

A second watershed, this time on the actin and tubulin signal, grows each cell outward from its nucleus until it meets its neighbors. Seeded growth like this is also how you outline grains around their centers or plants around their stems.

Left, untreated cells in color; right, the same cells with a white outline around each cell and a yellow outline around each nucleus
cells = ski.segmentation.watershed(-cyto, nuclei, mask=foreground)

Yellow lines are nuclei and white lines are cells. A cell with two nuclei gets split between them, so count nuclei for treatments like cytochalasin B.

5. Measure every object and compare groups

regionprops_table measures every labeled object and returns columns ready for pandas. Running the four steps on all 240 fields gave a table of 33,001 cells to compare across compounds and doses.

Two line charts against drug concentration on a log scale: nuclei per field of view falls from the untreated 208 to 30 for taxol at 0.01 ”M and to about 80 for nocodazole from 0.03 ”M, while cytochalasin B rises to 251 at 1 ”M before falling; median nucleus area rises from the untreated 852 pixels to about 1,240 for aphidicolin at 1 ”M and falls to 555 for cytochalasin B at 30 ”M
props = ski.measure.regionprops_table(
nuclei, intensity_image=dna,
properties=["label", "area", "eccentricity", "solidity", "intensity_mean", "intensity_median"])
df = pd.DataFrame(props)

The compounds that stop cell division leave fewer nuclei per field, and the one that stops DNA copying leaves bigger nuclei, which is the kind of dose response a screening team looks for.

What's possible

When you build an imaging app with a coding agent, these are the scikit-image capabilities to name, in plain words:

  • Read images: ski.io.imread for TIFF, PNG and JPEG, as NumPy arrays.
  • Fix contrast and noise: exposure.rescale_intensity, exposure.equalize_adapthist and restoration.denoise_nl_means.
  • Find objects: filters.threshold_otsu or filters.threshold_local, then morphology.remove_small_objects and measure.label.
  • Split touching objects: feature.peak_local_max on a distance transform, then segmentation.watershed.
  • Measure them: measure.regionprops_table for area, shape and brightness, and measure.find_contours for outlines.
  • Line images up: registration.phase_cross_correlation to correct drift between frames or channels.

Other apps you can build with scikit-image

  • Rock core pore analyzer: threshold a core scan and measure pore size and porosity with regionprops.
  • Defect counter for an inspection line: compare each part with a reference image and label the differences.
  • Materials grain size tool: watershed a micrograph into grains and plot the size distribution.
  • Satellite field mapper: segment fields or water bodies from an image band and measure their areas.
  • Histology slide browser: separate stains with color.rgb2hed and count cells per tissue region.
  • Time-lapse tracker: register frames and follow labeled objects as they move or grow.

What's new in scikit-image 0.26

Version 0.26 came ten months after 0.25.2, with 237 commits from more than 30 contributors:

  • intensity_median in regionprops, which a few very bright pixels barely move.
  • max_size in remove_small_objects and remove_small_holes, which removes objects of n pixels or fewer and replaces the easy-to-misread min_size and area_threshold.
  • from_estimate constructors, such as AffineTransform.from_estimate(src, dst), instead of an empty object plus .estimate().
  • Faster moments_central on 3D images, about 38 times faster on a 3D stack in our test.
  • One set of morphology functions: binary_erosion and friends are deprecated in favor of erosion, dilation, opening and closing.

Before you upgrade, note that Python 3.10 is gone, transform constructors are keyword-only (other than matrix), and the shift_x, shift_y and image2 parameters are removed. Everything else warns and names its replacement, and the release notes list the rest. On our plate, 0.25.2 and 0.26 found the same cells, pixel for pixel.

Demo App: Screen Lab

We built a Dash app called Screen Lab on the same plate, so a scientist can browse the whole screen and then retune the segmentation on any well.

Screen Lab Plate tab: a plate map of 60 wells in rows B to G and columns 2 to 11 colored by nuclei per field, next to dose-response lines for taxol, nocodazole, aphidicolin and cytochalasin B with the untreated level as a dotted line

The Plate tab colors each well by a measurement you pick and draws the dose response, which is how you spot the wells worth a closer look. Clicking a well opens it in the Segment tab.

Screen Lab Segment tab on well B03, cytochalasin B 30 ”M: sliders for smoothing, smallest nucleus and watershed min_distance; cards show 36 nuclei with 23 before the watershed, an Otsu threshold of 2,103, a median nucleus area of 556 pixels against 852 untreated, and 96 ms to segment and measure; the image shows nuclei and cell outlines and a scatter plots each nucleus's area against its intensity_median

The Segment tab reruns the whole pipeline in a callback on every slider move, so you can see how each setting changes the result before you apply it to the plate.

Screen Lab Segment tab with the before-watershed outlines in pink, showing pairs of nuclei inside one outline before they are split

A "before watershed" switch shows which blobs the watershed split, which is the quickest way to check min_distance.

Screen Lab Cells tab: 5,800 cells treated with cytochalasin B, plotted by nucleus area against DNA intensity_median and colored from light to dark purple by dose, over untreated cells in grey; the highest doses form a cloud of smaller, brighter nuclei

The Cells tab plots every cell for one compound against the untreated cells, so a shift with dose stands out.

Running scikit-image on Plotly Cloud and Dash Enterprise

What we learned deploying Screen Lab applies the same way on Dash Enterprise:

  • Measure the whole image set ahead of time. The app ships the table of every cell as a small Parquet file instead of segmenting 240 fields when someone opens the page.
  • Ship crops, not raw images. One crop per well keeps the app small and fast to load, and it's all the Segment tab needs.
  • Segment in the callback. One crop took under 200 ms, fast enough for every slider move without a background job.

If your images are large gridded arrays such as satellite scenes, our NumPy demo covers the array side.

Prompts to build it yourself

The five charts:

Prompt: Download plate Week1_22123 and BBBC021_v1_image.csv from BBBC021. With scikit-image 0.26 and Plotly: stretch each stain with rescale_intensity; threshold_otsu the smoothed DNA channel, remove_small_objects(max_size=59), label; split touching nuclei with peak_local_max on the distance transform and watershed; grow cells from nuclei with a watershed on actin + tubulin; regionprops_table for every nucleus and cell. Show steps 1-4 as image panels and a dose-response chart of nuclei per field and median nucleus area.

The Screen Lab app:

Prompt: Build a Dash app called Screen Lab on the same plate. Offline: measure all 240 fields to Parquet and save a 640 x 512 crop per well as .npz. Tabs: Plate (plate-map heatmap plus dose-response lines; click a well to open it), Segment (sliders for sigma, smallest nucleus and min_distance; rerun the segmentation in the callback and show outlines, cards and an area vs intensity_median scatter), Cells (every cell for one compound, colored by dose). Inter, light theme, Plotly purple.

FAQ

bluesly
x
instagram
youtube
medium
fcaebook

Product

© 2026
Plotly. All rights reserved.
Cookie Preferences
aicpa/soc2