我想知道如何使用python
或任何相关的图像库(如ndimage
)智能锐化图像,skimage
甚至是PIL
。我可以找到一些方法来锐化我的图像,但是在放大时会有很多噪声和像素。所以自从我知道Photoshop
之后,我就试图获得那种智能的锐化效果,这种效果可以通过python以较少的噪声和良好的对比度锐化图像,但我失败了。
注:-
(1) 试验方法:
>>> # The 1st Method:
>>> import Image
>>> import ImageFilter
>>> image.filter(ImageFilter.SHARPEN)
>>> Image.filter(ImageFilter.EDGE_ENHANCE_MORE) #Look down:1st image created
>>> # The 2nd Method:
>>> blurred_l=scipy.ndimage.gaussian_filter(b,3)
>>> filter_blurred_l = scipy.ndimage.gaussian_filter(blurred_l, 1)
>>> alpha =30
>>> sharpened = blurred_l + alpha * (blurred_l - filter_blurred_l)
>>> # The 3rd Method:
>>> shar=imfilter(Image,'sharpen') #Look down:2nd image created
(2)我发现了一段代码,但它在Perl
中。我只知道Python
In here或 directly
(3) 下面是使用上述方法的两个锐化图像,第三个是使用smartsharp完成的:
原始
Original image http://imageshack.us/a/img600/6640/babyil.jpg
第一次……………第二次
1st http://imageshack.us/a/img803/3897/sharp1.png2nd http://imageshack.us/a/img809/2235/sharp2.png
第三个目标>;这就是我想要的效果
3rd http://imageshack.us/a/img832/4563/smartsharp.jpg
(4) 下面是我用来创建上面第三个图像的工具:
smrsharpm http://imageshack.us/a/img210/2747/smartsharpentoolm.jpgsmrsharp http://imageshack.us/a/img193/490/smartsharpentool.jpg
Photoshop的“智能锐化”功能在内部使用了一种称为反褶积的数学运算。
numpy
确实有一个deconvolve()
函数,该函数可能已被压入此任务的服务中,但我找不到现成的函数来专门使用numpy
进行智能锐化,因此您可能需要自己编写代码。另一种方法是使用GIMP。有一个GIMP插件(直观地命名为“G'Mic”)将在其他锐化算法中进行反褶积,您可以使用Python自动实现GIMP。
不幸的是,如果不能访问Photoshop代码,很难知道“智能锐化”的功能。同时,你可以尝试混合一个不锐化的面具,总的变化过滤和一些颜色调整(也许有点色调提升)。
另请参见:http://www.kenrockwell.com/tech/photoshop/sharpening.htm#
更新:以下是如何从图像中移除运动模糊的示例:
https://github.com/stefanv/scikit-image-demos/blob/master/clock_deblur.py
(时钟映像位于同一存储库中)。不幸的是,scikit图像目前还没有成熟的去模糊/逆滤波技术——但我们正在研究它!
相关问题 更多 >
编程相关推荐