RecursiveDomainTransformFilter(回溯DomainTransform边缘保留滤波)
C++原型:
void __stdcall RecursiveDomainTransformFilter(unsigned char *Src, unsigned char *Joint, unsigned char *Dest, int Width, int Height, int Stride, float SigmaS, float SigmaR, int Iteration)
C#声明:
[DllImport("ImageProcessing.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Unicode, ExactSpelling = true)] internal static extern void RecursiveDomainTransformFilter(byte* Src, byte* Joint, byte* Dest, int Width, int Height, int Stride, float SigmaS, float SigmaR, int Iteration);
VB.NET声明:
<DllImport("ImageProcessing.dll", CallingConvention := CallingConvention.StdCall, CharSet := CharSet.Unicode, ExactSpelling := True)> _ Friend Shared Sub RecursiveDomainTransformFilter (ByVal Src As IntPtr,ByVal Joint As IntPtr,ByVal Dest As IntPtr, ByVal Width As Integer, ByVal Height As Integer, ByVal Stride As Integer, Byval SigmaS as Single, Byval SigmaR As Single, Byval Iteration as Integer) End Sub
VB6.0声明:
Private Declare Sub RecursiveDomainTransformFilter Lib "ImageProcessing" (ByVal Src As Long, Byval Joint as Long, ByVal Dest As Long, ByVal Width As Long, ByVal Height As Long, ByVal StrideAs Long, Byval SigmaS as Single, Byval SigmaR as Single, byval Iteration as Long)
函数说明:
/// <summary> /// 实现基于Domain transform的快速回溯边缘保留滤波.,基于<Domain Transform for Edge-Aware Image and Video Processing>一文,2014.8.17日整理, 耗时4个小时 /// </summary> /// <param name="Src">图像数据部分在内存中的地址。</param> /// <param name="Joint">引导图的数据在内存中的地址,必须和原图具有相同的格式和大小,也可以直接用原图,那么就变成了普通的双边滤波了。</param> /// <param name="Dest">保存处理后的结果的图像数据在内存中的地址,必须和原图具有相同的格式和大小。</param> /// <param name="Width">图像的宽度。</param> /// <param name="Height">图像的高度。</param> /// <param name="Stride">图像的扫描行大小。</param> /// <param name="SigmaS">控制Spatial Kernel的大小,范围是(0,255],算法速度于这个参数无关。</param> /// <param name="SigmaR">控制Range Kernel的大小,范围是(0,255],算法速度于此变量无关。</param> /// <param name="Iteration">迭代次数,默认为3比较合理。</param> /// <remarks>1:Dest参数可以和Src可以相同。2:算法速度严重制约于pow函数,但网络上用于优化pow函数的代码有问题。 </remarks>
算法效果:
以上为SigmaS = 25,SigmaR = 50,Iteration =2时的处理结果。
处理速度:
I3 M380 2.53GHZ 笔记本上测试:1000 * 1000 彩色像素,用时150ms(Iteration = 2).
代码情况:
本代码是基于所提论文及论文配套代码可从网络上下载到(matlab)。算法本身可高度并行。