rd_plot.sh 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/bash
  2. set -e
  3. # Use this to average data from multiple runs
  4. #awk '{size[FNR]+=$2;bytes[FNR]+=$3;psnr[FNR]+=$2*$4;psnrhvs[FNR]+=$2*$5;ssim[FNR]+=$2*$6;fastssim[FNR]+=$2*$7;}END{for(i=1;i<=FNR;i++)print i+1,size[i],bytes[i],psnr[i]/size[i],psnrhvs[i]/size[i],ssim[i]/size[i],fastssim[i]/size[i];}' *.out > total.out
  5. if [ -n "$IMAGE" ]; then
  6. IMAGE="$IMAGE-"
  7. fi
  8. if [ $# == 0 ]; then
  9. echo "usage: IMAGE=<prefix> $0 *.out"
  10. exit 1
  11. fi
  12. if [ -z "$GNUPLOT" -a -n "`type -p gnuplot`" ]; then
  13. GNUPLOT=`type -p gnuplot`
  14. fi
  15. if [ ! -x "$GNUPLOT" ]; then
  16. echo "Executable not found GNUPLOT=$GNUPLOT"
  17. echo "Please install it or set GNUPLOT to point to an installed copy"
  18. exit 1
  19. fi
  20. #Uncomment to generate eps files for use with LaTeX
  21. #CMDS="$CMDS set term eps size 6, 4.5;"
  22. CMDS="$CMDS set term png size 1024,768;"
  23. CMDS="$CMDS set log x;"
  24. CMDS="$CMDS set xlabel 'Bits/Pixel';"
  25. CMDS="$CMDS set ylabel 'dB';"
  26. CMDS="$CMDS set key bot right;"
  27. for FILE in "$@"; do
  28. BASENAME=$(basename $FILE)
  29. PSNR="$PSNR $PREFIX '$FILE' using (\$3*8/\$2):4 with lines title '${BASENAME%.*} (PSNR)'"
  30. PSNRHVS="$PSNRHVS $PREFIX '$FILE' using (\$3*8/\$2):5 with lines title '${BASENAME%.*} (PSNR-HVS)'"
  31. SSIM="$SSIM $PREFIX '$FILE' using (\$3*8/\$2):6 with lines title '${BASENAME%.*} (SSIM)'"
  32. FASTSSIM="$FASTSSIM $PREFIX '$FILE' using (\$3*8/\$2):7 with lines title '${BASENAME%.*} (FAST SSIM)'"
  33. PREFIX=","
  34. done
  35. SUFFIX="psnr.png"
  36. $GNUPLOT -e "$CMDS set output \"$IMAGE$SUFFIX\"; plot $PSNR;" 2> /dev/null
  37. SUFFIX="psnrhvs.png"
  38. $GNUPLOT -e "$CMDS set output \"$IMAGE$SUFFIX\"; plot $PSNRHVS;" 2> /dev/null
  39. SUFFIX="ssim.png"
  40. $GNUPLOT -e "$CMDS set output \"$IMAGE$SUFFIX\"; plot $SSIM;" 2> /dev/null
  41. SUFFIX="fastssim.png"
  42. $GNUPLOT -e "$CMDS set output \"$IMAGE$SUFFIX\"; plot $FASTSSIM;" 2> /dev/null