高斯模糊

来源:互联网 发布:监控网络防雷器 20ka 编辑:程序博客网 时间:2024/06/03 06:42
转自:GuassBlur(高斯模糊)
GuassBlur(高斯模糊)

C++原型:

void __stdcall GuassBlur(unsigned char *Src, unsigned char *Dest, int Width, int Height, int Stride, float Radius)

C#声明:

[DllImport("ImageProcessing.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Unicode, ExactSpelling = true)]internal static extern void GuassBlur(byte* Src, byte *Dest, int Width, int Height, int Stride, float Radius);

VB.NET声明:

<DllImport("ImageProcessing.dll", CallingConvention := CallingConvention.StdCall, CharSet := CharSet.Unicode, ExactSpelling := True)> _Friend Shared Sub GuassBlur(ByVal Src As IntPtr, ByVal Dest As IntPtr, ByVal Width As Integer, ByVal Height As Integer, ByVal Stride As Integer, ByVal Radius As Single) End Sub

VB6.0声明:

Private Declare Sub GuassBlur Lib "ImageProcessing" (ByVal Src As Long, ByVal Dest As Long, ByVal Width As Long, ByVal Height As Long, ByVal Stride As Long, ByVal Radius As Single)

函数说明:

复制代码
/// <summary>/// 实现图像高斯模糊效果,O(1)复杂度,最新整理时间 2014.9.19。/// 参考论文:Recursive implementation of the Gaussian filter/// </summary>/// <param name="Src">源图像数据在内存的起始地址。</param>/// <param name="Dest">目标图像数据在内存的起始地址。</param>/// <param name="Width">源和目标图像的宽度。</param>/// <param name="Height">源和目标图像的高度。</param>/// <param name="Stride">图像的扫描行大小。</param>/// <param name="Radius">方框模糊的半径,有效范围[0.1,1000]。</param>/// <remarks> 1: 能处理8位灰度和24位图像。</remarks>/// <remarks> 2: Src和Dest可以相同,相同和不同速度上无区别。</remarks>/// <remarks> 3: 使用了多线程,可加快执行速度。</remarks>
复制代码

算法效果:

    

处理速度:

  I3  M380 2.53GHZ 笔记本上测试:1000 * 1000 彩色像素,用时52ms(时间是于参数无关的)。

代码情况:

     本算法是从GIMP的Retinex代码中提取的高斯模糊,其算法原理参考论文Recursive implementation of the Gaussian filter,算法本质上适合于并行编程。

其他说明:

   无论是图像编辑软件(如Photoshop),还是图像增强识别方面,GuassBlur 函数都可以说是最基础最基础也是应用场合最多的函数,因此对于该函数的优化是一个优异图像处理软件的基本要求,本函数在优化时勾选了系统的SSE优化。

                                         

                                                                    BoxBlur/LinearBlur/GuassBlur权重曲线示例 

0 0