python高斯滤波和降噪_高斯滤波器和高斯滤波器中sigma与带宽的关系
例如,我可以通过在gaussian_filter(左图)中设置sigma=2.和在{}(右绘图)中设置bw_method=sigma/30.来获得以下绘图:
(MWE在问题的底部)
很明显,这些参数之间有一个关系,因为一个是高斯滤波器,另一个是高斯核密度估计。在
每个参数的定义是:sigma : scalar or sequence of scalars Standard deviation for Gaussian
kernel. The standard deviations of the Gaussian filter are given for
each axis as a sequence, or as a single number, in which case it is
equal for all axes.
根据高斯算子的定义,我可以理解这一点:
bw_method : str, scalar or callable, optional The method used to
calculate the estimator bandwidth. This can be ‘scott’, ‘silverman’, a
scalar constant or a callable. If a scalar, this will be used directly
as kde.factor. If a callable, it should take a gaussian_kde instance
as only parameter and return a scalar. If None (default), ‘scott’ is
used. See Notes for more details.
在本例中,假设bw_method的输入是标量(float),以便与sigma相比较。这里是我迷路的地方,因为我在任何地方都找不到关于这个kde.factor参数的信息。在
我想知道的是,如果可能的话,连接这两个参数的精确数学方程(即:当使用float时,sigma和{})。在
MWE:import numpy as np
from scipy.stats import gaussian_kde
from scipy.ndimage.filters import gaussian_filter
import matplotlib.pyplot as plt
def rand_data():
return np.random.uniform(low=1., high=200., size=(1000,))
# Generate 2D data.
x_data, y_data = rand_data(), rand_data()
xmin, xmax = min(x_data), max(x_data)
ymin, ymax = min(y_data), max(y_data)
# Define grid density.
gd = 100
# Define bandwidth
bw = 2.
# Using gaussian_filter
# Obtain 2D histogram.
rang = [[xmin, xmax], [ymin, ymax]]
binsxy = [gd, gd]
hist1, xedges, yedges = np.histogram2d(x_data, y_data, range=rang, bins=binsxy)
# Gaussian filtered histogram.
h_g = gaussian_filter(hist1, bw)
# Using gaussian_kde
values = np.vstack([x_data, y_data])
# Data 2D kernel density estimate.
kernel = gaussian_kde(values, bw_method=bw / 30.)
# Define x,y grid.
gd_c = complex(0, gd)
x, y = np.mgrid[xmin:xmax:gd_c, ymin:ymax:gd_c]
positions = np.vstack([x.ravel(), y.ravel()])
# Evaluate KDE.
z = kernel(positions)
# Re-shape for plotting
z = z.reshape(gd, gd)
# Make plots.
fig, (ax1, ax2) = plt.subplots(1, 2)
# Gaussian filtered 2D histograms.
ax1.imshow(h_g.transpose(), origin='lower')
ax2.imshow(z.transpose(), origin='lower')
plt.show()
python高斯滤波和降噪_高斯滤波器和高斯滤波器中sigma与带宽的关系相关推荐
- python高斯滤波和降噪_高斯滤波原理及python实现
高斯滤波器时一种线性平滑滤波器,主要适用处理高斯噪声,所以在了解高斯滤波之前,我们首先熟悉一下高斯噪声.噪声在图像中表现的通常是引起视觉效果的孤立像素点和像素块,简单说噪声点就是会给图像带来干扰,让图 ...
- python高斯滤波和降噪_python添加高斯噪声和椒盐噪声,实现中值滤波和均值滤波,实现Roberts算子和Sobel算子...
写在前面 HIT大三上学期视听觉信号处理课程中视觉部分的实验一,经过和学长们实验的对比发现每一级实验要求都不一样,因此这里标明了是2019年秋季学期的视觉实验一. 由于时间紧张,代码没有进行任何优化, ...
- python实现洗牌算法_洗牌算法及 random 中 shuffle 方法和 sample 方法浅析
对于算法书买了一本又一本却没一本读完超过 10%,Leetcode 刷题从来没坚持超过 3 天的我来说,算法能力真的是渣渣.但是,今天决定写一篇跟算法有关的文章.起因是读了吴师兄的文章 <扫雷与 ...
- python打开文件夹对话框_文件对话框打开文件夹中的文件(tkinter)
我想把它实现到我自己的代码中,但是当我运行这个(没有我的代码,只有你看到的代码)时,所有显示的文件夹都是空的,我实际上不能打开任何东西.在from tkinter import * from tkin ...
- python random.choice报错_如何解决mtrand.RandomState.choice中的内存错误...
我试图从1e5字符串中抽取1e7个项目,但是出现内存错误.从1e4字符串中抽取1e6项是很好的.我在64位机器上使用4GB RAM,并且不认为我应该在1e7达到任何内存限制.有任何想法吗? $pyth ...
- python查询数据库带逗号_浅谈pymysql查询语句中带有in时传递参数的问题
直接给出例子说明: cs = conn.cursor() img_ids = [1,2,3] sql = "select img_url from img_url_table where i ...
- python treeview文本自动换行显示_在tkinter.ttk.Treeview列中设置文本格式
我想知道如何调整ttk.Treeview列中的文本.下面是我的意思的一个例子.请注意日期和数字之间的位置不正确.我认为这和间距有关,但我可能错了. 编辑:用Python 3编写.#! coding=u ...
- python如何删除对象属性_如何优雅的删除对象中的指定属性?
要优雅的话,使用 Lodash 的 omit 方法移除不要的属性: const object = { 'a': 1, 'b': '2', 'c': 3 }; const result = _.omit ...
- python项目开发案例集锦_在线分享 | 在 VS Code 中一站式完成 Python 项目开发
往期活动回顾 VS Code 中文社区自成立以来,已经举办了4场活动: Workshop | First Step to VS Code 基础篇 Workshop | First Step to VS ...
- python循环写入csv文件_从for循环和列表中写入.csv文件
我可能会改变这个:for filename in os.listdir (image_path): print filename print len(filename) 有点像lines = list ...
最新文章
- Android:ViewPager为页卡内视图组件添加事件
- 项目发布错误的解决方法
- sdut-1148 相加和最大值
- 第06课:浅层神经网络(NN)
- php 输出json utf8,php json_encode utf-8中文问题
- unsigned int mysql_mysql 中int类型字段unsigned和signed的探索
- JspWriter 与 printwriter区别
- RH413--在RHEL6.4下测试nosuid和noexec选项
- Bailian2759 神奇的口袋(2)【DP】
- python利器app怎么查文献-基于Python的参考文献检索工具开发
- 如何通过 onstat 命令监控GBase8s数据库
- Excel 2010 SQL应用096 聚合函数之标准偏差及标准差
- JAVA的简单数据类型和复合数据类型
- 数模电路基础知识 —— 1. 回路中的电压、电流、电阻、电功率计算式
- 富士康计算机类笔试题,富士康2021校招技术类笔试题
- 2008年公休假安排:
- 计算机组成原理swbus,计算机组成原理实验 2.1 总线与寄存器 赖晓铮.ppt
- notepad++ 16进制数字加前缀0x
- sql中完全依赖,部分依赖,传递依赖关系
- Unity角色同时播放两个音效(走路音效+说话音效)