当前位置:网站首页>UnityShader-高斯模糊
UnityShader-高斯模糊
2022-07-27 05:21:00 【122&&113】
在图像处理中的模糊效果常常可以使用均值模糊,中值模糊,高斯模糊。
这里主要记录一下对UnityShader入门精要中高斯模糊的理解。
高斯滤波:
G ( x , y ) = 1 2 π σ 2 e − x 2 + y 2 2 σ 2 G(x,y) = \frac{1}{2\pi\sigma^2}e^{-\frac{x^2+y^2}{2\sigma^2}} G(x,y)=2πσ21e−2σ2x2+y2
x , y x, y x,y 对应当前位置到卷积核中心的整数距离。通过高斯滤波,我们可以计算当前位置对中心位置的像素权重贡献。
1. 降低时间复杂度
这里对时间复杂度降低的策略进行的一个理解。
首先假设有一个 5 × 5 5\times5 5×5 的高斯核矩阵 A 5 × 5 A_{5\times5} A5×5 ,其中 A i j A_{ij} Aij 就是通过高斯滤波算出来的 { i , j } \{ i,j\} { i,j} 处的权重值,为了图像权重加起来为1以防止图像变暗,因此还需要做归一化处理。
如果按照 A A A 矩阵来实现高斯模糊,那么需要采样 N × N × W × H N\times N\times W\times H N×N×W×H 次,其中 W , H W,H W,H是图像的高宽。
有趣的地方来了,通过计算发现,我们可以先对水平方向采样 N × W × H N\times W\times H N×W×H 次, 获得在水平方向上的权重值 B B B,然后再对 B B B 在竖直方向上采样 N × W × H N\times W\times H N×W×H 次,获得 C C C。通过这两步操作得到的结果和直接采样 N × N × W × H N\times N\times W\times H N×N×W×H 次是一样的。但是后者总共只需要采样 2 × N × W × H 2\times N\times W\times H 2×N×W×H 次。
仔细观察可以发现:
C × B = A C \times B = A C×B=A
边栏推荐
- [first song] deep learning of rebirth -keras (elementary)
- Redis在windows下的idea连接不上问题
- 开源WebGIS-相关知识
- [song] rebirth of me in py introductory training (7): function call
- What has been updated in the Chinese version of XMIND mind map 2022 v12.0.3?
- VSCode解决运行ipynb文件使用卡顿问题
- [first song] rebirth of me in py introductory training (3): if conditional sentence
- arcgis for js api-入门系列
- [5.20 special] MATLAB, I'm confessing to you
- 【头歌】重生之我在py入门实训中(12):Matplotlib接口和常用图形
猜你喜欢
随机推荐
百问网驱动大全学习(二)I2C驱动
Unity 引擎开始从 Mono 迁移到 .NET CoreCLR
Unity 窗口界面的简单介绍
【头歌】重生之数据科学导论——回归进阶
链表回文判断
Can it replace PS's drawing software?
pycharm安装及导入项目注意事项
PZK学C语言之字符串函数(一)
哈希表的原理及哈希冲突的解决方法
力扣题解 动态规划(5)
【头歌】重生之我在py入门实训中(6):函数的定义与应用
Xmind 思维导图 2022 v12.0.3中文版更新了哪些内容?
Leetcode one question per day 30. Concatenate substrings of all words
[song] rebirth of me in py introductory training (8): module
2021-06-26
[song] rebirth of me in py introductory training (9): exception handling
【动态规划----钢条切割问题】
AE 3D particle system plug-in: Trapcode particle
Unity 桌面7.6 版本解读
[song] rebirth of me in py introductory training (7): function call









