# jacob-424/sg2-images architecture

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

- Interactive diagram: https://gitdiagram.com/jacob-424/sg2-images
- Repository: https://github.com/jacob-424/sg2-images

## Overview

SG2 is a command-line ballot-image processor: it validates a PNG, locates two plus-shaped markers, checks horizontal alignment, translates the image, and reports image statistics. The main implementation is consolidated in SG2.py; the tree also contains standalone versions of validation, detection, and translation, plus ballot-image generators. The excerpts show some implementation details but omit much of SG2.py’s main control flow, so uncertain stage connections are marked unverified rather than asserted.

Main entry points: [`SG2.py`](https://github.com/jacob-424/sg2-images/blob/main/SG2.py) (SG2 Workflow), [`Image_Translation.py`](https://github.com/jacob-424/sg2-images/blob/main/Image_Translation.py) (Image Translator), [`pngGen.py`](https://github.com/jacob-424/sg2-images/blob/main/pngGen.py) (Binary Ballot Generator), [`grayScalePngGen.py`](https://github.com/jacob-424/sg2-images/blob/main/grayScalePngGen.py) (Grayscale Ballot Generator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_processing["Ballot Processing"]
  node_main["SG2 Workflow<br/>[SG2.py]"]
  node_validation["PNG Validation<br/>[SG2.py]"]
  node_grayscale["Grayscale Conversion<br/>[SG2.py]"]
  node_detection["Marker Detection<br/>[SG2.py]"]
  node_alignment["Alignment Check<br/>[SG2.py]"]
  node_translation["Image Translation<br/>[SG2.py]"]
  node_balloty["BallotY Image<br/>[SG2.py]"]
  node_statistics["Image Statistics<br/>[SG2.py]"]
  node_grayness["Grayness Labels<br/>[SG2.py]"]
end

subgraph group_standalone["Standalone Modules"]
  node_validator_module["PNG Validator"]
  node_detector_module["Pattern Detector"]
  node_translator_module["Image Translator"]
end

subgraph group_generation["Image Generation"]
  node_generator_binary["Binary Ballot Generator<br/>[pngGen.py]"]
  node_generator_gray["Grayscale Ballot Generator<br/>[grayScalePngGen.py]"]
end

node_user(("Operator"))

node_user -->|"runs"| node_main
node_main -->|"calls"| node_validation
node_main -.->|"uses"| node_grayscale
node_main -.->|"uses"| node_detection
node_main -.->|"uses"| node_alignment
node_main -.->|"uses"| node_translation
node_main -.->|"uses"| node_statistics
node_statistics -->|"calls"| node_grayness
node_translation -->|"saves"| node_balloty
node_translator_module -->|"imports"| node_validator_module
node_generator_binary -.->|"generates"| node_user
node_generator_gray -.->|"generates"| node_user

click node_main "https://github.com/jacob-424/sg2-images/blob/main/SG2.py"
click node_validation "https://github.com/jacob-424/sg2-images/blob/main/SG2.py"
click node_grayscale "https://github.com/jacob-424/sg2-images/blob/main/SG2.py"
click node_detection "https://github.com/jacob-424/sg2-images/blob/main/SG2.py"
click node_alignment "https://github.com/jacob-424/sg2-images/blob/main/SG2.py"
click node_translation "https://github.com/jacob-424/sg2-images/blob/main/SG2.py"
click node_balloty "https://github.com/jacob-424/sg2-images/blob/main/SG2.py"
click node_statistics "https://github.com/jacob-424/sg2-images/blob/main/SG2.py"
click node_grayness "https://github.com/jacob-424/sg2-images/blob/main/SG2.py"
click node_validator_module "https://github.com/jacob-424/sg2-images/blob/main/Png_input_and_validation.py"
click node_detector_module "https://github.com/jacob-424/sg2-images/blob/main/patternDetection.py"
click node_translator_module "https://github.com/jacob-424/sg2-images/blob/main/Image_Translation.py"
click node_generator_binary "https://github.com/jacob-424/sg2-images/blob/main/pngGen.py"
click node_generator_gray "https://github.com/jacob-424/sg2-images/blob/main/grayScalePngGen.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_main,node_validation,node_grayscale,node_detection,node_alignment,node_translation,node_balloty,node_statistics,node_grayness toneBlue
class node_validator_module,node_detector_module,node_translator_module toneAmber
class node_generator_binary,node_generator_gray toneMint
class node_user toneIndigo
```

## Components

### Ballot Processing

- [SG2 Workflow](https://github.com/jacob-424/sg2-images/blob/main/SG2.py): `SG2.py`
- [PNG Validation](https://github.com/jacob-424/sg2-images/blob/main/SG2.py): `SG2.py`
- [Grayscale Conversion](https://github.com/jacob-424/sg2-images/blob/main/SG2.py): `SG2.py`
- [Marker Detection](https://github.com/jacob-424/sg2-images/blob/main/SG2.py): `SG2.py`
- [Alignment Check](https://github.com/jacob-424/sg2-images/blob/main/SG2.py): `SG2.py`
- [Image Translation](https://github.com/jacob-424/sg2-images/blob/main/SG2.py): `SG2.py`
- [BallotY Image](https://github.com/jacob-424/sg2-images/blob/main/SG2.py): `SG2.py`
- [Image Statistics](https://github.com/jacob-424/sg2-images/blob/main/SG2.py): `SG2.py`
- [Grayness Labels](https://github.com/jacob-424/sg2-images/blob/main/SG2.py): `SG2.py`

### Standalone Modules

- [PNG Validator](https://github.com/jacob-424/sg2-images/blob/main/Png_input_and_validation.py): `Png_input_and_validation.py`
- [Pattern Detector](https://github.com/jacob-424/sg2-images/blob/main/patternDetection.py): `patternDetection.py`
- [Image Translator](https://github.com/jacob-424/sg2-images/blob/main/Image_Translation.py): `Image_Translation.py`

### Image Generation

- [Binary Ballot Generator](https://github.com/jacob-424/sg2-images/blob/main/pngGen.py): `pngGen.py`
- [Grayscale Ballot Generator](https://github.com/jacob-424/sg2-images/blob/main/grayScalePngGen.py): `grayScalePngGen.py`

### Other components

- **Operator**

## Connections

- Operator → SG2 Workflow: runs (evidence: `SG2.py`)
- SG2 Workflow → PNG Validation: calls (evidence: `SG2.py`)
- SG2 Workflow → Grayscale Conversion: uses (evidence: `SG2.py`)
- SG2 Workflow → Marker Detection: uses (evidence: `SG2.py`)
- SG2 Workflow → Alignment Check: uses (evidence: `SG2.py`)
- SG2 Workflow → Image Translation: uses (evidence: `SG2.py`)
- SG2 Workflow → Image Statistics: uses (evidence: `SG2.py`)
- Image Statistics → Grayness Labels: calls (evidence: `SG2.py`)
- Image Translation → BallotY Image: saves (evidence: `SG2.py`)
- Image Translator → PNG Validator: imports (evidence: `Image_Translation.py`)
- Binary Ballot Generator → Operator: generates
- Grayscale Ballot Generator → Operator: generates
