()
| 23 | |
| 24 | |
| 25 | def main() -> None: |
| 26 | dir_path = os.path.dirname(os.path.realpath(__file__)) |
| 27 | # Loading images (original image and compressed image) |
| 28 | original = cv2.imread(os.path.join(dir_path, "image_data/original_image.png")) |
| 29 | contrast = cv2.imread(os.path.join(dir_path, "image_data/compressed_image.png"), 1) |
| 30 | |
| 31 | original2 = cv2.imread(os.path.join(dir_path, "image_data/PSNR-example-base.png")) |
| 32 | contrast2 = cv2.imread( |
| 33 | os.path.join(dir_path, "image_data/PSNR-example-comp-10.jpg"), 1 |
| 34 | ) |
| 35 | |
| 36 | # Value expected: 29.73dB |
| 37 | print("-- First Test --") |
| 38 | print(f"PSNR value is {peak_signal_to_noise_ratio(original, contrast)} dB") |
| 39 | |
| 40 | # # Value expected: 31.53dB (Wikipedia Example) |
| 41 | print("\n-- Second Test --") |
| 42 | print(f"PSNR value is {peak_signal_to_noise_ratio(original2, contrast2)} dB") |
| 43 | |
| 44 | |
| 45 | if __name__ == "__main__": |
no test coverage detected