Install

  1. opencv with python bind (see Python & Opencv)
  2. scikit-image

Read/Write Show Image

opencv: read image with bgr format

import cv2
img=cv2.imread('input.jpg')
cv2.imwrite('xxx.png',img)

# must with extend opencv support, need build from source
cv2.imshow('title',img)
cv2.waitKey(0)

# convert to rgb format
img1=cv2.cvtColor(img,cv2.COLOR_BGR2RGB)

scikit-image

from skimage import data, io, filters

image = io.imread('xxx.png')
# ... or any other NumPy array!
edges = filters.sobel(image)
io.imshow(edges)    
io.show()

matplot

import matplotlib.pyplot as plt
matplotlib.image as mpimg
import numpy as np

img=mpimg.imread('stinkbug.png')
imgplot = plt.imshow(img)
plt.show()

results matching ""

    No results matching ""