Skip to content

Instantly share code, notes, and snippets.

@barrbrain
Last active October 31, 2015 02:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barrbrain/a708f6c4d28eec4680dd to your computer and use it in GitHub Desktop.
Save barrbrain/a708f6c4d28eec4680dd to your computer and use it in GitHub Desktop.
Calculate PSNR with CIE76 difference method
#!/bin/bash
# REQUIRES imagemagick compiled with HDRI feature enabled
SIZE=$(head -n1 "$1" | sed -E 's/.*W([0-9]*) H([0-9]*).*/\1x\2/')
FMT="-size $SIZE -depth 8 -sampling-factor 4:2:0 -interlace plane -set colorspace Rec709YCbCr"
convert $FMT YUV:<(tail -n+3<"$1") YUV:<(tail -n+3<"$2") \
-colorspace Lab -compose difference \
-composite -evaluate Pow 2 -separate -evaluate-sequence Add \
-filter box -resize 1x1\! -format "%[fx:-10*log(u)]\n" info:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment