计算图像方差背后的理论是什么? [英] What's the theory behind computing variance of an image?

查看:70
本文介绍了计算图像方差背后的理论是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过使用LaplacianFilter来计算图像的模糊度.

根据这篇文章:

您可以看到模糊的图像几乎没有边缘,而聚焦的图像有很多响应.现在,如果您计算方差会发生什么.让我们想象一下白色为255而黑色为0的情况.如果一切都是黑色...则方差低(模糊情况),但是如果它们有一半一样,则方差高.

但是,正如作者已经说过的那样,该阈值取决于域,即使您对天空拍照,即使它是聚焦的,它也可能具有较低的方差,因为它非常相似并且定义得不是很好.边缘...

我希望这能回答您的疑问:)

I am trying to compute the blurriness of an image by using LaplacianFilter.

According to this article: https://www.pyimagesearch.com/2015/09/07/blur-detection-with-opencv/ I have to compute the variance of the output image. The problem is I don't understand conceptually how do I compute variance of an image.

Every pixel has 4 values for every color channel, therefore I can compute the variance of every channel, but then I get 4 values, or even 16 by computing variance-covariance matrix, but according to the OpenCV example, they have only 1 number.

After computing that number, they just play with the threshold in order to make a binary decision, whether the image is blurry or not.

PS. by no means I am an expert on this topic, therefore my statements can make no sense. If so, please be nice to edit the question.

解决方案

First thing first, if you see the tutorial you gave, they convert the image to a greyscale, thus it will have only 1 channel and 1 variance. You can do it for each channel and try to compute a more complicated formula with it, or just use the variance over all the numbers... However I think the author also converts it to greyscale since it is a nice way of fusing the information and in one of the papers that the author supplies actually says that

A well focused image is expected to have a high variation in grey levels.

The author of the tutorial actually explains it in a simple way. First, think what the laplacian filter does. It will show the well define edges here is an example using the grid of pictures he had. (click on it to see better the details)

As you can see the blurry images barely have any edges, while the focused ones have a lot of responses. Now, what would happen if you calculate the variance. let's imagine the case where white is 255 and black is 0. If everything is black... then the variance is low (cases of the blurry ones), but if they have like half and half then the variance is high.

However, as the author already said, this threshold is dependent on the domain, if you take a picture of a sky even if it is focus it may have low variance, since it is quite similar and does not have very well define edges...

I hope this answer your doubts :)

这篇关于计算图像方差背后的理论是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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