[db:标题]

摘要:早年就接触过小波的概念,那个时候看什么小波十讲这类的,看的可真谓云里雾里,一大堆数学公式,头大的要死。做去噪的时候也看很多人说小波去噪算法效果不错,最近定心的去研究了下GIMP里的小波分解插件,有一些心得,一起分享给大家。
早年就接触过小波的概念,那个时候看什么小波十讲这类的,看的可真谓云里雾里,一大堆数学公式,头大的要死。做去噪的时候也看很多人说小波去噪算法效果不错,不过网络上有的都是matlab代码,而matlab的小波包里的函数是已经写好的内嵌函数,是无法看到代码的。因此,一直以来,也从未想过自己动手写个小波去噪之类的效果。 偶尔翻阅了一下GIMP软件的菜单,再次看到了在其Filters-->Enhance菜单下有个wavelet-decompose菜单,点击一下,发现原图像是没有任何增强的效果的,但是在其图层界面里增加了一些列的图层,如下图所示:   后面搜索一些参考资料,大概明白了他的意识这个做分解是为后续的增强做铺垫的,因为他分解成了多个层后,可以单独对每个层进行一些特别的处理,GIMP官方的文档对其说明如下: This filter decomposes the active layer or selection into several layers, named“scales”, each of them containing a particular set of details. Finest details are in first layers and they become larger until you get to the last one, at bottom. This last layer is called“residual”and holds what is left after all detail layers have been removed; it represents the global contrast and colors of the image. Each of scale layers are set to combine using the Grain Merge layer mode. This means that pixels that have a 50% value will not affect the final result. So, painting a wavelet scale with neutral gray (R:50% G:50% B:50%) will erase details. Wavelet-decompose is a wonderful filter for skin smoothing and retouching, removing blemishes, wrinkles, spots from your photos. It can be used also for sharpening and local contrast enhancement and for removing stains, colors, tones. All this is well explained in tutorials mentioned above.   这个帮助最后提到这个分解可以用于皮肤光滑、磨皮、移除瑕疵、斑点等,或者做锐化以及局部增强等等功能。   似乎很是强大。   仔细看看GIMP分解后的图,我们发现他将图像分解为了多个图层,图层的数量取决用户界面的参数,比如选择5层,他实际上是生成了6个图层,额外增加了一个特殊的Residual(残余)层,我们试着尝试解析他的代码。 在GIMP的源代码里搜索wavelet,可以发现gimp-master\plug-ins\common这个目录下有个wavelet-decompose.c文件,再打开这个文件,稍微分析下这个代码,发现其中需要一个非常核心的函数:wavelet_blur,这个函数确没有在gimp-master这个文件夹里,而是在gegl-master这里。wavelet_blur函数又涉及到一个wavelet-blur-1d的文件。   得益于早年我翻译和抽取过很多GIMP的函数,以及自己对图像处理本身算法的了解,虽然GIMP的代码写的很晦涩,但是拼接多年的经验,还是成功的把这个代码抽取出来。
阅读全文