# minsikaw/sam_delamquantification architecture

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

- Interactive diagram: https://gitdiagram.com/minsikaw/sam_delamquantification
- Repository: https://github.com/minsikaw/sam_delamquantification

## Overview

This is a Windows Forms sample-mapping and image-analysis application. Its main workflow is to load project images, detect sample regions, review or correct ROIs, and use the resulting geometry in image combination and spreadsheet output. Separate capabilities cover configurable CV models, delamination analysis and quantification, and ZGT batch conversion. The graph uses the source index and excerpts for relationships; unsampled forms and services are included where the tree identifies their product role, but are not given speculative connections.

Main entry points: [`MainForm.cs`](https://github.com/minsikaw/sam_delamquantification/blob/master/MainForm.cs) (Application shell), [`Forms/SampleRoiReviewForm.cs`](https://github.com/minsikaw/sam_delamquantification/blob/master/Forms/SampleRoiReviewForm.cs) (ROI editor), [`Forms/SampleDetectionReviewForm.cs`](https://github.com/minsikaw/sam_delamquantification/blob/master/Forms/SampleDetectionReviewForm.cs) (Detection review), [`Services/CvModels/CvModelRegistry.cs`](https://github.com/minsikaw/sam_delamquantification/blob/master/Services/CvModels/CvModelRegistry.cs) (CV model registry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Mapping workflow"]
  node_app["Application shell<br/>[MainForm.cs]"]
  node_source_mode["Source selection"]
  node_sample_review["Detection review"]
  node_roi_review["ROI editor"]
end

subgraph group_detection["Detection and models"]
  node_sample_detector["Sample detection"]
  node_final_roi["Final ROI detection"]
  node_cv_service["CV detection service"]
  node_cv_backend["OpenCV backend"]
  node_cv_registry[("CV model registry<br/>[CvModelRegistry.cs]")]
  node_cv_manager["Model manager"]
  node_cv_test["Model test mode"]
end

subgraph group_analysis["Analysis and review"]
  node_roi_confidence["ROI confidence"]
  node_roi_policy["ROI review policy<br/>[RoiReviewPolicy.cs]"]
  node_roi_store[("ROI correction store")]
  node_delam_review["Delamination review"]
  node_delam_service["Delamination analysis"]
  node_delam_quantifier["Color quantification"]
  node_delam_store[("Analysis store")]
end

subgraph group_data["Presets and output"]
  node_preset_manager[("Preset manager<br/>[PresetManager.cs]")]
  node_unified_presets[("Unified presets")]
  node_image_mapper["Image mapping<br/>[ImageMapper.cs]"]
  node_image_combiner["Image combination<br/>[ImageCombiner.cs]"]
  node_excel["Spreadsheet output<br/>[ExcelService.cs]"]
end

subgraph group_operations["Conversion and support"]
  node_zgt_convert["ZGT batch conversion"]
  node_zgt_parser["ZGT parser<br/>[ZgtParser.cs]"]
  node_logger["Logging<br/>[LoggerHelper.cs]"]
end

node_user(("User"))

node_user -->|"uses"| node_app
node_app -->|"opens"| node_source_mode
node_app -->|"opens"| node_sample_review
node_app -->|"opens"| node_roi_review
node_app -->|"maps images"| node_image_mapper
node_app -->|"combines images"| node_image_combiner
node_app -->|"exports results"| node_excel
node_app -->|"manages presets"| node_preset_manager
node_app -->|"opens"| node_zgt_convert
node_sample_review -->|"opens"| node_roi_review
node_sample_review -->|"reads corrections"| node_roi_store
node_sample_review -->|"checks review"| node_roi_policy
node_sample_review -->|"evaluates confidence"| node_roi_confidence
node_roi_review -->|"loads and saves"| node_roi_store
node_roi_review -->|"checks review"| node_roi_policy
node_roi_review -->|"builds confidence"| node_roi_confidence
node_roi_review -->|"detects ROI"| node_final_roi
node_roi_confidence -->|"selects presets"| node_preset_manager
node_final_roi -->|"requests detection"| node_cv_service
node_cv_service -->|"gets model"| node_cv_registry
node_cv_service -->|"creates backend"| node_cv_backend
node_cv_backend -->|"uses geometry"| node_unified_presets
node_cv_manager -->|"manages models"| node_cv_registry
node_cv_registry -->|"uses preset geometry"| node_unified_presets
node_cv_registry -->|"bridges presets"| node_preset_manager
node_delam_review -->|"loads analyses"| node_delam_store
node_delam_review -.->|"reviews analysis"| node_delam_service
node_delam_service -->|"quantifies color"| node_delam_quantifier
node_delam_service -->|"reads corrections"| node_roi_store
node_image_combiner -->|"reads corrections"| node_roi_store
node_excel -->|"uses combined images"| node_image_combiner
node_zgt_convert -.->|"parses ZGT"| node_zgt_parser
node_app -.->|"runs detection"| node_sample_detector
node_cv_manager -.->|"offers testing"| node_cv_test

click node_app "https://github.com/minsikaw/sam_delamquantification/blob/master/MainForm.cs"
click node_source_mode "https://github.com/minsikaw/sam_delamquantification/blob/master/Forms/SourceModeSelectionForm.cs"
click node_sample_review "https://github.com/minsikaw/sam_delamquantification/blob/master/Forms/SampleDetectionReviewForm.cs"
click node_roi_review "https://github.com/minsikaw/sam_delamquantification/blob/master/Forms/SampleRoiReviewForm.cs"
click node_sample_detector "https://github.com/minsikaw/sam_delamquantification/blob/master/Services/SamSampleDetector.cs"
click node_final_roi "https://github.com/minsikaw/sam_delamquantification/blob/master/Services/SamFinalRoiDetector.cs"
click node_cv_service "https://github.com/minsikaw/sam_delamquantification/blob/master/Services/CvModels/SampleDetectionService.cs"
click node_cv_backend "https://github.com/minsikaw/sam_delamquantification/blob/master/Services/CvModels/ClassicalOpenCvDetectionBackend.cs"
click node_cv_registry "https://github.com/minsikaw/sam_delamquantification/blob/master/Services/CvModels/CvModelRegistry.cs"
click node_cv_manager "https://github.com/minsikaw/sam_delamquantification/blob/master/Forms/CvModelManagerForm.cs"
click node_cv_test "https://github.com/minsikaw/sam_delamquantification/blob/master/Forms/CvModelTestModeForm.cs"
click node_roi_confidence "https://github.com/minsikaw/sam_delamquantification/blob/master/Services/RoiConfidenceService.cs"
click node_roi_policy "https://github.com/minsikaw/sam_delamquantification/blob/master/Services/RoiReviewPolicy.cs"
click node_roi_store "https://github.com/minsikaw/sam_delamquantification/blob/master/Services/RoiCorrectionStore.cs"
click node_delam_review "https://github.com/minsikaw/sam_delamquantification/blob/master/Forms/DelamAnalysisReviewForm.cs"
click node_delam_service "https://github.com/minsikaw/sam_delamquantification/blob/master/Services/DelamAnalysisService.cs"
click node_delam_quantifier "https://github.com/minsikaw/sam_delamquantification/blob/master/Services/ColorDelamQuantifier.cs"
click node_delam_store "https://github.com/minsikaw/sam_delamquantification/blob/master/Services/DelamAnalysisStore.cs"
click node_preset_manager "https://github.com/minsikaw/sam_delamquantification/blob/master/Models/PresetManager.cs"
click node_unified_presets "https://github.com/minsikaw/sam_delamquantification/blob/master/Services/UnifiedSampleDetectionPresetStore.cs"
click node_image_mapper "https://github.com/minsikaw/sam_delamquantification/blob/master/Services/ImageMapper.cs"
click node_image_combiner "https://github.com/minsikaw/sam_delamquantification/blob/master/Services/ImageCombiner.cs"
click node_excel "https://github.com/minsikaw/sam_delamquantification/blob/master/Services/ExcelService.cs"
click node_zgt_convert "https://github.com/minsikaw/sam_delamquantification/blob/master/Forms/ZgtBatchConvertForm.cs"
click node_zgt_parser "https://github.com/minsikaw/sam_delamquantification/blob/master/Services/ZgtParser.cs"
click node_logger "https://github.com/minsikaw/sam_delamquantification/blob/master/Services/LoggerHelper.cs"

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_app,node_source_mode,node_sample_review,node_roi_review,node_user toneBlue
class node_sample_detector,node_final_roi,node_cv_service,node_cv_backend,node_cv_registry,node_cv_manager,node_cv_test toneAmber
class node_roi_confidence,node_roi_policy,node_roi_store,node_delam_review,node_delam_service,node_delam_quantifier,node_delam_store toneMint
class node_preset_manager,node_unified_presets,node_image_mapper,node_image_combiner,node_excel toneRose
class node_zgt_convert,node_zgt_parser,node_logger toneIndigo
```

## Components

### Mapping workflow

- [Application shell](https://github.com/minsikaw/sam_delamquantification/blob/master/MainForm.cs): `MainForm.cs`
- [Source selection](https://github.com/minsikaw/sam_delamquantification/blob/master/Forms/SourceModeSelectionForm.cs): `Forms/SourceModeSelectionForm.cs`
- [Detection review](https://github.com/minsikaw/sam_delamquantification/blob/master/Forms/SampleDetectionReviewForm.cs): `Forms/SampleDetectionReviewForm.cs`
- [ROI editor](https://github.com/minsikaw/sam_delamquantification/blob/master/Forms/SampleRoiReviewForm.cs): `Forms/SampleRoiReviewForm.cs`

### Detection and models

- [Sample detection](https://github.com/minsikaw/sam_delamquantification/blob/master/Services/SamSampleDetector.cs): `Services/SamSampleDetector.cs`
- [Final ROI detection](https://github.com/minsikaw/sam_delamquantification/blob/master/Services/SamFinalRoiDetector.cs): `Services/SamFinalRoiDetector.cs`
- [CV detection service](https://github.com/minsikaw/sam_delamquantification/blob/master/Services/CvModels/SampleDetectionService.cs): `Services/CvModels/SampleDetectionService.cs`
- [OpenCV backend](https://github.com/minsikaw/sam_delamquantification/blob/master/Services/CvModels/ClassicalOpenCvDetectionBackend.cs): `Services/CvModels/ClassicalOpenCvDetectionBackend.cs`
- [CV model registry](https://github.com/minsikaw/sam_delamquantification/blob/master/Services/CvModels/CvModelRegistry.cs): `Services/CvModels/CvModelRegistry.cs`
- [Model manager](https://github.com/minsikaw/sam_delamquantification/blob/master/Forms/CvModelManagerForm.cs): `Forms/CvModelManagerForm.cs`
- [Model test mode](https://github.com/minsikaw/sam_delamquantification/blob/master/Forms/CvModelTestModeForm.cs): `Forms/CvModelTestModeForm.cs`

### Analysis and review

- [ROI confidence](https://github.com/minsikaw/sam_delamquantification/blob/master/Services/RoiConfidenceService.cs): `Services/RoiConfidenceService.cs`
- [ROI review policy](https://github.com/minsikaw/sam_delamquantification/blob/master/Services/RoiReviewPolicy.cs): `Services/RoiReviewPolicy.cs`
- [ROI correction store](https://github.com/minsikaw/sam_delamquantification/blob/master/Services/RoiCorrectionStore.cs): `Services/RoiCorrectionStore.cs`
- [Delamination review](https://github.com/minsikaw/sam_delamquantification/blob/master/Forms/DelamAnalysisReviewForm.cs): `Forms/DelamAnalysisReviewForm.cs`
- [Delamination analysis](https://github.com/minsikaw/sam_delamquantification/blob/master/Services/DelamAnalysisService.cs): `Services/DelamAnalysisService.cs`
- [Color quantification](https://github.com/minsikaw/sam_delamquantification/blob/master/Services/ColorDelamQuantifier.cs): `Services/ColorDelamQuantifier.cs`
- [Analysis store](https://github.com/minsikaw/sam_delamquantification/blob/master/Services/DelamAnalysisStore.cs): `Services/DelamAnalysisStore.cs`

### Presets and output

- [Preset manager](https://github.com/minsikaw/sam_delamquantification/blob/master/Models/PresetManager.cs): `Models/PresetManager.cs`
- [Unified presets](https://github.com/minsikaw/sam_delamquantification/blob/master/Services/UnifiedSampleDetectionPresetStore.cs): `Services/UnifiedSampleDetectionPresetStore.cs`
- [Image mapping](https://github.com/minsikaw/sam_delamquantification/blob/master/Services/ImageMapper.cs): `Services/ImageMapper.cs`
- [Image combination](https://github.com/minsikaw/sam_delamquantification/blob/master/Services/ImageCombiner.cs): `Services/ImageCombiner.cs`
- [Spreadsheet output](https://github.com/minsikaw/sam_delamquantification/blob/master/Services/ExcelService.cs): `Services/ExcelService.cs`

### Conversion and support

- [ZGT batch conversion](https://github.com/minsikaw/sam_delamquantification/blob/master/Forms/ZgtBatchConvertForm.cs): `Forms/ZgtBatchConvertForm.cs`
- [ZGT parser](https://github.com/minsikaw/sam_delamquantification/blob/master/Services/ZgtParser.cs): `Services/ZgtParser.cs`
- [Logging](https://github.com/minsikaw/sam_delamquantification/blob/master/Services/LoggerHelper.cs): `Services/LoggerHelper.cs`

### Other components

- **User**

## Connections

- User → Application shell: uses
- Application shell → Source selection: opens (evidence: `MainForm.cs`)
- Application shell → Detection review: opens (evidence: `MainForm.cs`)
- Application shell → ROI editor: opens (evidence: `MainForm.cs`)
- Application shell → Image mapping: maps images (evidence: `MainForm.cs`)
- Application shell → Image combination: combines images (evidence: `MainForm.cs`)
- Application shell → Spreadsheet output: exports results (evidence: `MainForm.cs`)
- Application shell → Preset manager: manages presets (evidence: `MainForm.cs`)
- Application shell → ZGT batch conversion: opens (evidence: `MainForm.cs`)
- Detection review → ROI editor: opens (evidence: `Forms/SampleDetectionReviewForm.cs`)
- Detection review → ROI correction store: reads corrections (evidence: `Forms/SampleDetectionReviewForm.cs`)
- Detection review → ROI review policy: checks review (evidence: `Forms/SampleDetectionReviewForm.cs`)
- Detection review → ROI confidence: evaluates confidence (evidence: `Forms/SampleDetectionReviewForm.cs`)
- ROI editor → ROI correction store: loads and saves (evidence: `Forms/SampleRoiReviewForm.cs`)
- ROI editor → ROI review policy: checks review (evidence: `Forms/SampleRoiReviewForm.cs`)
- ROI editor → ROI confidence: builds confidence (evidence: `Forms/SampleRoiReviewForm.cs`)
- ROI editor → Final ROI detection: detects ROI (evidence: `Forms/SampleRoiReviewForm.cs`)
- ROI confidence → Preset manager: selects presets (evidence: `Services/RoiConfidenceService.cs`)
- Final ROI detection → CV detection service: requests detection (evidence: `Services/SamFinalRoiDetector.cs`)
- CV detection service → CV model registry: gets model (evidence: `Services/CvModels/SampleDetectionService.cs`)
- CV detection service → OpenCV backend: creates backend (evidence: `Services/CvModels/SampleDetectionService.cs`)
- OpenCV backend → Unified presets: uses geometry (evidence: `Services/CvModels/ClassicalOpenCvDetectionBackend.cs`)
- Model manager → CV model registry: manages models (evidence: `Forms/CvModelManagerForm.cs`)
- CV model registry → Unified presets: uses preset geometry (evidence: `Services/CvModels/CvModelRegistry.cs`)
- CV model registry → Preset manager: bridges presets (evidence: `Models/PresetManager.cs`)
- Delamination review → Analysis store: loads analyses (evidence: `Forms/DelamAnalysisReviewForm.cs`)
- Delamination review → Delamination analysis: reviews analysis
- Delamination analysis → Color quantification: quantifies color (evidence: `Services/DelamAnalysisService.cs`)
- Delamination analysis → ROI correction store: reads corrections (evidence: `Services/DelamAnalysisService.cs`)
- Image combination → ROI correction store: reads corrections (evidence: `Services/ImageCombiner.cs`)
- Spreadsheet output → Image combination: uses combined images (evidence: `Services/ExcelService.cs`)
- ZGT batch conversion → ZGT parser: parses ZGT
- Application shell → Sample detection: runs detection
- Model manager → Model test mode: offers testing
