Skip to main content

wellcrop

A lightweight computer vision utility for automated detection, alignment, and extraction of individual wells from multi-well plate scans.


Highlights

  • 🔍 Shift & Skew Tolerant: Accommodates hand-placed plates on flatbed scanners via directional gradient edge snapping and 2D affine grid estimation.
  • 🎯 Hough Ring Locking: Snaps analytic well centers to physical plastic rims via localized Hough circle transforms.
  • ✂️ Automatic Masking: Crops and isolates pure circular wells, shaving off outer plastic rims and blacking out corners.
  • 🪶 Zero Heavy AI Dependencies: No PyTorch, CUDA, or model weights required. Built purely on numpy, opencv-python, and scipy.

Installation

pip install wellcrop

Quickstart

import tifffile as tifi
import wellcrop

# 1. Load scan image
image = tifi.imread("plate_scan.tif")

# 2. Define ROI hints (fractions in [0, 1] drawn once on a reference scan)
roi_hints = [
    {"x": 0.05, "y": 0.08, "w": 0.40, "h": 0.84, "rows": 3, "cols": 2, "letter": "A"}
]

# 3. Detect & extract well crops
detector = wellcrop.PlateDetector(margin_frac=0.20)
wells = detector.crop(image, roi_hints=roi_hints)

# 4. Access individual well crops and metadata
for well in wells:
    print(f"Well {well.label}: center=({well.x}, {well.y}), radius={well.radius}px")
    # well.image is a circular-masked NumPy RGB array
    well.save(f"output/{well.label}.png")

Visual QA Overlay

Generate diagnostic overlays (showing padded search boxes, detected plate boxes, and snapped well rings):

import cv2

# Draw overlay directly onto the scan
overlay = wellcrop.draw_overlay(image, wells, roi_hints=roi_hints)
cv2.imwrite("grid_preview.png", cv2.cvtColor(overlay, cv2.COLOR_RGB2BGR))

How it Works

  1. ROI-Scoped Search: Expands the user's initial approximate plate bounding box by margin_frac to absorb scanner placement shift.
  2. Directional Edge Snapping: Projects Sobel gradients along vertical and horizontal axes to find true plate walls, reconciling them under rigid geometry constraints.
  3. Stacked Plate Reconciliation: Identifies shared dividing ribs for multi-tray formats so vertically stacked plates never overlap.
  4. Grid Estimation & Ring Snapping: Computes analytic well centers, locks physical rims with local Hough circle searches, and fits a 2D affine transform to absorb plate rotation.
  5. Rim Trimming & Masking: Shaves outer plastic rims and masks corners so downstream analyzers only see pure well contents.

License

MIT License. See LICENSE for details.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wellcrop-0.1.0.tar.gz (157.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wellcrop-0.1.0-py3-none-any.whl (18.3 kB view details)

Uploaded Python 3

File details

Details for the file wellcrop-0.1.0.tar.gz.

File metadata

  • Download URL: wellcrop-0.1.0.tar.gz
  • Upload date:
  • Size: 157.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for wellcrop-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9dd467035d17ed62c71505755f7d1bcf9690f478a7b01a8319a8a07bc916273b
MD5 e8f358e2328d5a90c59faa750043ec6f
BLAKE2b-256 f6c8bc478d33d2f7ae002972af552ccfa780af0f73b23984236c040afad58c56

See more details on using hashes here.

File details

Details for the file wellcrop-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: wellcrop-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for wellcrop-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bc406d167d8ff233dc16a7ef898c5d0831d622c9b8a1198a3ce4ff8590e17a43
MD5 cba9560c6352d1c3f40d73f8e1316006
BLAKE2b-256 1ea04106404377b4c9548ce4928aefc1f245fbc2a1a2a4e4f3df930d8387c9d2

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page