Skip to content

Commit 7a575d6

Browse files
committed
fix matrices & image-path
1 parent 7b4e0e9 commit 7a575d6

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

digital_image_processing/rotation/rotation.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import cv2
22
import numpy as np
33
from matplotlib import pyplot as plt
4+
import os.path
45

56

67
def get_rotation(
7-
img: np.ndarray, pt1: np.float32, pt2: np.float32, rows: int, cols: int
8+
img: np.ndarray, pt1: np.ndarray, pt2: np.ndarray, rows: int, cols: int
89
) -> np.ndarray:
910
"""
1011
Get image rotation
@@ -21,17 +22,17 @@ def get_rotation(
2122

2223
if __name__ == "__main__":
2324
# read original image
24-
image = cv2.imread("lena.jpg")
25+
image = cv2.imread(os.path.dirname(__file__) + "/../image_data/lena.jpg")
2526
# turn image in gray scale value
2627
gray_img = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
2728
# get image shape
2829
img_rows, img_cols = gray_img.shape
2930

3031
# set different points to rotate image
31-
pts1 = np.float32([[50, 50], [200, 50], [50, 200]])
32-
pts2 = np.float32([[10, 100], [200, 50], [100, 250]])
33-
pts3 = np.float32([[50, 50], [150, 50], [120, 200]])
34-
pts4 = np.float32([[10, 100], [80, 50], [180, 250]])
32+
pts1 = np.array([[50, 50], [200, 50], [50, 200]], np.float32)
33+
pts2 = np.array([[10, 100], [200, 50], [100, 250]], np.float32)
34+
pts3 = np.array([[50, 50], [150, 50], [120, 200]], np.float32)
35+
pts4 = np.array([[10, 100], [80, 50], [180, 250]], np.float32)
3536

3637
# add all rotated images in a list
3738
images = [

0 commit comments

Comments
 (0)