compare_images.py 995 B

123456789101112131415161718192021222324252627282930313233
  1. # main imports
  2. import os, sys, argparse
  3. # image processing imports
  4. from PIL import Image
  5. import ipfml.iqa.fr as fr
  6. def main():
  7. parser = argparse.ArgumentParser(description="Compute .csv dataset file")
  8. parser.add_argument('--reference', type=str, help='Reference image')
  9. parser.add_argument('--reconstructed', type=str, help='Image to compare')
  10. parser.add_argument('--iqa', type=str, help='Image to compare', choices=['ssim', 'mse', 'rmse', 'mae', 'psnr'])
  11. args = parser.parse_args()
  12. param_reference = args.reference
  13. param_reconstructed = args.reconstructed
  14. param_iqa = args.iqa
  15. reference_image = Image.open(param_reference)
  16. reconstructed_image = Image.open(param_reconstructed)
  17. try:
  18. fr_iqa = getattr(fr, param_iqa)
  19. except AttributeError:
  20. raise NotImplementedError("FR IQA `{}` not implement `{}`".format(fr.__name__, param_iqa))
  21. print(fr_iqa(reference_image, reconstructed_image))
  22. if __name__== "__main__":
  23. main()