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

3 ビュー (過去 30 日間)
agelos
agelos 2011 年 5 月 4 日
回答済み: HSIN-YUAN CHEN 2023 年 7 月 23 日
how can i add noise to a picture with snr= 5dB?

回答 (1 件)

HSIN-YUAN CHEN
HSIN-YUAN CHEN 2023 年 7 月 23 日
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.

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by