lolsalat

[SCAD]: Practical 3 Tester

Jan 5th, 2021 (edited)
857
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.13 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # change to the name of your python interpreter
  4. python="python3"
  5.  
  6. # file name of original binary (filtermagic before you changed anything)
  7. old="filtermagic_old"
  8.  
  9. # name of test image
  10. test_img="img.bmp"
  11.  
  12. # check a given filter
  13. function check {
  14.   printf "%s %13s" "checking"  "$1:  "
  15.   # run your implementation
  16.   ./filtermagic $test_img $1 > /dev/null
  17.   # move output to results folder
  18.   mv out.bmp results/$1.bmp
  19.   # run reference implementation
  20.   ./$old $test_img $1 > /dev/null
  21.   # move output to results folder
  22.   mv out.bmp results/$1_reference.bmp
  23.   # calculate md5 checksum of results
  24.   result=$(md5sum results/$1.bmp)
  25.   reference=$(md5sum results/$1_reference.bmp)
  26.   # compare md5 sums
  27.   echo $($python -c "print('success' if '$result'.split(' ')[0] == '$reference'.split(' ')[0] else 'failed')")
  28. }
  29.  
  30. # make sure everything is compiled!
  31. make >/dev/null
  32. # make results directory
  33. mkdir results > /dev/null 2> /dev/null
  34.  
  35. # run tests
  36. check grayscale
  37. check valuecap
  38. check edge
  39. check sequence
  40. check mark
  41. check maxcolor
  42. check reduce
  43. check threshold
  44. check lucy
  45. check bleed
  46. check luminance
  47. check enhance
Add Comment
Please, Sign In to add comment