【问题标题】:fspecial alternatives for Gaussian filterf 高斯滤波器的特殊替代品
【发布时间】:2013-03-04 18:37:19
【问题描述】:

我正在尝试使用需要使用图像处理工具箱函数fspecial() 的 MATLAB 脚本。

我没有图像处理工具箱,但有信号处理工具箱,其中包含用于创建过滤器的工具套件。可悲的是,我在很大程度上对滤波器的创建一无所知,我想看看是否可以帮助我确定是否可以使用信号处理工具箱中的滤波器创建工具复制以下代码行:

fspecial('gaussian', [5 1], 0.75)

【问题讨论】:

    标签: matlab filter signal-processing gaussian


    【解决方案1】:

    fspecial() 创建一组用户指定的二维过滤函数,并提供一组默认值。

    以下函数将产生等效的二维高斯函数。当使用选项'gaussian'. 运行时,它也是fspecial 中的实现

    您可以通过h = gaussian2D([5 1], 0.75); 调用它,例如。

    %% 2D Gaussian filter
    function h = gaussian2D(siz, std)
    
    % create the grid of (x,y) values
    siz = (siz-1)./2;
    [x,y] = meshgrid(-siz(2):siz(2),-siz(1):siz(1));
    
    % analytic function
    h = exp(-(x.*x + y.*y)/(2*std*std));
    
    % truncate very small values to zero
    h(h<eps*max(h(:))) = 0;
    
    % normalize filter to unit L1 energy 
    sumh = sum(h(:));
    if sumh ~= 0
        h = h/sumh;
    end
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-10-03
      • 1970-01-01
      • 1970-01-01
      • 2013-03-29
      • 1970-01-01
      • 2018-01-26
      • 2013-02-01
      • 1970-01-01
      相关资源
      最近更新 更多