首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >开式cv中laplacian模糊度的方差计算

开式cv中laplacian模糊度的方差计算
EN

Stack Overflow用户
提问于 2018-04-13 01:45:53
回答 1查看 1.5K关注 0票数 1

我试图获得图像的模糊度。我参考本教程计算开cv中laplacian的方差。

代码语言:javascript
复制
import cv2
def variance_of_laplacian(image):
  return cv2.Laplacian(image, cv2.CV_64F).var()

def check_blurry(image):
  """
  :param: the image 
  :return: True or False for blurry
  """
  gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
  fm = variance_of_laplacian(gray)
  return fm

当我试图从两幅图像中计算fm时,这两幅图像看起来完全相同,但大小不同。

代码语言:javascript
复制
filePath = 'small.jpeg'
image1 = cv2.imread(filePath)
print('small image shape', image1.shape)
print('small image fm', check_blurry(image1))

filePath = 'large.jpg'
image2 = cv2.imread(filePath)
print('large image shape', image2.shape)
print('large image fm', check_blurry(image2))

信息系统的产出:

代码语言:javascript
复制
small image shape (1440, 1080, 3)
small image fm 4.7882723403428065
large image shape (4032, 3024, 3)
large image fm 8.44476634687877

很明显,小图像缩小了大图像的2.8比。fm与图像大小有关吗?如果是的话,他们之间有什么关系?或者有什么方法来评估不同大小图像的模糊程度?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-04-14 16:35:22

“fm与图像大小相关吗?”

是的,部分地(至少就你的问题而言),因为如果你缩放一幅图像,你必须插值像素值。向下缩放不仅会丢失信息,还会通过像素插值(如果不是最近邻插值)创建新信息,从而影响图像的方差。但这只适用于缩放图像,而不适用于最初不同的图像。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49808127

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档