Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] conflict about the SNR in image

Status
Not open for further replies.

Serwan Bamerni

Member level 2
Joined
Dec 21, 2014
Messages
45
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Activity points
367
Hi everyone

I am trying to add noise of 5dB to an image in matlab according to the following steps

Code:
SNR = 5;
Im = double(Io) / 255;
vm = var(Im(:)) / 10^(SNR/10);
I_my_noisy = imnoise(Im, 'gaussian', 0, vm);

where Io is the readed original image

but when I measure the SNR by using the matlab command

Code:
[peaksnr,snr] = psnr(I_my_noisy, Im)

I get SNR equal 10. So, what is the wrong in my code? and why the result differ from my add dB?
 

Hi everyone

I went deeply in calculating the SNR for image in my case and I found that the add SNR is obtained via the following code

Code:
Error = I_my_noisy - Im;
SNR = 10*log10(var(Im(:))/var(Error(:)));

and that differ from the result obtained from the direct matlab function

Code:
[peaksnr,snr] = psnr(I_my_noisy, Im)

that calculate the power ratio between signal and noise
 

I presume the noise is being measured as power and is being defined as 20 log xxx.

You need to modify your code:
Code:
vm = var(Im(:)) / 10^(SNR/10);

and try again and see. I do not see any conflict.
 

Please check the help menu on psnr. I do not have matlab and I use octave.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top