How erdogant/undouble works
Project Context and Purpose
• Project Type: This is a Python library with a focused purpose—to detect (near-)identical images using image hashing.
Key Components
a. Input & File Handling Subsystem:
• This includes functionality to:
– Recursively read image files from directories.
– Accept lists of file paths or even numpy array representations of images.
• This as an Input Module that feeds data to the processing pipeline.
b. Pre-processing Module:
• This module is responsible for converting incoming images into a consistent format. Key processing steps include:
– Converting to grayscale.
– Normalizing and scaling the image.
c. Hash Computation Module:
• As indicated in the README and the core code, the system computes a hash for each pre-processed image.
• This as the “Image Hashing Engine”.
d. Grouping and Duplicate Detection:
• After computing hashes, a grouping mechanism is applied. This compares hashes with a threshold (0 in the simplest case) and groups near-identical images.
• This can be labeled “Grouping Engine” or “Duplicate Detection Module”.
e. Output & Action Module:
• This module handles two main functionalities:
– Visualization/plotting of image hash distributions and groupings.
– Moving or copying duplicate images (with the rule that the highest-resolution image is preserved and the rest moved to an “undouble” subdirectory).
• As separate but related sub-components (e.g., “Plotting & Visualization” and “File Management/Moving” modules).
f. Auxiliary Components:
• Testing and CI: Although not part of the runtime architecture, mention that automated tests and CI pipelines (GitHub workflows) ensure the integrity of components.
• Documentation: Sphinx-generated documentation verifies and explains the design and usage (build pipeline for docs).
Relationships and Data Flow
• From Pre-processing, images flow to the Hash Computation Module.
• The computed hashes then flow into the Grouping Engine that clusters images based on similarity.
• Finally, results are passed to the Output Module, with options for visualization and file operations.
Architectural Patterns & Design Principles
• Modular Design: Each core functionality (input, preprocessing, hash computation, grouping, output handling) is isolated, making it easier to maintain and extend.
• Pipeline/Sequential Processing: The process follows a clear sequential pipeline where each stage is responsible for a distinct part of the process.
• Extensibility: The design allows for plug-ins or additional modules (e.g., clustering extensions using the clustimage library mentioned in the README).