基本概念看http://en.wikipedia.org/wiki/Gaussian_blur,有一个新的概念是linearly separable, 原本是一个有权值组成的方形矩阵来对周围的pixel做加权和,现在分开horizaontal and vertical direction方向各一个pass来先后做,好处是什么?提高performance, 对每一个pixel的求值从width * height个乘法降低到width + height个。
例如对于blur宽度是5的情况, 有以下两个预想求得的table值 (取不同的宽度值就对应不同的两个tables. 至于这些table值是怎么求出来的,standard deviation去什么值, 是不是直接代入坐标算出来的呢?有待考证):
static float const blurOffsets5[] = { -4.37988, -2.43235, -0.486391, 1.45925, 3.40585, 5 };
static float const blurWeights5[] = {0.0953448, 0.200199, 0.275104, 0.24745, 0.145682, 0.0362198 };
那么水平(or 竖直)一个方向的blur结果就是:
for (index = 0; index < 5; ++index) {
pixel += read_imagef(srcImage, 当前坐标 + (float2)(blurOffsets5[index], 0.0f)) * blurWeights5[index];
}
另一个话题 Guassian distribution,(normal distribution).
一维情况下,这个高斯分布(正态分布)的curve的函数是 那么为什么高斯分布在自然中这么常见呢?甚至说一个学校里面学生的考试成绩也是成高斯分布。Central Limit Theorem 是一种解释. "In its simplest form, the Central Limit Theorem states that a sum of random numbers becomes normally distributed as more and more of the random numbers are added together. It does not require the individual random numbers be from any particular distribution, or even that the random numbers be from the same distribution"[The Scientist and Engineer's Guide to Digital Signal Processing, Steven W. Smith].
没有评论:
发表评论