python显示图片

opencv show
# -*- coding: UTF-8 -*-

from PIL import Image
from PIL import ImageEnhance
import numpy as np
import cv2
# 原始图像
fn=r"C:\Users\libanggeng\Pictures\yaozong\3.jpg"
image = Image.open(fn)

cv2.imshow('houghlines3.jpg', np.asarray(image))

# cv2.imwrite('houghlines3.jpg', img)
cv2.waitKey(0)

pil自己show
# -*- coding: UTF-8 -*-

from PIL import Image
from PIL import ImageEnhance
import numpy as np
import cv2
# 原始图像
fn=r"C:\Users\libanggeng\Pictures\yaozong\3.jpg"
image = Image.open(fn)
image.show()


直接显示数组矩阵:
b=np.array([
new_im = Image.fromarray(b.astype(np.uint8))

cv2.imshow("sadf",np.asarray(new_im))
cv2.waitKey(0)
 
   
 
   
opencv 转pil:
 img=cv2.imread(imageFullPath)
    im=Image.fromarray(img)
               cvimg= np.array(im)
numpy转opencv:
#coding=utf-8
import cv2 as cv
import numpy as np
width = 200
height = 200

image = np.zeros((height, width, 3), dtype=np.uint8)

#创建显示窗口

win_name = "test"
cv.namedWindow("test",cv.WINDOW_AUTOSIZE)
cv.imshow(win_name, image)
cv.waitKey()


你可能感兴趣的:(python)