← Back to blog

BlockHash: The Noise‑Tolerant Duplicate Finder for Messy Image Collections

Sakarto's BlockHash algorithm finds duplicate photos and videos by comparing block‑averaged brightness. Perfect for heavily compressed JPEGs, scanned documents, and noisy image collections. Free, browser‑based, and 100% private.

Sakarto BlockHash duplicate finder interface showing noise-tolerant grouping of compressed images

Not all duplicate problems are the same. If you have a folder of high‑quality JPEGs straight from a camera, aHash will find duplicates in milliseconds. But what if your images have been re‑compressed multiple times? Saved at different quality levels? Scanned from old prints with visible grain and noise?

That’s where BlockHash comes in. It’s the noise‑tolerant workhorse of Sakarto’s image toolkit—an algorithm that averages brightness over blocks of pixels instead of reading them individually. This simple change makes it dramatically more resistant to JPEG compression artifacts, sensor noise, scanning imperfections, and re‑encoding degradation.

BlockHash won’t win any awards for precision. It’s a coarse descriptor by design, and it will occasionally group images that share a broad brightness structure without being true duplicates. But when your images are messy—and most image collections are—BlockHash is often the algorithm that finds duplicates the others miss.


What makes BlockHash different from aHash?

Both algorithms produce a binary hash and compare using Hamming distance. Both ignore colour and work only with brightness. But they encode brightness in fundamentally different ways:

aHashBlockHash
Input size16×16 pixels (256 total)64×64 canvas → 16×16 blocks (256 blocks)
ProcessingEach pixel compared to overall meanEach block averaged, then block averages compared to median
SensitivitySensitive to individual pixel changesNoise and compression artifacts are averaged away
SpeedFastestVery Fast (slightly slower than aHash)
Best forClean images, exact copies, speed priorityNoisy, compressed, or re‑encoded images

The key insight: When JPEG compression degrades an image, it introduces small errors in individual pixels. But when you average brightness over a 16×16 block—256 pixels—those small errors mostly cancel out. The block average barely changes even when the quality setting drops from 90% to 70%. aHash, which reads individual pixels, sees those errors as real differences and produces a different hash.


How the algorithm works: a deep dive

Let’s walk through exactly what happens when you scan a folder with BlockHash.

Step 1: Resize to a fixed canvas

Each image is drawn onto a canvas large enough to be cleanly divided into the block grid. In the current implementation, BlockHash uses a 64×64 pixel canvas (though the block count is what matters—16×16 blocks, each 4×4 pixels).

Fast Mode (enabled by default for JPEGs): Instead of decoding the full image, Sakarto reads the embedded EXIF thumbnail. This makes JPEG scans 5–10× faster. Because BlockHash averages brightness over blocks anyway, the tiny thumbnail quality difference rarely affects the result.

Step 2: Divide into a grid of equal blocks

The canvas is divided into a 16×16 grid of equal‑sized blocks. Each block covers a distinct rectangular region of the image. This produces 256 blocks, each representing the average brightness of that specific region.

Step 3: Compute average brightness per block

For each block, every pixel is converted to grayscale using the standard luminance formula: Gray = 0.299 × Red + 0.587 × Green + 0.114 × Blue

The average grayscale value across all pixels in that block is then computed. This single number represents the overall brightness of that region.

Why block averaging matters: JPEG compression adds small errors to individual pixels. By averaging 16 or more pixels together, those errors cancel out. The same applies to sensor noise, scanner grain, and minor variations from re‑encoding—the block average remains stable.

Step 4: Threshold to binary hash

The average brightness of each block is compared to the overall median of all block averages. Blocks brighter than the median become 1; darker become 0. The result is a 256‑bit binary hash—one bit per block.

Step 5: Compare using Hamming distance

To compare two files, Sakarto XORs their 256‑bit hashes bit by bit. The number of positions where the bits differ is the Hamming distance.

  • Distance = 0 → hashes are identical
  • Distance = 10 → 10 bits differ (about 4% of the hash)
  • Distance = 50 → 50 bits differ (about 20% of the hash)

The threshold slider controls the maximum Hamming distance allowed for two files to be grouped together. Lower = stricter.

Step 6: Aspect‑ratio pre‑check

Before comparing hashes, Sakarto checks whether the two files have similar aspect ratios. If one is 4:3 and the other is 16:9—differing by more than 10%—they’re skipped entirely. This prevents a tall portrait from matching a wide landscape even if their block brightness patterns coincidentally align.

Step 7: Video processing

For videos, 3 frames are extracted at 1.5‑second intervals. Each frame produces its own 256‑bit hash. The three hashes are averaged together (majority vote per bit) to produce a single representative hash for the whole file. Video scanning pauses if you switch tabs (browser limitation) and resumes when you return.


What BlockHash finds well

Type of duplicateHow well it worksWhy
Exact byte‑for‑byte copies✅ ExcellentThe hash will be identical.
Same photo at different resolutions✅ ExcellentResizing to a fixed canvas removes resolution differences.
Heavily compressed JPEGs at low quality✅ ExcellentBlock averaging absorbs compression artifacts that would change individual pixels.
Re‑saved copies in different formats (JPEG → PNG → WebP)✅ ExcellentFormat conversions change pixels, but block averages remain stable.
Scanned photos with sensor noise or print grain✅ ExcellentRandom noise cancels out when averaged over a block.
Re‑encoded files with visible compression artifacts✅ ExcellentExactly what BlockHash was designed for.
Screenshots of the same image✅ Very GoodScreenshots add slight colour shifts but block averages are preserved.
Videos with broadly similar key‑frame brightness✅ GoodMultiple frames averaged together produce a stable fingerprint.
Heavily cropped images (over 30% removed)⚠️ May missRemoving a large portion changes the block grid significantly.
Rotated or mirrored images❌ Won’t findBlock positions change entirely. Use ORB for rotated copies.
Images with dramatic colour filters or brightness edits⚠️ May missLarge brightness changes affect block averages. Try pHash or dHash.
Fine details that differ only within blocks⚠️ May missBlockHash is coarse by design—it won’t catch pixel‑level differences within blocks.
Two images that share brightness structure by coincidence⚠️ May over‑matchBlockHash is a coarse descriptor—use Compare to verify borderline matches.

Understanding the Hamming threshold slider

The threshold slider is the most important control in BlockHash. It determines how many bit differences are allowed between two hashes before they stop being considered duplicates.

Threshold rangeWhat it doesWhen to use
0–5 (Very strict)Only near‑identical hashes match. False positives are very rare.Finding exact copies and very close re‑exports.
6–15 (Balanced)Catches re‑compressed, resized, and reformatted copies.Default and recommended. BlockHash at 10–15 often catches everything aHash catches at 15–20.
16–25 (Loose)Includes more approximate brightness matches. More false positives.If you’re missing duplicates that are heavily cropped or significantly different in quality.
30+ (Very loose)Groups images with broadly similar block brightness distributions.Only use for exploration. Expect many false positives. Always compare before acting.

Tip: Because BlockHash is a coarse descriptor by design, it often catches everything useful at lower thresholds than you might need with aHash. Start at 8–10 and only raise if you’re missing known duplicates.


How to use BlockHash: step by step

Step 1: Open the tool and select a folder

Go to the BlockHash duplicate finder page. Click 📁 Select Folder to Scan to open a native folder picker (Chrome/Edge). Or drag and drop a folder onto the page.

Tip: Make sure Fast Mode is checked. For JPEGs, this reads the embedded thumbnail instead of the full image—5–10× faster with near‑identical accuracy. BlockHash’s block‑averaging step absorbs any tiny thumbnail quality difference.

Step 2: Wait for the scan to run

A progress bar shows how many files have been processed. BlockHash is one of the fastest algorithms in Sakarto—block averaging is computationally very light. Duplicate groups appear live as they’re found—you don’t need to wait for the full scan to finish before reviewing results.

Step 3: Adjust the threshold

After the scan completes, use the Hamming Threshold slider (0–50) to tune matching strictness. Release the slider to re‑cluster all results instantly using the new value—no re‑scanning needed. A background Web Worker handles the re‑comparison.

Step 4: Review the duplicate groups

Results are shown in numbered groups. Each group contains files with similar block brightness structures.

  • Click a card to select it (blue border)
  • Ctrl+Click (Cmd on Mac) to add to the compare list (purple border)
  • Click the 🔍 icon on hover to preview full size
  • Right‑click any card for the context menu
  • Click & drag on empty space to box‑select multiple cards

Step 5: Use the Compare modal

Ctrl+Click two or more cards, then click ⚖️ Compare in the toolbar. A modal shows each file with:

  • Full metadata (dimensions, file size, format)
  • A similarity percentage
  • Copy, Move, and Delete buttons for each file
  • A pairwise similarity matrix for 3+ files

Important: BlockHash can occasionally group images that share a broad brightness structure without being true duplicates. Always use Compare to verify borderline matches before acting.

Step 6: Take action—Move, Delete, or Copy

Select files and use the toolbar buttons. With Queue Mode on (recommended), files are staged for review first:

  • 📋 Copy — copy filename(s) to clipboard
  • 📂 Move — stage for move to a named folder
  • 🗑️ Delete — stage for permanent deletion
  • ⚖️ Compare — view selected files side‑by‑side

Warning: Deletions are permanent. The File System Access API bypasses the recycle bin. Always use Queue Mode to review before executing.

Step 7: Execute queued actions

Switch to the Move Queue or Delete Queue tab in the sidebar to review staged files, remove any you changed your mind about, then execute when ready.


When to use BlockHash vs. the other 6 algorithms

Sakarto gives you seven visual algorithms for a reason—each one handles a different type of duplication problem. Here’s when to pick BlockHash over the others:

Color Signature — colour accuracy

Color Signature is the only algorithm that compares actual colour. Use it when colour accuracy matters and you want to find copies that share the same palette.

Use BlockHash instead: Your images are heavily compressed, noisy, or re‑encoded many times. BlockHash is more tolerant of the degradation that would break Color Signature’s colour comparisons.

aHash (Average Hash) — speed above all else

aHash is the fastest algorithm—it reads individual pixels and compares them to the overall mean. It’s less tolerant of compression artifacts than BlockHash.

Use BlockHash instead: Your images show visible JPEG compression artifacts, blockiness, or noise that would cause aHash to produce different hashes for copies that look identical to the human eye.

dHash (Difference Hash) — brightness and exposure-adjusted copies

dHash compares the direction of brightness change between adjacent pixels, making it robust to exposure shifts.

Use BlockHash instead: You’re dealing with compression artifacts and noise rather than exposure adjustments. dHash is more sensitive to pixel‑level changes than BlockHash.

pHash (Perceptual Hash) — the all‑rounder for format conversions

pHash uses the Discrete Cosine Transform to extract low‑frequency structural data. It’s more discriminating than BlockHash but also slower.

Use BlockHash instead: You need speed for a large folder and your images are visibly noisy or heavily compressed. BlockHash is 3–5× faster than pHash and more tolerant of degradation.

wHash (Wavelet Hash) — speed and quality balance

wHash uses the Haar Wavelet Transform—similar quality to pHash at lower CPU cost.

Use BlockHash instead: You need the noise tolerance of block averaging. wHash is still sensitive to the pixel‑level changes that BlockHash ignores.

ORB (Feature Matching) — rotation, cropping, and perspective

ORB is the only algorithm that handles rotation, cropping, and perspective warping.

Use BlockHash instead: Your copies are not rotated or heavily cropped. BlockHash is 100× faster than ORB for large folders.


Algorithm quick reference

AlgorithmBest forColour‑aware?Handles rotation?SpeedNoise‑tolerant?
Color SignatureSame colour palette, social media re‑uploads✅ Yes❌ NoFast⚠️ Moderate
aHashLarge folders, speed priority❌ No❌ NoFastest⚠️ Low
BlockHashHeavily compressed JPEGs, noisy images❌ No❌ NoVery FastHigh
dHashBrightness/exposure‑adjusted copies❌ No❌ NoVery Fast⚠️ Moderate
pHashFormat conversions, all‑round reliability❌ No❌ NoFast⚠️ Moderate
wHashSpeed + quality balance❌ No❌ NoFast⚠️ Moderate
ORBRotated, cropped, perspective‑warped❌ No✅ YesSlower✅ High

Privacy: your files never leave your device

Like every Sakarto tool, the BlockHash duplicate finder runs entirely in your browser:

  • Zero network activity after page load. Open DevTools → Network tab and verify: no outbound requests during any scan or file operation.
  • No accounts, no cookies, no analytics. The only localStorage data is your OS detection and checkbox preferences. No file names or scan results are ever saved.
  • Folder access is scoped and session‑only. Permission expires when you close the tab.
  • Purely static—no backend. Sakarto is HTML, CSS, and JavaScript. There is no server, no database, and no API receiving your data.

Frequently asked questions (BlockHash specific)

“How is BlockHash different from aHash, and when should I choose it?”

Both are brightness‑based perceptual hashes compared using Hamming distance, but they encode brightness differently. aHash shrinks to 16×16 individual pixels and compares each pixel to the overall mean—it’s fast but sensitive to pixel‑level noise from JPEG compression. BlockHash divides a 64×64 canvas into 16 equal blocks and computes the average brightness of each block, then compares each block average to the median. This block averaging step is the key difference: by averaging brightness over a 16×16 area instead of reading a single pixel, compression artifacts, sensor noise, and encoding differences get diluted and mostly disappear from the hash. Choose BlockHash when your duplicates are heavily re‑compressed, saved at different quality settings, or include scanned documents at various DPIs.

”Two clearly different photos are being grouped together. How do I fix it?”

BlockHash is intentionally a coarse descriptor. Two photos with a similar broad brightness layout—both mostly bright sky above and dark ground below, for example—can produce matching hashes even if they show completely different scenes. Fix: Lower the similarity threshold slider to 3–6 to require hashes to be much closer before files are grouped. If false positives still occur at low thresholds, switch to pHash (frequency‑domain encoding, more discriminating) or Color Signature (also compares colour, not just brightness) for finer‑grained matching.

”I know two files are duplicates but they aren’t being grouped. What should I try?”

First, raise the threshold slider toward 15–20. Second, check aspect ratios—pairs where one file’s proportions differ from the other by more than 10% are excluded by the pre‑check before hashing runs. A portrait version will never match a landscape version regardless of threshold. Third, if one file is rotated or heavily cropped, BlockHash won’t match it—try ORB Feature Matching, which is the only algorithm that handles geometric transformations.

”Why is BlockHash described as ‘noise‑tolerant’? What counts as noise?”

In this context, “noise” means any pixel‑level difference that doesn’t represent a real change in the image’s visual content. JPEG re‑compression at a lower quality setting introduces ringing artifacts around edges. Re‑scanning a document on a flatbed scanner at a different DPI introduces slight brightness variations. Saving through a different encoder (e.g. Photoshop vs Lightroom) can change individual pixel values by a few levels. In all these cases, the block average barely changes because the noise is random and largely cancels out when averaged over a 16×16 area. An individual‑pixel algorithm like aHash would see those changes as real differences and produce a different hash.

”What does Fast Mode do, and does it affect BlockHash accuracy?”

Fast Mode reads the small EXIF thumbnail embedded in JPEG files (typically around 160×120 pixels) instead of decoding the full image. This is 5–10× faster with no meaningful accuracy cost for BlockHash, because BlockHash averages brightness over large blocks and is already insensitive to fine detail. The main reason to turn Fast Mode off is if your JPEG files were saved without EXIF thumbnails—some cameras and image editors strip them—in which case Fast Mode falls back to reading the full image anyway.

”Why does video scanning pause when I switch tabs?”

Browsers stop processing video elements when a tab is hidden, to conserve battery and CPU. Sakarto uses the Page Visibility API to detect this and automatically pauses video frame extraction. It resumes immediately when you return to the tab. Image hashing runs in a background Web Worker, which is not affected by tab visibility—images continue scanning at full speed no matter which tab you’re looking at.

”Can I recover files after deleting them?”

No. The File System Access API’s remove() method permanently deletes files without using the OS Recycle Bin or Trash. Queue Mode is enabled by default for exactly this reason: it stages files for review before anything is actually deleted. Use the full‑size preview icon and the Compare modal to verify each group before executing a deletion. If you’re unsure, use Move instead of Delete—moved files go to a “Sakarto‑Duplicates” subfolder you can review and manually restore from.

”What file types are supported?”

Images: JPEG, PNG, GIF, WebP, BMP. Videos: MP4, WebM, MOV, MKV. Files over 40 MB are silently skipped. HEIC/HEIF, SVG, RAW formats (CR2, NEF, ARW, DNG), and TIFF are not currently supported—browsers cannot natively decode these formats. Convert them to JPEG or PNG before scanning if needed.

”Does this work on Firefox or Safari?”

Scanning, hash computation, result display, and the Compare modal all work in Firefox and Safari. Move and Delete are the exception—they require the File System Access API, which is only available in Chrome 86+ and Edge 86+. In other browsers, run the full scan, review groups in the Compare modal, and use Download List to export a report so you can handle the files manually in your OS file manager.


Final thoughts

BlockHash is the noise‑tolerant workhorse of Sakarto’s image duplicate toolkit. It’s not the most precise algorithm—pHash and Color Signature are both more discriminating—but it excels at finding duplicates in messy, heavily compressed, or noisy image collections where other algorithms fail.

It’s particularly effective for:

  • Old JPEG collections. Images that have been re‑saved multiple times with visible compression artifacts.
  • Scanned photos and documents. Flatbed scanner output with sensor noise and grain.
  • Social media downloads. Platforms like Instagram, Facebook, and X apply aggressive re‑compression that degrades images significantly.
  • First‑pass deduplication. Run BlockHash on a large collection to find the obvious duplicates, then use pHash or Color Signature for a second pass on the remaining groups.

Where BlockHash falls short—rotated, colour‑graded, or heavily cropped copies—other Sakarto algorithms fill the gap. Use ORB for geometric transforms, pHash for format conversions and edits, or Color Signature for colour‑aware matching.

But for noisy, messy, and heavily compressed image libraries, BlockHash is the algorithm that finds the duplicates the others miss.

Ready to find duplicate images and videos in noisy collections?

May 31, 2026
⏱ 18 min read
🇬🇧 English