Opencv cheat sheet

Getting Started with Images

Import OpenCV and numpy

import cv2
import numpy

A condensed overview of the following can be found in the Cheat Sheet


Read or save image : cv2.imshow('name of window', img)

Rotate image : rotated_image = imutils.rotate(image, 90)

Resize image : img2 = cv2.resize(img, None, fx=0.5, fy=0.5, interpolation = cv2.INTER_AREA)

Change parts of image

Split or merge channels

Add a border to an image

Convert colorspaces

Warp image

Image filtering

Thresholding selects pixels in a gray scale image whose intensity is larger (or smaller) than a threshold and assigns a new value to them.