how can i add noise to a picture with snr= 5dB?

3 visualizzazioni (ultimi 30 giorni)
agelos
agelos il 4 Mag 2011
Risposto: HSIN-YUAN CHEN il 23 Lug 2023
how can i add noise to a picture with snr= 5dB?

Risposte (1)

HSIN-YUAN CHEN
HSIN-YUAN CHEN il 23 Lug 2023
Hi,
To add noise to an image with a specific Signal-to-Noise Ratio (SNR) in MATLAB:
% Load and convert image to double
I = double(imread('path_to_your_image.jpg'));
% Compute signal power and calculate noise power for desired SNR
P_signal = var(I(:));
P_noise = P_signal / 10^(5 / 10); % 5 dB SNR
% Generate noise and add it to the image
noise = sqrt(P_noise) * randn(size(I));
I_noisy = I + noise;
% Display the noisy image
imshow(uint8(I_noisy));
Code assumes grayscale, no pixel checks; adjust as needed.
Hope this helps.

Tag

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by