在Python的OpenCV中使用sobel运算符计算x方向的模糊度

问题描述 投票:0回答:1

我们需要检测可调透镜产生的图像是否模糊。

我们想要找到一种模糊性的替代指标。

我目前的想法是首先沿x方向应用Sobel,因为跳跃或条纹大部分沿该方向。然后计算x方向的边际均值,最后计算这些边际均值的标准偏差。

我们期望此Std为对于清晰的图像来说更大对于模糊的图像来说较小],因为清晰的图像将具有较大的强度或更大的像素值跳跃。

但是我们得到相反的结果。我们如何改善这种模糊性度量?

def sobel_image_central_std(PATH):
    # use the blue channel
    img = cv2.imread(PATH)[:,:,0]

    # extract the central part of the image
    hh, ww = img.shape
    hh2 = hh // 2 
    ww2 = ww// 2
    hh4 = hh // 4
    ww4 = hh //4
    img_center = img[hh4:(hh2+hh4), ww4:(ww2+ww4)]

    # Sobel operator
    sobelx = cv2.Sobel(img_center, cv2.CV_64F, 1, 0, ksize=3)
    x_marginal = sobelx.mean(axis = 0)

    plt.plot(x_marginal)
    return(x_marginal.std())

模糊#1

enter image description here

模糊#2

enter image description here

清除#1

enter image description here

清除#2

enter image description here

我们需要检测可调透镜产生的图像是否模糊。我们想要找到一种模糊性的替代指标。我目前的想法是首先沿x ...

python opencv blur sobel
1个回答
0
投票

一般:

© www.soinside.com 2019 - 2024. All rights reserved.