how can i add noise to a picture with snr= 5dB?
14 views (last 30 days)
Show older comments
how can i add noise to a picture with snr= 5dB?
0 Comments
Answers (1)
HSIN-YUAN CHEN
on 23 Jul 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.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!