日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

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

發布時間:2024/1/23 python 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python高通滤波,高通滤波器使用scipy / numpy在python中进行图像处理 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

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()

總結

以上是生活随笔為你收集整理的python高通滤波,高通滤波器使用scipy / numpy在python中进行图像处理的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。