Skip to content

Commit

Permalink
make images' path specific (TheAlgorithms#671)
Browse files Browse the repository at this point in the history
fixed wrong image's path while debuggin in VSCode
  • Loading branch information
raksa authored and yanglbme committed Dec 26, 2018
1 parent f6d241e commit ad0bc2b
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions analysis/compression_analysis/psnr.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"""

import math
import os

import cv2
import numpy as np
Expand All @@ -18,18 +19,18 @@ def psnr(original, contrast):


def main():

dir_path = os.path.dirname(os.path.realpath(__file__))
# Loading images (original image and compressed image)
original = cv2.imread('original_image.png')
contrast = cv2.imread('compressed_image.png', 1)
original = cv2.imread(os.path.join(dir_path, 'original_image.png'))
contrast = cv2.imread(os.path.join(dir_path, 'compressed_image.png'), 1)

original2 = cv2.imread('PSNR-example-base.png')
contrast2 = cv2.imread('PSNR-example-comp-10.jpg', 1)
original2 = cv2.imread(os.path.join(dir_path, 'PSNR-example-base.png'))
contrast2 = cv2.imread(os.path.join(dir_path, 'PSNR-example-comp-10.jpg'), 1)

# Value expected: 29.73dB
print("-- First Test --")
print(f"PSNR value is {psnr(original, contrast)} dB")

# # Value expected: 31.53dB (Wikipedia Example)
print("\n-- Second Test --")
print(f"PSNR value is {psnr(original2, contrast2)} dB")
Expand Down

0 comments on commit ad0bc2b

Please sign in to comment.