使用cv2.imshow()显示图像时,如何增加图像的原始尺寸?

时间:2018-11-03 19:07:18

标签: python-3.x opencv image-processing computer-vision

我有在模型中使用的28X28图像,并且图像的原始大小为28x28。 我正在使用gausianblur()和阈值对其进行预处理,并希望在两个单独的窗口中显示原始图像和经过预处理的图像。

问题是显示时我的图像很小,我想在显示时增加它的尺寸。我该怎么做。

下面是用于该代码的代码。

def image_pre_dis(image, width = 50, height = 50, inter = cv2.INTER_CUBIC):
    # initialize the dimensions of the image to be resized and
    # grab the image size
    dim = (200, 200)

    # resize the image

    im_gray = cv2.GaussianBlur(image, (5, 5), 0)
    _, threshold_img = cv2.threshold(im_gray, 60, 255, cv2.THRESH_BINARY)
    resized = cv2.resize(threshold_img, dim, interpolation = inter)
    print('HIT n TO PREDICT THE RESULT IF ITS EVEN OR ODD')

    #display th eoriginal image   
    cv2.imshow("ORIGINAL", image)
    #display the binary image
    cv2.imshow("BINARY", threshold_img)
    cv2.resizeWindow('ORIGINAL', 600,600)
    cv2.resizeWindow('BINARY', 600,600)
    k = chr(cv2.waitKey())
    if k == 'n':
        cv2.destroyAllWindows()



#     # return the resized image

    return resized

0 个答案:

没有答案