mirror of
https://hub.njuu.cf/TheAlgorithms/Python.git
synced 2023-10-11 13:06:12 +08:00
fix matrices & image-path
This commit is contained in:
parent
7b4e0e9036
commit
7a575d6e83
@ -1,10 +1,11 @@
|
|||||||
import cv2
|
import cv2
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from matplotlib import pyplot as plt
|
from matplotlib import pyplot as plt
|
||||||
|
import os.path
|
||||||
|
|
||||||
|
|
||||||
def get_rotation(
|
def get_rotation(
|
||||||
img: np.ndarray, pt1: np.float32, pt2: np.float32, rows: int, cols: int
|
img: np.ndarray, pt1: np.ndarray, pt2: np.ndarray, rows: int, cols: int
|
||||||
) -> np.ndarray:
|
) -> np.ndarray:
|
||||||
"""
|
"""
|
||||||
Get image rotation
|
Get image rotation
|
||||||
@ -21,17 +22,17 @@ def get_rotation(
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# read original image
|
# read original image
|
||||||
image = cv2.imread("lena.jpg")
|
image = cv2.imread(os.path.dirname(__file__) + "/../image_data/lena.jpg")
|
||||||
# turn image in gray scale value
|
# turn image in gray scale value
|
||||||
gray_img = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
gray_img = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
||||||
# get image shape
|
# get image shape
|
||||||
img_rows, img_cols = gray_img.shape
|
img_rows, img_cols = gray_img.shape
|
||||||
|
|
||||||
# set different points to rotate image
|
# set different points to rotate image
|
||||||
pts1 = np.float32([[50, 50], [200, 50], [50, 200]])
|
pts1 = np.array([[50, 50], [200, 50], [50, 200]], np.float32)
|
||||||
pts2 = np.float32([[10, 100], [200, 50], [100, 250]])
|
pts2 = np.array([[10, 100], [200, 50], [100, 250]], np.float32)
|
||||||
pts3 = np.float32([[50, 50], [150, 50], [120, 200]])
|
pts3 = np.array([[50, 50], [150, 50], [120, 200]], np.float32)
|
||||||
pts4 = np.float32([[10, 100], [80, 50], [180, 250]])
|
pts4 = np.array([[10, 100], [80, 50], [180, 250]], np.float32)
|
||||||
|
|
||||||
# add all rotated images in a list
|
# add all rotated images in a list
|
||||||
images = [
|
images = [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user