【问题标题】:Identifying the quality of an png format image with opencv使用 opencv 识别 png 格式图像的质量
【发布时间】:2020-12-01 01:41:58
【问题描述】:

我需要根据质量分离图像。使用 OpenCV 获得图像质量的最佳方法是什么? 我知道 image.shape 给出了图像的高度和宽度,但在某些情况下,对于低质量的图像,我们可以改变高度和宽度。 所以高度和宽度不能像我想的那样给出图像的质量。

【问题讨论】:

  • 你说的“质量”是什么意思?所有 PNG 都是无损的,因此它们的标称 “质量” 为 100%。

标签: image opencv png opencv-python image-preprocessing


【解决方案1】:

图像中一个有用的品质是清晰而不模糊。确定这一点的一种简单方法是测量梯度的数量。梯度中的能量多意味着边缘锐利,能量低意味着边缘模糊。

这是我在https://stackoverflow.com/questions/6646371/detect-which-image-is-sharper#:~:text=The%20simple%20method%20is%20to,produces%20the%20larger%20number%20wins 的答案之一中解释的。问题。

使用 python opencv 会是这样的:

    import cv2 as cv
    import numpy as np

    img = cv.imread('dave.jpg',0)
    laplacian = cv.Laplacian(img,cv.CV_64F)
    gnorm = np.sqrt(laplacian**2)
    sharpness = np.average(gnorm)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-18
    • 1970-01-01
    • 1970-01-01
    • 2013-03-13
    相关资源
    最近更新 更多