(a)
| 35 | import video |
| 36 | |
| 37 | def rnd_warp(a): |
| 38 | h, w = a.shape[:2] |
| 39 | T = np.zeros((2, 3)) |
| 40 | coef = 0.2 |
| 41 | ang = (np.random.rand()-0.5)*coef |
| 42 | c, s = np.cos(ang), np.sin(ang) |
| 43 | T[:2, :2] = [[c,-s], [s, c]] |
| 44 | T[:2, :2] += (np.random.rand(2, 2) - 0.5)*coef |
| 45 | c = (w/2, h/2) |
| 46 | T[:,2] = c - np.dot(T[:2, :2], c) |
| 47 | return cv2.warpAffine(a, T, (w, h), borderMode = cv2.BORDER_REFLECT) |
| 48 | |
| 49 | def divSpec(A, B): |
| 50 | Ar, Ai = A[...,0], A[...,1] |