Tutorial 2: Detecting Colonies#

In Tutorial 1, you loaded a plate image and explored its accessors. Now let’s put that plate to work — we’ll detect the individual Rhodotorula colonies using PhenoTypic’s OtsuDetector.

What you will learn:

  1. Create an OtsuDetector and apply it to a plate image

  2. View the binary mask (objmask) and labeled object map (objmap)

  3. View the detection overlay on the original plate

  4. Count detected colonies

Imports#

[1]:
from phenotypic.data import load_yeast_plate
from phenotypic.detect import OtsuDetector

Load the Plate#

Let’s load our Rhodotorula yeast plate — the same one from Tutorial 1.

[2]:
plate = load_yeast_plate()

You can see the colonies as pigmented spots arranged in the 96-well grid. Our goal is to have PhenoTypic find each one automatically.

Create and Apply a Detector#

OtsuDetector finds a single intensity threshold that best separates colony pixels from background. It works by minimizing the variance within each group (colonies vs. agar), which makes it effective when the two populations have distinct brightness levels.

Creating and applying a detector takes two lines:

[3]:
detector = OtsuDetector()
plate = detector.apply(plate)

That’s it! The detector read from detect_mat, computed a threshold, and wrote the results into two new accessors on the plate:

  • ``objmask`` — a binary mask (True where colonies are, False for background)

  • ``objmap`` — a labeled map where each colony gets a unique integer (0 = background)

Let’s look at both.

White regions are colonies, black is background. This is useful for a quick sanity check — do the white patches line up with where you see colonies in the RGB image?

[4]:
plate.objmap.dash()

Data type cannot be displayed: application/vnd.plotly.v1+json

View the Detection Overlay#

The most useful quality-check is the overlay — the detected colonies drawn on top of the original RGB image. This lets you see at a glance whether the detection matches reality.

[5]:
plate.dash(overlay=True)

Data type cannot be displayed: application/vnd.plotly.v1+json

[6]:
plate.dash(overlay=True, show_labels=True)

Data type cannot be displayed: application/vnd.plotly.v1+json

Summary#

You’ve detected colonies on a real plate image using OtsuDetector and explored three ways to view the results:

  • ``objmask`` — binary colony mask

  • ``objmap`` — labeled colony map with unique IDs

  • overlay — colonies drawn on the original plate for visual validation

The detection may not be perfect — some faint colonies might be missed, or background artifacts might be picked up. In the next tutorial, you’ll learn how enhancing the detection matrix before detection can improve results.

Next up: Tutorial 3: Enhancing Before Detection