Skip to content

๐Ÿ–ผ๏ธ Terminal UI for perceptual image hashing (dHash/pHash) with multi-threaded processing and visual similarity detection

License

Notifications You must be signed in to change notification settings

OlaszPL/perceptual-hashing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

35 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ–ผ๏ธ Perceptual Hashing TUI

Rust License Release

Built With Ratatui

Blazing fast ๐Ÿš€ and memory-safe perceptual hashing application built with Rust!

A terminal user interface (TUI) application for computing perceptual hashes of images and finding similar images with convenient preview capabilities. Hash computation is performed using multi-threading for optimal performance.

๐Ÿ‘ฅ Authors

Project realized as a part of Rust Course at AGH University of Krakow by:

image

โœจ Features

  • ๐Ÿ–ผ๏ธ Perceptual hashing with two algorithms:
    • dHash (Difference Hash)
    • pHash (Perceptual Hash)
  • ๐Ÿ” Similar image detection with visual preview
  • ๐Ÿ“ Built-in file explorer for folder selection
  • โšก Multi-threaded processing for blazing fast performance
  • ๐ŸŽจ Interactive TUI built with Ratatui
  • ๐Ÿ”ข 64-bit hash computation
  • ๐Ÿ–ฅ๏ธ Cross-platform support (Linux & Windows)

๐ŸŽฏ How it Works

The application provides an intuitive TUI interface with:

  1. Built-in file explorer - Navigate and select folders containing images
  2. Algorithm selection - Choose between dHash and pHash algorithms
  3. Results browser - View similar images with side-by-side preview of source and similar images

๐ŸŽฌ Demo

Nagranieekranuz2025-10-0313-27-36-ezgif com-video-to-gif-converter

Complete workflow: folder selection โ†’ algorithm choice โ†’ processing โ†’ results exploration


๐Ÿ“‹ Prerequisites

  • Rust (edition 2024 or higher)
  • Cargo (Rust package manager)

๐Ÿ“ฆ Installation

Download Pre-built Binaries

You can download pre-built binaries for your platform from the releases page.

Available architectures:

  • Linux x86_64
  • Windows x86_64

Important

  • The Windows version does not support image display in the terminal.
  • On Linux, image display in the terminal is only supported in terminals listed in the
    ratatui-image compatibility matrix.

Running the Application

Linux

./perceptual-hashing

Windows

.\perceptual-hashing.exe

Build from Source

  1. Clone the repository

    git clone https://github.com/OlaszPL/perceptual-hashing.git
    cd perceptual-hashing
  2. Build the project

    cargo build --release
  3. Run the application

    cargo run --release

๐Ÿ” Algorithms

The application implements two proven perceptual hashing algorithms:

dHash (Difference Hash)

  • Fast computation - ideal for real-time processing
  • Good performance on brightness/contrast variations
  • Lower memory usage
  • Best for: Quick similarity detection

pHash (Perceptual Hash)

  • Higher accuracy - more robust similarity detection
  • Better resilience to image transformations
  • DCT-based approach for perceptual similarity
  • Best for: Precise duplicate detection

Both algorithms produce 64-bit hashes and use Hamming distance for similarity comparison (lower distance = more similar images).

๐ŸŽฎ User Interface

The TUI provides an intuitive workflow:

1. File Selection

  • Browse directories using arrow keys
  • Press c to select a folder for processing
  • Press q to exit
image

2. Algorithm Selection

  • Choose between dHash (red) and pHash (blue)
  • Use arrow keys or mouse to toggle selection
  • Press Enter to confirm
image

3. Processing

  • Real-time progress with "CALCULATING" indicator
  • Processing time displayed in the top-right corner
  • Multi-threaded computation for optimal performance
image

4. Results Exploration

  • Left Panel: List of all processed images
  • Center Panel: Similar images with Hamming distance scores (0 = identical)
  • Right Panel: Side-by-side preview of selected and similar images
  • Navigate with arrow keys, press Esc to go back
image

๐Ÿงช Testing

The project includes comprehensive unit tests for the hashing algorithms:

# Run all tests
cargo test

Tests cover:

  • dHash algorithm correctness and consistency
  • pHash algorithm accuracy and edge cases
  • Hash computation validation

โš ๏ธ Important Notes

  • Folder permissions: The application cannot access folders without proper read permissions
  • Minimum images: Processing requires at least 2 images in the selected directory
  • Hash size: All computed hashes are 64-bit for optimal performance and accuracy
  • Image formats: Supports common formats (JPEG, PNG, etc.)
  • Performance: Processing time scales with image count and selected algorithm

๐Ÿ› ๏ธ Technology Stack

  • Language: Rust ๐Ÿฆ€ (memory-safe and blazing fast!)
  • TUI Framework: Ratatui

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


Made with โค๏ธ and ๐Ÿฆ€ Rust

About

๐Ÿ–ผ๏ธ Terminal UI for perceptual image hashing (dHash/pHash) with multi-threaded processing and visual similarity detection

Topics

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •  

Languages