对图像进行去模糊以执行边缘检测 [英] Deblurring an image in order to perform edge detection

查看:299
本文介绍了对图像进行去模糊以执行边缘检测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这张图片:





我试图将背景聚焦,以便对图像执行边缘检测。可以使用的方法是什么(在
空间/频率上提交)?






我试过的如下:

  kernel = np.array([[ -  1,-1,-1],[ -  1, 9,-1],[ - ,-1,-1]])
im = cv2.filter2D(equ,-1,kernel)

输出此图片:





我也玩了中心值,但没有给出正面结果。



我也试过这个:

  psf = np.ones((5,5))/ 25 
equ = convolve2d(equ,psf,'same')
deconvolved = restoration.wiener(equ,psf,1,clip = False)
plt.imshow(deconvolved,cmap ='gray')

图片没有明显变化。



非常感谢任何有关此事的帮助!






编辑:



以下是我从

解决方案

去模糊图像(很遗憾)非常困难,其原因是模糊消除了噪点,因此有几个(嘈杂的)图像模糊时会产生相同的图像。这意味着当你进行去模糊时,计算机没有简单的方法可以选择哪个有噪声的图像。因此,去模糊通常会产生嘈杂的图像。



现在,您可能会问摄影师在现实中如何做到这一点。嗯,他们实际上并没有对图像进行去模糊,而是对图像进行锐化(这略有不同)。当您锐化图像时,可以增加边界附近的对比度以强调它们(这就是为什么有时会在图像上看到过于锐化的边框周围的光环)。



在你的情况下,你想要对它进行去模糊(并且没有允许你这样做的卷积内核)。要以一种好的方式做到这一点,你需要知道什么过程首先模糊了图像(即如果你不想花费数千美元购买特殊软件或者没有数学或天文学硕士学位) 。



如果您仍想这样做,我建议您搜索反卷积,如果您不知道模糊过程,则盲目反卷积。在skimage中有一些(粗略的)函数可能会有所帮助( http://scikit-image.org/docs/stable/auto_examples/filters/plot_restoration.html#sphx-glr-auto-examples-filters- plot-restoration-py )。



最后,Jax Briggs的最后一个链接似乎很有帮助,但我不会因为神奇的结果而交叉。


I have this image:

I am trying to put the background into focus in order to perform edge-detection on the image. What would be the methods available to me (either on space/frequency filed)?


What I tried is the following:

kernel = np.array([[-1,-1,-1], [-1,9,-1], [-1,-1,-1]])
im = cv2.filter2D(equ, -1, kernel)

This outputs this image:

I also played around with the centre value but with no positive result.

I also tried this:

psf = np.ones((5, 5)) / 25
equ = convolve2d(equ, psf, 'same')
deconvolved = restoration.wiener(equ, psf, 1, clip=False)
plt.imshow(deconvolved, cmap='gray')

With no appreciable changes to the image.

Any help on the matter is greatly appreciated!


EDIT:

Here is the code that I took from here:

psf = np.ones((5, 5)) / 25
equ = convolve2d(equ, psf, 'same')
deconvolved, _ = restoration.unsupervised_wiener(equ, psf)
plt.imshow(deconvolved, cmap='gray')

and here is the output:

解决方案

Deblurring images is (unfortunately) quite difficult, the reason for this is that blurring removes noise, so there are several (noisy) images that will yield the same image when you blur it. This means that there is no simple way for the computer to "choose" which of the noisy images when you deblur it. Because of this, deblurring will often yield noisy images.

Now then, you might ask how photographers do this in reality. Well, they do not actually deblur images, they sharpen them (which is slightly different). When you sharpen an image, you increase the contrast near borders to emphasise them (this is why you sometimes see a halo around borders on images that have been too heavily sharpened).

In you case, you want to deblur it (and there is no convolution kernel that will allow you to do this). To do it in a good way, you need to know what process blurred the image in the first place (that is if you don't want to spend thousands of dollars on special software or don't have a masters in mathematics or astronomy).

If you still want to do this, I'd recommend searching for deconvolution, and if you don't know the blurring process, blind deconvolution. There are some (crude) functions for it in skimage, which might be of help (http://scikit-image.org/docs/stable/auto_examples/filters/plot_restoration.html#sphx-glr-auto-examples-filters-plot-restoration-py).

Finally, the final link in Jax Briggs seem helpful, but I would not cross my fingers for magical results.

这篇关于对图像进行去模糊以执行边缘检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆