Skip to content

Commit 45f48c6

Browse files
author
Sekhar Roy
committed
Rotation Fixed
1 parent 8c0d29d commit 45f48c6

9 files changed

+22
-4
lines changed
-66 Bytes
Binary file not shown.
233 Bytes
Binary file not shown.
13 Bytes
Binary file not shown.
13 Bytes
Binary file not shown.
13 Bytes
Binary file not shown.
13 Bytes
Binary file not shown.
13 Bytes
Binary file not shown.

melNET.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def main():
1616
global applied
1717
applied = False
1818

19-
def apply_but ton_applied():
19+
def apply_button_applied():
2020
root.destroy()
2121
global applied
2222
applied = True

melNET_augData.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import os
66
from tkinter import *
77
import shutil
8+
89
import blur_detection
910

1011

@@ -275,10 +276,27 @@ def file_naming(_img, process_initial, _folder, _set_counter):
275276
if rotationAngle is not None:
276277
# Rotation Code
277278
for angle in range(0, 360, rotationAngle):
278-
dim = _img.shape
279279
_scaleFactor = 1
280-
_rotationMatrix = cv2.getRotationMatrix2D((dim[1] / 2, dim[0] / 2), angle, _scaleFactor)
281-
_imgRotated = cv2.warpAffine(_img, _rotationMatrix, (dim[1], dim[0]), flags=cv2.INTER_LINEAR,
280+
(h, w) = _img.shape[:2]
281+
(cX, cY) = (w // 2, h // 2)
282+
283+
# grab the rotation matrix (applying the negative of the
284+
# angle to rotate clockwise), then grab the sine and cosine
285+
# (i.e., the rotation components of the matrix)
286+
M = cv2.getRotationMatrix2D((cX, cY), angle, _scaleFactor)
287+
288+
cos = np.abs(M[0, 0])
289+
sin = np.abs(M[0, 1])
290+
291+
# compute the new bounding dimensions of the image
292+
nW = int((h * sin) + (w * cos))
293+
nH = int((h * cos) + (w * sin))
294+
295+
# adjust the rotation matrix to take into account translation
296+
M[0, 2] += (nW / 2) - cX
297+
M[1, 2] += (nH / 2) - cY
298+
299+
_imgRotated = cv2.warpAffine(_img, M, (nW, nH), flags=cv2.INTER_LINEAR,
282300
borderMode=cv2.BORDER_REFLECT_101)
283301
_savingName = dst_root + _folder + "/" + _folder + "_" + str(name_counter) + "_" \
284302
+ process_initial + "_Rot_" + str(angle) + ".jpg"

0 commit comments

Comments
 (0)