Exercises - Part 8 (Advanced)
- M = np.float32([[1, 0, 100],
- [0, 1, 50]])
- h, w = img.shape[:2]
- angle = 45
- h, w = img.shape[:2]
- center = (w//2, h//2)
- M = cv2.getRotationMatrix2D(center, angle, 1.0)
- cos = np.abs(M[0, 0])
- sin = np.abs(M[0, 1])
- new_w = int(h * sin + w * cos)
- new_h = int(h * cos + w * sin)
- M[0, 2] += (new_w - w) / 2
- M[1, 2] += (new_h - h) / 2
-