Peak signal-to-noise (PSNR) , signal-to-noise ratio (SNR)
Code: "image_snr.py". Programming language: Python DMelt Version 2.4. Last modified: 03/03/2021. License: Pro
https://datamelt.org/code/cache/image_snr_6653.py
To run this script using the DMelt IDE, copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.


"""
The signal-to-noise ratio (SNR) is measure of the sensitivity of 
imaging. Industry standards measure SNR in decibels (dB) of power and therefore apply the 10 log rule to the "pure" SNR ratio
Peak signal-to-noise ratio, often abbreviated PSNR, is the ratio between the maximum possible 
power of a signal and the power of corrupting noise that affects the fidelity of its representation.
"""
from Catalano.Imaging.Tools import ObjectiveFidelity
from Catalano.Imaging  import FastBitmap
from jhplot import *

print Web.get("https://datamelt.org/examples/data/logo_jhepwork.png")
print Web.get("https://jdatamelt.org/examples/data/logo_jhepwork_noisy.png")

original=FastBitmap("logo_jhepwork.png")
original.toGrayscale()
reconstructed=FastBitmap("logo_jhepwork_noisy.png")
reconstructed.toGrayscale()
#print original.getGrayData()
#print original.getSize()

img=ObjectiveFidelity(original,reconstructed)
print "Mean square signal-to-noise ratio (SNR)",img.getSNR()

#  Reference: A New Objective Fidelity Criterion For Image Processing: Derivative SNR - Hakki Tarkan Yalazan, and Melek D. Yucel.
print "Derivative Signal noise ratio=",img.getDSNR()
print "Peak signal-to-noise ratio (PSNR)=",img.getPSNR()

#  References: Wang, Zhou, and Alan C. Bovik. "A universal image quality index." Signal Processing Letters, IEEE 9.3 (2002): 81-84.
print "Universal Quality Index",img.getUniversalQualityIndex()



Ads help maintain this website.