Skip to Content
New: codec-png-native and codec-png-wasm bring the blazediff-png codec to Node and WebAssembly, faster than spng and jSquash. Read more β†’
Comparevs OpenCV

BlazeDiff vs OpenCV

The blazediff Python wheel is ~3.4x faster than reading two files with OpenCV and running cv2.absdiff, and it answers the question a visual test asks: how many pixels differ, and where. OpenCV gives you a difference array, and the counting, thresholding and anti-aliasing handling are up to you.

cv2.absdiff subtracts two arrays per channel and returns the absolute values. That is a building block, not a test assertion: it has no perceptual threshold and no anti-aliasing detection, so one-pixel font rendering changes count as differences. blazediff.compare decodes both files, runs a YIQ color delta with optional anti-aliasing detection, and can write a diff image.

At a glance

OpenCV (opencv-python)BlazeDiff (blazediff)
LicenseApache-2.0 (wheels bundle LGPL FFmpeg and Qt)MIT
DependenciesnumpyNone
Inputnumpy arrays, after cv2.imreadFile paths (PNG, JPEG, QOI)
OutputPer-channel difference arraymatch, diff_count, diff_percentage, diff image
Perceptual thresholdNo, you threshold the arrayYes, YIQ delta with threshold
Anti-aliasingNoOptional detection
ScopeFull computer vision libraryImage diffing

Benchmarks

The OpenCV side reads both files as grayscale, runs cv2.absdiff, and counts the non-zero pixels. The BlazeDiff side reads both files in color and runs compare. Decode is included for both.

vs opencv-python (cv2.absdiff)

TOTAL TIME Β· 34 FIXTURES Β· MEAN OF 25 RUNS Β· IO INCLUDED

BlazeDiffOther librariesLower is better
#LibraryVersionTotal timevs OpenCV absdiff
1BlazeDiff7.0.02.20s3.42x faster
2OpenCV absdiff4.13.0.927.53sbaseline
Per-fixture results (34)
FixtureOpenCV absdiffBlazeDiffBlazeDiff vs OpenCV absdiff
4k/1617ms213ms2.90x
4k/1 (identical)782ms199ms3.92x
4k/2710ms280ms2.54x
4k/2 (identical)695ms242ms2.88x
4k/3820ms270ms3.03x
4k/3 (identical)790ms250ms3.16x
blazediff/14.94ms1.13ms4.38x
blazediff/1 (identical)4.50ms1.03ms4.36x
blazediff/24.14ms1.58ms2.61x
blazediff/2 (identical)4.01ms1.13ms3.55x
blazediff/344.59ms19.03ms2.34x
blazediff/3 (identical)44.49ms15.52ms2.87x
blazediff/430.53ms5.81ms5.26x
blazediff/4 (identical)30.23ms4.92ms6.15x
page/11.06s285ms3.72x
page/1 (identical)1.21s266ms4.52x
page/2306ms73.36ms4.16x
page/2 (identical)288ms48.83ms5.91x
pixelmatch/13.46ms1.29ms2.68x
pixelmatch/1 (identical)4.40ms1.20ms3.65x
pixelmatch/21.16ms1.58ms0.73x
pixelmatch/2 (identical)1.07ms0.54ms2.00x
pixelmatch/33.40ms1.05ms3.23x
pixelmatch/3 (identical)3.96ms1.05ms3.76x
pixelmatch/47.76ms4.53ms1.71x
pixelmatch/4 (identical)6.00ms2.28ms2.63x
pixelmatch/51.84ms0.66ms2.78x
pixelmatch/5 (identical)1.89ms0.62ms3.05x
pixelmatch/62.64ms1.64ms1.61x
pixelmatch/6 (identical)4.48ms0.86ms5.21x
pixelmatch/71.89ms1.11ms1.70x
pixelmatch/7 (identical)2.06ms0.71ms2.90x
same/118.29ms3.55ms5.15x
same/1 (identical)19.38ms3.55ms5.46x
TOTAL7.53s2.20s3.42x

pnpm benchmark python-opencv Β· Apple M1 Max Β· darwin/arm64 Β· Node v22.14.0 Β· rustc 1.97.1 (8bab26f4f 2026-07-14) Β· Python 3.11.14 Β· 2026-11-11 Β· eafe393-dirty

Switching

# Before import cv2 import numpy as np a = cv2.imread("baseline.png", cv2.IMREAD_GRAYSCALE) b = cv2.imread("current.png", cv2.IMREAD_GRAYSCALE) changed = np.count_nonzero(cv2.absdiff(a, b)) # After from blazediff import diff result = diff("baseline.png", "current.png", "diff.png", threshold=0.1) if result.kind == "compared" and not result.identical: print(f"{result.count} pixels differ")

diff returns kind == "dimension-mismatch" when the two images differ in size, where cv2.absdiff raises an error.

When to keep OpenCV

  • The diff is one step in a larger vision pipeline: alignment, contours, morphology or feature matching.
  • You need formats that only OpenCV reads, such as TIFF, WebP or HDR.
  • You need GPU processing.
Last updated on