Skip to content

Instantly share code, notes, and snippets.

@Shnatsel
Last active December 16, 2018 19:06
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 Shnatsel/0c1e9254f722c63cced09a322eefd74d to your computer and use it in GitHub Desktop.
Save Shnatsel/0c1e9254f722c63cced09a322eefd74d to your computer and use it in GitHub Desktop.
compare two folders with images visually and output mean squared error for each pair
#!/bin/bash
# Usage:
# ./compare.sh folder1 folder2 | grep -v '^[0-9]\.[0-9]\+e-' | grep -v '^0 ' | sort --numeric-sort --reverse
# filters out images with significant differences and sorts them by mean squared error
cd "$1"
for file in $(find * -type f); do
# http://www.imagemagick.org/Usage/compare/
NORMALIZED_DIFFERENCE=$(compare -metric MSE "$file" ../"$2"/"$file" null: 2>&1 | cut -d '(' -f 2 | cut -d ')' -f 1)
echo "$NORMALIZED_DIFFERENCE" "$file"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment