Skip to main content

Sobel Gradient Image Deduplication

Project description

GraDupe Icon
GraDupe

Sobel Gradient Image Deduplication

Usage

Get the CLI tool with pip install -U gradupe, or retrieve from PyPI manually. It is recommended to run the CLI with admin privilege.

gradupe init initializes cache in the current directory for long-term management.
gradupe scan scans the current directory for duplicates, utilizing cache if available.

For further information and options, refer to gradupe and gradupe [command] --help. Cache is stored in the .gradupe SQLite database in the current directory if enabled.

Motive

Classical algorithms based on image hashes can be inaccurate. Innovative ones based on RNNs can be inefficient. As the demand for image storage increases rapidly over the decade, we need a prompt solution that combines the benefits of both.

At one point, Sobel gradients occurred to me as a decent fingerprint for an image. Similar to finite differences and derivatives, two distinct images bear the same gradient only if they differ by a constant. By reading an image in grayscale, we obtain a 2D matrix suitable for Sobel operators.

Images of different dimensions are downscaled into a square grid. Although convolutions are blazingly fast on modern hardware, this is done to unify dimensions and speed up diffing. After downscaling, there remains a sufficient amount of informative bits for diffing in the next step.

Sobel operators are traditionally used for edge detection, but their nature lies in differentiating an image. Computing the Sobel gradient of an image in both the x and y directions yields two matrices, which we flatten and concatenate into a contiguous array.

The gradients are thresholded into bitmasks since Hamming distance can be optimized using SIMD XOR instructions, making it magnitudes faster than Euclidean norm. By mapping sub-indices of pairs into combinatorial indices, a densely packed array can be used as a distance matrix, saving memory and enabling parallel computation.

The single flat distance array can be thresholded into a boolean mask with SIMD instructions. All that remains is to compress the image combinations with the mask (combinatorial indexing ensures correct correspondence), resulting in a list of duplicate pairs which is then merged into groups via union find.

Credits

Library
OpenCV, NumPy, Numba

Cache
SQLite

CLI
Typer, Rich

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gradupe-3.0.3.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gradupe-3.0.3-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file gradupe-3.0.3.tar.gz.

File metadata

  • Download URL: gradupe-3.0.3.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for gradupe-3.0.3.tar.gz
Algorithm Hash digest
SHA256 e7e8bea0a7dc558770ffd420aed2de419ce4f309e08ac4c0a203aa31f20450ff
MD5 6eeca5626a438beecd5453839ecef953
BLAKE2b-256 f9db4224aac33c14470784fdd78d81cd9bf1c6a681c9968a7cf3f3e5c6e7f0d5

See more details on using hashes here.

Provenance

The following attestation bundles were made for gradupe-3.0.3.tar.gz:

Publisher: publish.yml on wavim/gradupe

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gradupe-3.0.3-py3-none-any.whl.

File metadata

  • Download URL: gradupe-3.0.3-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for gradupe-3.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7a4bf0375186a826d67b15c42fffab0a69fcbaa1faf4c32eae74f45e11f8f654
MD5 4d13238a61a7e6d91cfc5b81cb92bbed
BLAKE2b-256 9ef9878b5ebbaa096d2eed515515cd26e201322a61815dfd16ccca6d8313c221

See more details on using hashes here.

Provenance

The following attestation bundles were made for gradupe-3.0.3-py3-none-any.whl:

Publisher: publish.yml on wavim/gradupe

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page