'PSNR error with operands, different shapes
hi guys
am using a code to apply a Wiener filter on a noisy image, the code source
and it worked and everything seemed to be okay until I went to measure the PSNR value, and did not work, I used this method to measure PSNR :
def PSNR(original, compressed):
mse = np.mean((original - compressed) ** 2)
if(mse == 0):
return d
max_pixel = 255.0
psnr = 20 * log10(max_pixel / sqrt(mse))
return psnr
original = img
compressed = filtered_img
value = PSNR(original, compressed)
print("noisy = ",value)
The error message is :
ValueError Traceback (most recent call last)
<ipython-input-18-f21fe64cbb4c> in <module>()
73 original = img
74 compressed = filtered_img
---> 75 value = PSNR(original, compressed)
76 print("noisy = ",value)
<ipython-input-6-7d8e6558cdd2> in PSNR(original, compressed)
2
3 def PSNR(original, compressed):
----> 4 mse = np.mean((original - compressed) ** 2)
5 if(mse == 0):
6 return d
ValueError: operands could not be broadcast together with shapes (512,512) (498,498)
I want to use this code to denoise an image with speckle or Gaussian noise, but I need PSNR calculation to identify or measure the denoising process.
so pls help me fix this problem, thanks in advance
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
