def iageorigid(f, scale, theta, t): from iaffine import iaffine Ts = [[scale[1],0,0], [0,scale[0],0], [0,0,1]] Trot = [[cos(theta),-sin(theta),0], [sin(theta),cos(theta),0], [0,0,1]] Tx = [[1,0,t[1]], [0,1,t[0]], [0,0,1]] g = iaffine(f, dot(dot(Tx,Trot), Ts)) return g
def iageorigid(f, scale, theta, t): from iaffine import iaffine Ts = [[scale[1], 0, 0], [0, scale[0], 0], [0, 0, 1]] Trot = [[cos(theta), -sin(theta), 0], [sin(theta), cos(theta), 0], [0, 0, 1]] Tx = [[1, 0, t[1]], [0, 1, t[0]], [0, 0, 1]] g = iaffine(f, dot(dot(Tx, Trot), Ts)) return g
import numpy as np import matplotlib.pyplot as plt from iaffine import iaffine G = np.ones((50, 50)) * 255.0 G[5:16, 5] = 0 G[15, 5:12] = 0 plt.figure() plt.imshow(G, cmap = plt.get_cmap('gray')) T = np.array([[1, 0, -5], [0, 1, -5], [0, 0, 1] ]) G1 = iaffine(G, T) plt.show() plt.figure() plt.imshow(G1, cmap = plt.get_cmap('gray')) plt.show() T2 = np.array([[0.5, 0, 0], [0, 0.5, 0], [0, 0, 1]]) G2 = iaffine(G1, T2) print(T2) plt.figure() plt.imshow(G2, cmap = plt.get_cmap('gray')) plt.show() T3 = np.array([[0,-1, 0], [1, 0, 0], [0, 0, 1]]) G3 = iaffine(G2, T3)