![]() |
|
Conversions between Various Formats |
|
Convert between Python tuple and list |
|
Read/Write Images with OpenCV image = cv.LoadImage(“ponzo.jpg”) cv.SaveImage(“out.png”, image) Read/Write Images with PIL image = Image.open(“ponzo.jpg”) image.save(“out.jpg”) Read/Write Images with PyOpenCV mat = pyopencv.imread(“ponzo.jpg”) pyopencv.imwrite(“out.png”, mat) |
|
Convert between OpenCV image and PIL image |
|
Convert between PIL image and NumPy ndarray |
|
Convert between OpenCV image and NumPy ndarray cimg = cv.LoadImage("ponzo.jpg", cv.CV_LOAD_IMAGE_COLOR) # cimg is a OpenCV image pimg = Image.fromstring("RGB", cv.GetSize(cimg), cimg.tostring()) # pimg is a PIL image array = numpy.array(pimg) # array is a numpy array pimg2 = cv.fromarray(array) # pimg2 is a OpenCV image |