MWMartin Wassim
Return to Selected Work
ARCHITECTURAL DOSSIER // 2024—2026
PROJECT 09Computer Vision & Image SegmentationOpenCV & Watershed

NUMISVISION

Computer vision coin detection, marker-controlled watershed segmentation, and monetary valuation.

martinx.work/work/coin-counting
NUMISVISION Architectural Presentation
TIMELINE

2024 — 2026

DISCIPLINE

AI / Computer Vision

ROLE

Lead Software Architect

AFFILIATION

Systemize EG · Cairo

Core Runtime • Engineering Toolchain
PythonOpenCVNumPyWatershedOtsuMatplotlibSciPy
01 // Operational & Technical Friction

The Problem Space

Standard circle detection algorithms (like naive Hough Circle Transforms) fail catastrophically when coins overlap, touch, or exist under uneven ambient lighting with harsh metallic specular glares.

02 // The Architected Solution

Systemized Implementation

Formulated a robust multi-stage segmentation pipeline using Gaussian blurring, comparative Otsu vs adaptive thresholding, Euclidean distance transforms to identify local maxima centers, and marker-controlled watershed segmentation to partition merged contours with high geometric precision.

03 // Production Implementation & Workflow

How It Operates in Production

Built in Python using OpenCV, NumPy, and SciPy. The pipeline ingests high-resolution images, computes morphological gradients to preserve boundaries, calculates distance transform relief maps, and seeds watershed markers at local Euclidean peaks.

Engineering Depth

Engineered automatic contour area calibration converting pixel diameters into exact physical coin denominations (10, 25, 50 piastres, and 1 pound), computing total currency value with rigorous error metrics.

04 // Architectural Flow & State MachineBespoke Pipeline
IMAGE PROCESSING

NUMISVISION // WATERSHED OVERLAPPING CONTOUR PARTITIONING

OPENCV 4.0 • HIGH-ACCURACY VISION
STEP 01 // PRE-PROCESSING

Bilateral Edge-Preserving Filter

Eliminates high-frequency surface scratches on metallic coins while maintaining pristine circular perimeter gradients.

NODE 01ONLINE
STEP 02 // BINARIZATION

Otsu vs. Adaptive Thresholding

Dynamically splits illumination variations and eliminates specular reflections from metal surfaces.

NODE 02ONLINE
Core Innovation
STEP 03 // DISTANCE TRANSFORM

Euclidean Topological Map

Computes metric distance from every foreground pixel to background boundary, detecting unique local maxima seeds.

NODE 03VERIFIED
STEP 04 // WATERSHED

Marker-Controlled Segmentation

Floods basins from topological seeds to cleanly divide overlapping coins into discrete contour polygons.

NODE 04ONLINE

Data Flow & Infrastructure

Raw images undergo bilateral edge-preserving smoothing followed by adaptive thresholding. The binary mask passes through distance transformation to isolate core centers. Watershed segmentation floods outward from peaks, separating boundaries cleanly before passing contours to the denomination classifier.

Architectural Highlight

Euclidean distance transforms coupled with marker-controlled watershed segmentation partition merged contours where naive Hough circle transforms fail.

05 // Key Engineering Decisions
Marker-controlled watershed over Hough Circles: Distance transform peaks provide deterministic seed markers that naturally separate touching circular bodies without circular deformation assumptions.
Morphological closure preprocessing: Applied elliptical structuring elements to seal interior specular voids caused by bright laboratory and smartphone flash reflections.
Calibrated denomination mapping: Evaluated bounding diameter ratios against known physical Egyptian currency dimensions for multi-coin classification.
06 // Challenges & Mitigations
Handling touching coins with overlapping shadows and edge occlusion.
Eliminating false positive markers caused by ornate coin face reliefs and engravings.
07 // Verified Capabilities

Core System Features

Gaussian and bilateral image filtering for noise suppression and edge preservation
Comparative Otsu global variance vs. local adaptive thresholding benchmarking
Morphological opening and closing kernels eliminating specular glare voids
Topographical distance transform generating markers for overlapping coin segmentation
Calibrated pixel-to-millimeter ratio classifying coin denominations and summing total currency
Evaluated across variable lighting datasets with MAE, RMSE, and count accuracy metrics