MCPcopy Create free account
hub / github.com/geekcomputers/Python / main

Function main

Compression_Analysis/PSNR.py:18–37  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

16
17
18def main():
19 # Loading images (original image and compressed image)
20 orignal_image = cv2.imread("orignal_image.png", 1)
21 compressed_image = cv2.imread("compressed_image.png", 1)
22
23 # Getting image height and width
24 height, width = orignal_image.shape[:2]
25
26 orignalPixelAt = calculate(orignal_image)
27 compressedPixelAt = calculate(compressed_image)
28
29 diff = orignalPixelAt - compressedPixelAt
30 error = np.sum(np.abs(diff) ** 2)
31
32 error = error / (height * width)
33
34 # MSR = error_sum/(height*width)
35 PSNR = -(10 * math.log10(error / (255 * 255)))
36
37 print("PSNR value is {}".format(PSNR))
38
39
40if __name__ == "__main__":

Callers 1

PSNR.pyFile · 0.70

Calls 1

calculateFunction · 0.70

Tested by

no test coverage detected