compare_images.py 953 B

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