# reiko0908/mod3d architecture

> Architecture diagram of the GitHub repository reiko0908/mod3d, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/reiko0908/mod3d
- Repository: https://github.com/reiko0908/mod3d

## Overview

MOD3D is a research implementation of moving-object detection from image pairs, using dominant motion alignment and, where needed, multiple planar layers to distinguish parallax from independent motion. The workflow aligns inspection images to a reference, identifies shared misaligned regions, estimates local layer motion, tests rigidity, and returns motion masks and scores. The sampled source is partial, so this map shows only relationships visible in the excerpt; major algorithm stages documented in the README are retained where supported.

Main entry points: [`mod_3d.py`](https://github.com/reiko0908/mod3d/blob/main/mod_3d.py) (Detection pipeline)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_alignment["Motion alignment"]
  node_dominant["Dominant motion<br/>[mod_3d.py]"]
  node_optimizer["Gauss-Newton alignment<br/>[mod_3d.py]"]
  node_warp["Frame warping<br/>[mod_3d.py]"]
end

subgraph group_layers["Layer analysis"]
  node_regional["Regional alignment<br/>[mod_3d.py]"]
  node_parallax["Parallax estimate<br/>[mod_3d.py]"]
  node_rigidity["Rigidity test<br/>[mod_3d.py]"]
end

subgraph group_detection["Motion detection"]
  node_pipeline["Detection pipeline<br/>[mod_3d.py]"]
  node_misalignment["Misalignment map<br/>[mod_3d.py]"]
  node_masking["Region masks<br/>[mod_3d.py]"]
  node_result["Detection result<br/>[mod_3d.py]"]
end

node_images(("Image pair"))

node_images -->|"provides frames"| node_pipeline
node_pipeline -->|"estimates motion"| node_dominant
node_dominant -->|"initializes"| node_optimizer
node_pipeline -->|"aligns frames"| node_warp
node_pipeline -->|"maps differences"| node_misalignment
node_pipeline -->|"cleans regions"| node_masking
node_pipeline -->|"aligns regions"| node_regional
node_regional -->|"fits local motion"| node_optimizer
node_pipeline -->|"estimates parallax"| node_parallax
node_pipeline -->|"tests consistency"| node_rigidity
node_pipeline -->|"returns masks"| node_result

click node_pipeline "https://github.com/reiko0908/mod3d/blob/main/mod_3d.py"
click node_dominant "https://github.com/reiko0908/mod3d/blob/main/mod_3d.py"
click node_optimizer "https://github.com/reiko0908/mod3d/blob/main/mod_3d.py"
click node_warp "https://github.com/reiko0908/mod3d/blob/main/mod_3d.py"
click node_misalignment "https://github.com/reiko0908/mod3d/blob/main/mod_3d.py"
click node_masking "https://github.com/reiko0908/mod3d/blob/main/mod_3d.py"
click node_regional "https://github.com/reiko0908/mod3d/blob/main/mod_3d.py"
click node_parallax "https://github.com/reiko0908/mod3d/blob/main/mod_3d.py"
click node_rigidity "https://github.com/reiko0908/mod3d/blob/main/mod_3d.py"
click node_result "https://github.com/reiko0908/mod3d/blob/main/mod_3d.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_dominant,node_optimizer,node_warp toneBlue
class node_regional,node_parallax,node_rigidity toneAmber
class node_pipeline,node_misalignment,node_masking,node_result toneMint
class node_images toneIndigo
```

## Components

### Motion alignment

- [Dominant motion](https://github.com/reiko0908/mod3d/blob/main/mod_3d.py): `mod_3d.py`
- [Gauss-Newton alignment](https://github.com/reiko0908/mod3d/blob/main/mod_3d.py): `mod_3d.py`
- [Frame warping](https://github.com/reiko0908/mod3d/blob/main/mod_3d.py): `mod_3d.py`

### Layer analysis

- [Regional alignment](https://github.com/reiko0908/mod3d/blob/main/mod_3d.py): `mod_3d.py`
- [Parallax estimate](https://github.com/reiko0908/mod3d/blob/main/mod_3d.py): `mod_3d.py`
- [Rigidity test](https://github.com/reiko0908/mod3d/blob/main/mod_3d.py): `mod_3d.py`

### Motion detection

- [Detection pipeline](https://github.com/reiko0908/mod3d/blob/main/mod_3d.py): `mod_3d.py`
- [Misalignment map](https://github.com/reiko0908/mod3d/blob/main/mod_3d.py): `mod_3d.py`
- [Region masks](https://github.com/reiko0908/mod3d/blob/main/mod_3d.py): `mod_3d.py`
- [Detection result](https://github.com/reiko0908/mod3d/blob/main/mod_3d.py): `mod_3d.py`

### Other components

- **Image pair**

## Connections

- Image pair → Detection pipeline: provides frames (evidence: `mod_3d.py`)
- Detection pipeline → Dominant motion: estimates motion (evidence: `mod_3d.py`)
- Dominant motion → Gauss-Newton alignment: initializes (evidence: `mod_3d.py`)
- Detection pipeline → Frame warping: aligns frames (evidence: `mod_3d.py`)
- Detection pipeline → Misalignment map: maps differences (evidence: `mod_3d.py`)
- Detection pipeline → Region masks: cleans regions (evidence: `mod_3d.py`)
- Detection pipeline → Regional alignment: aligns regions (evidence: `mod_3d.py`)
- Regional alignment → Gauss-Newton alignment: fits local motion (evidence: `mod_3d.py`)
- Detection pipeline → Parallax estimate: estimates parallax (evidence: `mod_3d.py`)
- Detection pipeline → Rigidity test: tests consistency (evidence: `mod_3d.py`)
- Detection pipeline → Detection result: returns masks (evidence: `mod_3d.py`)
