python高通滤波_高通滤波器使用scipy / numpy在python中进行图像处理

1586010002-jmsa.png

I am currently studying image processing. In Scipy, I know there is one median filter in Scipy.signal. Can anyone tell me if there is one filter similar to high pass filter?

Thank you

解决方案

"High pass filter" is a very generic term. There are an infinite number of different "highpass filters" that do very different things (e.g. an edge dectection filter, as mentioned earlier, is technically a highpass (most are actually a bandpass) filter, but has a very different effect from what you probably had in mind.)

At any rate, based on most of the questions you've been asking, you should probably look into scipy.ndimage instead of scipy.filter, especially if you're going to be working with large images (ndimage can preform operations in-place, conserving memory).

As a basic example, showing a few different ways of doing things:

import matplotlib.pyplot as plt

import numpy as np

from scipy import ndimage

import Image

def plot(data, title):

plot.i += 1

plt.subplot(2,2,plot.i)

plt.imshow(data)

plt.gray()

plt.title(title)

plot.i = 0

# Load the data...

im = Image.open('lena.png')

data = np.array(im, dtype=float)

plot(data, 'Original')

# A very simple and very narrow highpass filter

kernel = np.array([[-1, -1, -1],

[-1, 8, -1],

[-1, -1, -1]])

highpass_3x3 = ndimage.convolve(data, kernel)

plot(highpass_3x3, 'Simple 3x3 Highpass')

# A slightly "wider", but sill very simple highpass filter

kernel = np.array([[-1, -1, -1, -1, -1],

[-1, 1, 2, 1, -1],

[-1, 2, 4, 2, -1],

[-1, 1, 2, 1, -1],

[-1, -1, -1, -1, -1]])

highpass_5x5 = ndimage.convolve(data, kernel)

plot(highpass_5x5, 'Simple 5x5 Highpass')

# Another way of making a highpass filter is to simply subtract a lowpass

# filtered image from the original. Here, we'll use a simple gaussian filter

# to "blur" (i.e. a lowpass filter) the original.

lowpass = ndimage.gaussian_filter(data, 3)

gauss_highpass = data - lowpass

plot(gauss_highpass, r'Gaussian Highpass, $\sigma = 3 pixels$')

plt.show()

M24re.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值