Skip to content

Instantly share code, notes, and snippets.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
from subprocess import call
from pylab import *
from mpl_toolkits.axes_grid1 import make_axes_locatable
from matplotlib.patches import Rectangle
from time import sleep
import cv2
# Read template image
templateImageGray = cv2.imread("./images/templateImage.png", cv2.IMREAD_GRAYSCALE)
templateImageGray = cv2.resize(templateImageGray, (0, 0), fx=16, fy=16, interpolation=cv2.INTER_CUBIC)
import os
from glob import glob
import cv2
import numpy as np
from numpy import arange
import matplotlib.pyplot as plt
from matplotlib.figure import Figure
from matplotlib.backend_bases import key_press_handler
# convert image to numpy array
im = array(Image.open('./data/empire.jpg')) #return numpy array
# show
imshow(im, interpolation='nearest')#or interpolation='None'
# star point
x = [100,100,400,400]
y = [200,500,200,500]
from PIL import Image
pil_im = Image.open('./data/empire.jpg').convert('L')
#rotate clockwise
out = pil_im.rotate(45)
#show
out.show()
from PIL import Image
pil_im = Image.open('./data/empire.jpg').convert('L')
#be careful it may change aspect ratio
out = pil_im.resize((128,128))
#show
out.show()