mirror of
https://hub.njuu.cf/TheAlgorithms/Python.git
synced 2023-10-11 13:06:12 +08:00
make images' path specific (#671)
fixed wrong image's path while debuggin in VSCode
This commit is contained in:
parent
f6d241e52d
commit
ad0bc2bb8b
@ -4,6 +4,7 @@
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import math
|
import math
|
||||||
|
import os
|
||||||
|
|
||||||
import cv2
|
import cv2
|
||||||
import numpy as np
|
import numpy as np
|
||||||
@ -18,18 +19,18 @@ def psnr(original, contrast):
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
dir_path = os.path.dirname(os.path.realpath(__file__))
|
||||||
# Loading images (original image and compressed image)
|
# Loading images (original image and compressed image)
|
||||||
original = cv2.imread('original_image.png')
|
original = cv2.imread(os.path.join(dir_path, 'original_image.png'))
|
||||||
contrast = cv2.imread('compressed_image.png', 1)
|
contrast = cv2.imread(os.path.join(dir_path, 'compressed_image.png'), 1)
|
||||||
|
|
||||||
original2 = cv2.imread('PSNR-example-base.png')
|
original2 = cv2.imread(os.path.join(dir_path, 'PSNR-example-base.png'))
|
||||||
contrast2 = cv2.imread('PSNR-example-comp-10.jpg', 1)
|
contrast2 = cv2.imread(os.path.join(dir_path, 'PSNR-example-comp-10.jpg'), 1)
|
||||||
|
|
||||||
# Value expected: 29.73dB
|
# Value expected: 29.73dB
|
||||||
print("-- First Test --")
|
print("-- First Test --")
|
||||||
print(f"PSNR value is {psnr(original, contrast)} dB")
|
print(f"PSNR value is {psnr(original, contrast)} dB")
|
||||||
|
|
||||||
# # Value expected: 31.53dB (Wikipedia Example)
|
# # Value expected: 31.53dB (Wikipedia Example)
|
||||||
print("\n-- Second Test --")
|
print("\n-- Second Test --")
|
||||||
print(f"PSNR value is {psnr(original2, contrast2)} dB")
|
print(f"PSNR value is {psnr(original2, contrast2)} dB")
|
||||||
|
Loading…
Reference in New Issue
Block a user