为什么展开的图像是完全白色的?我做错了什么?

2024-10-01 17:40:58 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试创建一个狮子图像的扩展版本,它看起来像:

<a href="https://ibb.co/R7DgDHS"><img src="https://i.ibb.co/R7DgDHS/reduced.jpg" alt="reduced" border="0"></a>

我正在尝试使用OpenCV创建此图像的扩展版本。我就是这么做的:

    def expand(img):
        height, width = img.shape
        ex_img = np.zeros((height*2, width*2))
        ex_img[::2,::2] = img
        kernel = np.array([0.25 - 0.4 / 2.0, 0.25, 0.4, 0.25, 0.25 - 0.4 / 2.0])
        return cv2.sepFilter2D(ex_img, -1, kernel, kernel, borderType = cv2.BORDER_REFLECT101)

这里函数img表示上面的图像。来自expand的输出如下所示:

<a href="https://ibb.co/Qrsfqkx"><img src="https://i.ibb.co/Qrsfqkx/Screenshot-from-2019-09-12-13-40-50.png" alt="Screenshot-from-2019-09-12-13-40-50" border="0"></a>

如您所见,展开的图像是完全白色的。为什么会这样


Tags: https图像版本srcimgaltkernelex

热门问题