# bughht/cmfd architecture

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

- Interactive diagram: https://gitdiagram.com/bughht/cmfd
- Repository: https://github.com/bughht/cmfd

## Overview

CMFD is a Python framework for evaluating image copy-move forgery detectors. The main workflow is to select an algorithm through the command line, load MICC-F220 images and labels, call the detector on each image, and report classification metrics. The repository includes SIFT, patch-adaptive SIFT, ORB, FAST, and Harris implementations, plus a block-based experiment. Source excerpts show the evaluation and several detector internals; the README documents additional framework capabilities. The block-based implementation is present but its filename marks it as dumped.

Main entry points: [`AlgoTest.py`](https://github.com/bughht/cmfd/blob/main/AlgoTest.py) (Algorithm runner), [`utils.py`](https://github.com/bughht/cmfd/blob/main/utils.py) (Image preprocessing), [`Dataset.py`](https://github.com/bughht/cmfd/blob/main/Dataset.py) (MICC-F220 dataset), [`Block_Methods_[!!DUMPED].py`](https://github.com/bughht/cmfd/blob/main/Block_Methods_%5B!!DUMPED%5D.py) (Block-based detector)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_evaluation["Evaluation"]
  node_runner["Algorithm runner<br/>[AlgoTest.py]"]
  node_metrics["Metric reporting<br/>[AlgoTest.py]"]
  node_loader["DataLoader setup<br/>[AlgoTest.py]"]
end

subgraph group_data["Dataset"]
  node_dataset["MICC-F220 dataset<br/>[Dataset.py]"]
  node_corpus[("MICC-F220 corpus")]
end

subgraph group_detectors["Detection algorithms"]
  node_sift["SIFT detector<br/>[SIFT_Methods.py]"]
  node_patch_sift["Patch-SIFT detector"]
  node_orb["ORB detector<br/>[ORB_Methods.py]"]
  node_fast["FAST detector<br/>[FAST_Methods.py]"]
  node_harris["Harris detector<br/>[Harris_Methods.py]"]
  node_block["Block-based detector"]
end

subgraph group_shared["Shared image utilities"]
  node_data_helpers["Dataset helpers<br/>[utils.py]"]
  node_preprocess["Image preprocessing<br/>[utils.py]"]
  node_block_helpers["Block feature helpers<br/>[utils.py]"]
end

node_user(("CLI user"))

node_user -->|"selects algorithm"| node_runner
node_runner -->|"creates loader"| node_loader
node_runner -->|"loads dataset"| node_dataset
node_loader -->|"batches samples"| node_dataset
node_dataset -->|"loads labels"| node_data_helpers
node_dataset -->|"reads images"| node_corpus
node_runner -->|"dispatches dynamically"| node_sift
node_runner -->|"evaluates predictions"| node_metrics
node_metrics -->|"calls predict"| node_runner
node_sift -->|"converts to gray"| node_preprocess
node_patch_sift -->|"converts to gray"| node_preprocess
node_orb -->|"converts to gray"| node_preprocess
node_fast -->|"converts to gray"| node_preprocess
node_harris -->|"converts to gray"| node_preprocess
node_block -->|"uses features"| node_block_helpers
node_block -->|"loads image data"| node_data_helpers

click node_runner "https://github.com/bughht/cmfd/blob/main/AlgoTest.py"
click node_metrics "https://github.com/bughht/cmfd/blob/main/AlgoTest.py"
click node_loader "https://github.com/bughht/cmfd/blob/main/AlgoTest.py"
click node_dataset "https://github.com/bughht/cmfd/blob/main/Dataset.py"
click node_data_helpers "https://github.com/bughht/cmfd/blob/main/utils.py"
click node_preprocess "https://github.com/bughht/cmfd/blob/main/utils.py"
click node_block_helpers "https://github.com/bughht/cmfd/blob/main/utils.py"
click node_sift "https://github.com/bughht/cmfd/blob/main/SIFT_Methods.py"
click node_patch_sift "https://github.com/bughht/cmfd/blob/main/PATCH_SIFT_Methods.py"
click node_orb "https://github.com/bughht/cmfd/blob/main/ORB_Methods.py"
click node_fast "https://github.com/bughht/cmfd/blob/main/FAST_Methods.py"
click node_harris "https://github.com/bughht/cmfd/blob/main/Harris_Methods.py"
click node_block "https://github.com/bughht/cmfd/blob/main/Block_Methods_%5B!!DUMPED%5D.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_runner,node_metrics,node_loader,node_user toneBlue
class node_dataset,node_corpus toneAmber
class node_sift,node_patch_sift,node_orb,node_fast,node_harris,node_block toneMint
class node_data_helpers,node_preprocess,node_block_helpers toneRose
```

## Components

### Evaluation

- [Algorithm runner](https://github.com/bughht/cmfd/blob/main/AlgoTest.py): `AlgoTest.py`
- [Metric reporting](https://github.com/bughht/cmfd/blob/main/AlgoTest.py): `AlgoTest.py`
- [DataLoader setup](https://github.com/bughht/cmfd/blob/main/AlgoTest.py): `AlgoTest.py`

### Dataset

- [MICC-F220 dataset](https://github.com/bughht/cmfd/blob/main/Dataset.py): `Dataset.py`
- **MICC-F220 corpus**

### Detection algorithms

- [SIFT detector](https://github.com/bughht/cmfd/blob/main/SIFT_Methods.py): `SIFT_Methods.py`
- [Patch-SIFT detector](https://github.com/bughht/cmfd/blob/main/PATCH_SIFT_Methods.py): `PATCH_SIFT_Methods.py`
- [ORB detector](https://github.com/bughht/cmfd/blob/main/ORB_Methods.py): `ORB_Methods.py`
- [FAST detector](https://github.com/bughht/cmfd/blob/main/FAST_Methods.py): `FAST_Methods.py`
- [Harris detector](https://github.com/bughht/cmfd/blob/main/Harris_Methods.py): `Harris_Methods.py`
- [Block-based detector](https://github.com/bughht/cmfd/blob/main/Block_Methods_%5B!!DUMPED%5D.py): `Block_Methods_[!!DUMPED].py`

### Shared image utilities

- [Dataset helpers](https://github.com/bughht/cmfd/blob/main/utils.py): `utils.py`
- [Image preprocessing](https://github.com/bughht/cmfd/blob/main/utils.py): `utils.py`
- [Block feature helpers](https://github.com/bughht/cmfd/blob/main/utils.py): `utils.py`

### Other components

- **CLI user**

## Connections

- CLI user → Algorithm runner: selects algorithm (evidence: `README.md`)
- Algorithm runner → DataLoader setup: creates loader (evidence: `AlgoTest.py`)
- Algorithm runner → MICC-F220 dataset: loads dataset (evidence: `AlgoTest.py`)
- DataLoader setup → MICC-F220 dataset: batches samples (evidence: `AlgoTest.py`)
- MICC-F220 dataset → Dataset helpers: loads labels (evidence: `Dataset.py`)
- MICC-F220 dataset → MICC-F220 corpus: reads images (evidence: `Dataset.py`)
- Algorithm runner → SIFT detector: dispatches dynamically (evidence: `AlgoTest.py`)
- Algorithm runner → Metric reporting: evaluates predictions (evidence: `AlgoTest.py`)
- Metric reporting → Algorithm runner: calls predict (evidence: `AlgoTest.py`)
- SIFT detector → Image preprocessing: converts to gray (evidence: `SIFT_Methods.py`)
- Patch-SIFT detector → Image preprocessing: converts to gray (evidence: `PATCH_SIFT_Methods.py`)
- ORB detector → Image preprocessing: converts to gray (evidence: `ORB_Methods.py`)
- FAST detector → Image preprocessing: converts to gray (evidence: `FAST_Methods.py`)
- Harris detector → Image preprocessing: converts to gray (evidence: `Harris_Methods.py`)
- Block-based detector → Block feature helpers: uses features (evidence: `Block_Methods_[!!DUMPED].py`)
- Block-based detector → Dataset helpers: loads image data (evidence: `Block_Methods_[!!DUMPED].py`)
