Building a Vision System Pipeline: Lessons from Monet's Observation Method

    A practical guide to building a computer vision pipeline. Learn how to define scene samples, design layered architectures with data contracts, and run versioned experiments inspired by Claude Monet's method of controlled observation. Includes Python code and field-level compatibility strategies.

    1. Define Scene Samples First, Then Talk About Algorithms

    When Monet painted the same stretch of water, he focused on the overall relationship between light and color rather than fixed outlines. In engineering terms, this means the requirements phase should answer three questions first: which environmental variables change the observation, which viewpoints and capture parameters will be used, and which quality dimensions must be recorded. If a requirement is written only as “detect an object,” the team will be unable to pinpoint which layer failed once the system goes live and encounters lighting changes, occlusion, or hardware differences.

    A good practice is to define a single observation as a SceneSample. Every field should specify its type, unit, and value range. Missing values should be uniformly represented as None—never as 0—otherwise downstream components will treat “unknown” as “genuinely zero.”

    1. from dataclasses import dataclass
    2. from typing import Optional, Protocol
    3. import numpy as np
    4. class FeatureError(Exception):
    5. """A known failure type in the feature layer; the caller decides whether to degrade."""
    6. @dataclass(frozen=True)
    7. class Lighting:
    8. intensity_lux: float # Illuminance in lux, range [0, 100000]
    9. color_temp_k: float # Color temperature in K, range [2000, 10000]
    10. direction_deg: Optional[float] # Dominant light direction in degrees, range [0, 360); None if unestimable
    11. @dataclass(frozen=True)
    12. class Capture:
    13. width: int # Image width in pixels
    14. height: int # Image height in pixels
    15. exposure_ms: float # Exposure time in milliseconds
    16. noise_sigma: Optional[float] # Estimated noise standard deviation; None if not estimated
    17. color_space: str # Enum, e.g. "sRGB", "Rec.709"
    18. @dataclass(frozen=True)
    19. class SceneSample:
    20. sample_id: str # Globally unique; UUID v4 recommended; immutable after creation
    21. timestamp_utc: str # ISO 8601 format, e.g. "2026-11-24T06:17:13Z"
    22. lighting: Optional[Lighting]
    23. capture: Capture
    24. roi: tuple[int, int, int, int] # Region of interest (x, y, w, h) in pixel coordinates
    25. dataset_version: str # Dataset version, following MAJOR.MINOR.PATCH
    26. class Feature(Protocol):
    27. name: str
    28. version: str
    29. def extract(self, image: np.ndarray, light: Optional[Lighting]) -> np.ndarray: ...
    30. @dataclass
    31. class ColorLayer:
    32. layer_id: str # Suggested format: "{sample_id}:{feature_name}:{feature_version}"
    33. feature_name: str
    34. feature_version: str
    35. data: Optional[np.ndarray] # None on failure
    36. confidence: float # Range [0, 1]
    37. status: str # "ok" | "failed" | "skipped"
    38. error: Optional[str] = None
    39. def estimate_lighting(image: np.ndarray) -> tuple[Optional[Lighting], float]:
    40. """Returns the lighting estimate and its confidence. Returns (None, 0.0) if unestimable."""
    41. ...
    42. def build_layers(sample: SceneSample, image: np.ndarray,
    43. pipeline: list[Feature]) -> list[ColorLayer]:
    44. if image.ndim not in (2, 3):
    45. raise ValueError(f"image must be 2- or 3-dimensional, got {image.ndim}")
    46. base = normalize(image, sample.capture) # Project function: denoise and convert to a unified color space
    47. light, light_conf = estimate_lighting(base)
    48. if light is None:
    49. light_conf = 0.0 # Continue with unknown lighting, but flag it in the quality layer
    50. layers = []
    51. for feature in pipeline:
    52. layer_id = f"{sample.sample_id}:{feature.name}:{feature.version}"
    53. try:
    54. data = feature.extract(base, light)
    55. layers.append(ColorLayer(layer_id, feature.name, feature.version,
    56. data, light_conf, "ok"))
    57. except FeatureError as exc: # A single feature failure does not halt the pipeline
    58. layers.append(ColorLayer(layer_id, feature.name, feature.version,
    59. None, 0.0, "failed", str(exc)))
    60. return layers

    Three points in this code are key. First, input validation happens at the pipeline entry. Second, when lighting estimation fails, the pipeline keeps running with confidence lowered to 0, and the quality layer handles it centrally. Third, individual feature failures are isolated, so results from other layers remain usable.

    2. Layered Architecture and Data Contracts: What Connects the Layers

    Layering exists so that components can be replaced locally. If lighting estimation becomes unstable, you swap only the estimation module without touching the decision layer. To achieve this, adjacent layers must be connected by stable data contracts. The table below lists the inputs, outputs, and mandatory constraints for each layer.

    Layer Input Output Mandatory Constraints
    Capture & Preprocessing Raw image, Capture Normalized image Unified color space; denoising parameters written into sample metadata
    Feature Normalized image, Lighting List of ColorLayer Each feature carries name and version; failures must set status
    Decision List of ColorLayer Result and confidence Confidence must be within [0, 1]; out-of-range values rejected outright
    Quality Decision results, sample annotations Metrics and alerts Metrics grouped by lighting and device, not just overall averages

    Field-level contracts should be documented just as precisely. The table below works well for interface handoffs across teams.

    Field Type Required Compatibility Policy
    sample_id string Yes Immutable; any content change requires a new sample_id
    dataset_version string Yes Adding fields is a MINOR upgrade; deleting or redefining is a MAJOR upgrade
    color_space enum Yes When new enum values are added, legacy consumers must treat unknown values as failed
    confidence float, range [0, 1] Yes Out-of-range records are rejected outright and logged
    status enum Yes Same as above; unknown values degrade to failed

    The key point in the compatibility column: fields may only be added, never silently redefined. Redefinition causes older consumers to produce wrong results without raising errors—this is the hardest class of bug to debug.

    3. Versioned Experiments: Controlled Comparison, the Way Monet Painted Series

    Monet painted series around a single subject, changing exactly one condition per painting, so differences could be attributed. Engineering experiments should follow the same principle. Change only one factor per experiment—such as the preprocessing version, feature combination, or threshold—and keep everything else fixed. Experiment results must be traceable to specific dataset versions,