【问题标题】:how to apply 2d and 3d filters in python如何在 python 中应用 2d 和 3d 过滤器
【发布时间】:2020-05-05 04:12:10
【问题描述】:

我想在 python 中找到一个应用 2d 过滤器或 3d 过滤器的函数。该函数应该接收过滤函数和数据。 就像 Matlab 中的函数 filter2imfilter, 或者像python中的函数scipy.ndimage.gaussian_filter(),它可以处理N维但仅适用于高斯过滤器(我希望过滤器成为一个参数)

我想我可以编写一个使用多维卷积 (scipy.ndimage.convolve()) 应用过滤器的函数,但是对于一维过滤器我没有成功。 我用于一维过滤的代码: signal.convolve(signal, filter_, mode='same', method='auto'),它给出的结果与函数 signal.filtfilt(filter_, 1, signal, padlen=len(signal)-1) 不同。

是否有应用 N-D 滤镜的功能? 如果没有,我该如何使用卷积函数?

谢谢!

【问题讨论】:

    标签: python scipy filtering signal-processing


    【解决方案1】:

    scipy.ndimage.generic_filter(input, function, size, footprint) 可能会有所帮助。

    这里是文档scipy.ndimage.generic_filter 和用法tutorial

    您可以使用footprintsize 来设计过滤器范围。例如size = 3footprint = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]设置以当前点为核心的3*3*3数组。 function 将其作为一维数组并返回您想要的标量。您可以将function(array) 定义为您的自定义过滤器。 泛型过滤器会用过滤器遍历input,默认用mode = 'reflect处理边界。

    【讨论】:

      猜你喜欢
      • 2022-12-22
      • 2018-09-19
      • 2012-09-18
      • 2012-11-24
      • 2020-05-26
      • 1970-01-01
      • 2021-09-21
      • 2018-06-02
      • 2020-12-04
      相关资源
      最近更新 更多