zoukankan      html  css  js  c++  java
  • matlab 工具函数(一) —— 添加指定 SNR 的噪声

    SNR=PsignalPnoise=10log10x=1Nxy=1Nyf2(x,y)x=1Nxy=1Ny(f(x,y)f^(x,y))2=20log10f(x,y)f^(x,y)f(x,y)=20log10f(x,y)noise

    根据信噪比(SNR)的值,是可以推知 noise 的:

    noise=f(x,y)10SNR/20

    • 这里的 f(x,y)f^(x,y) 其实就可以视为噪声;
      • 注意区别,噪声和含噪信号;
      • noisy = original + noise;
    fucntion [noisy, noise] = addnoise(signal, noise, snr)
    % signal:表示无噪图像,noise:噪声,snr,指定的 SNR 值;
    
    % 定义信噪比计算函数
    SNR = @(signal, noisy) 20*log10(norm(signal)/norm(signal-noisy));
    
    S = length(signal); N = length(noise);
    assert(N >= S);
    
    R = randi(1+N-S);
    noise = noise(R:R+S-1);
    
    noise = noise / norm(noise) * norm(signal) * 10^(0.05*snr);
            % 上文给出的计算公式;
    noisy = noise + signal;
    
    assert(abs(SNR(signal, noisy)) < 1e10*eps);
  • 相关阅读:
    代码大全2阅读笔记之最后总结
    web商品系统最终版
    web商品系统
    期末总结
    2020/12/13
    2020/12/12
    2020/12/11
    2020/12/10
    2020/12/09
    2020/12/08
  • 原文地址:https://www.cnblogs.com/mtcnn/p/9422660.html
Copyright © 2011-2022 走看看