(image, angle)
| 39 | return rotated |
| 40 | |
| 41 | def rotate_bound(image, angle): |
| 42 | # grab the dimensions of the image and then determine the |
| 43 | # center |
| 44 | (h, w) = image.shape[:2] |
| 45 | (cX, cY) = (w / 2, h / 2) |
| 46 | |
| 47 | # grab the rotation matrix (applying the negative of the |
| 48 | # angle to rotate clockwise), then grab the sine and cosine |
| 49 | # (i.e., the rotation components of the matrix) |
| 50 | M = cv2.getRotationMatrix2D((cX, cY), -angle, 1.0) |
| 51 | cos = np.abs(M[0, 0]) |
| 52 | sin = np.abs(M[0, 1]) |
| 53 | |
| 54 | # compute the new bounding dimensions of the image |
| 55 | nW = int((h * sin) + (w * cos)) |
| 56 | nH = int((h * cos) + (w * sin)) |
| 57 | |
| 58 | # adjust the rotation matrix to take into account translation |
| 59 | M[0, 2] += (nW / 2) - cX |
| 60 | M[1, 2] += (nH / 2) - cY |
| 61 | |
| 62 | # perform the actual rotation and return the image |
| 63 | return cv2.warpAffine(image, M, (nW, nH)) |
| 64 | |
| 65 | def resize(image, width=None, height=None, inter=cv2.INTER_AREA): |
| 66 | # initialize the dimensions of the image to be resized and |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…