Last active
March 7, 2019 19:39
-
-
Save dcommander/01a5f598d0bf3871548b2654584fd738 to your computer and use it in GitHub Desktop.
Bash script that duplicates the functionality of VirtualGL's imgdiff program using ImageMagick, in a more compatible (and probably more accurate) way
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Copyright (C)2019 D. R. Commander. All Rights Reserved. | |
# | |
# Redistribution and use in source and binary forms, with or without | |
# modification, are permitted provided that the following conditions are met: | |
# | |
# - Redistributions of source code must retain the above copyright notice, | |
# this list of conditions and the following disclaimer. | |
# - Redistributions in binary form must reproduce the above copyright notice, | |
# this list of conditions and the following disclaimer in the documentation | |
# and/or other materials provided with the distribution. | |
# - Neither the name of The VirtualGL Project nor the names of its contributors | |
# may be used to endorse or promote products derived from this software | |
# without specific prior written permission. | |
# | |
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS", | |
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE | |
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
# POSSIBILITY OF SUCH DAMAGE. | |
set -e | |
set -u | |
if [ $# -lt 2 ]; then | |
echo USAGE: $0 \<Image 1\> \<Image 2\> | |
exit 1 | |
fi | |
PAE=(`compare -verbose -metric PAE "$1" "$2" null: 2>&1 | grep -E 'red:|green:|blue:|all:' | cut -f2 -d: | sed s/\(.*//g`) | |
for index in {0..3}; do | |
PAE[$index]=`echo ${PAE[$index]} | awk '{printf "%.0f", $1/256}'` | |
done | |
MAE=(`compare -verbose -metric MAE "$1" "$2" null: 2>&1 | grep -E 'red:|green:|blue:|all:' | cut -f2 -d: | sed s/\(.*//g`) | |
for index in {0..3}; do | |
MAE[$index]=`echo ${MAE[$index]} | awk '{printf "%.6f", $1/256}'` | |
done | |
RMS=(`compare -verbose -metric RMSE "$1" "$2" null: 2>&1 | grep -E 'red:|green:|blue:|all:' | cut -f2 -d: | sed s/\(.*//g`) | |
for index in {0..3}; do | |
RMS[$index]=`echo ${RMS[$index]} | awk '{printf "%.6f", $1/256}'` | |
done | |
PSNR=(`compare -verbose -metric PSNR "$1" "$2" null: 2>&1 | grep -E 'red:|green:|blue:|all:' | cut -f2 -d: | sed s/\(.*//g`) | |
echo B: max err.= ${PAE[2]} avg err.= ${MAE[2]} rms= ${RMS[2]} PSNR= ${PSNR[2]} | |
echo G: max err.= ${PAE[1]} avg err.= ${MAE[1]} rms= ${RMS[1]} PSNR= ${PSNR[1]} | |
echo R: max err.= ${PAE[0]} avg err.= ${MAE[0]} rms= ${RMS[0]} PSNR= ${PSNR[0]} | |
echo T: max err.= ${PAE[3]} avg err.= ${MAE[3]} rms= ${RMS[3]} PSNR= ${PSNR[3]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment