<gh_stars>0
import cv2

# Reading the image
image = cv2.imread(r'C:\Users\harrizazham98\Desktop\OpenCVForPython\resources\Day 1\image\KL_view.jpg')

# dividing height and width by 2 to get the center of the image
height, width = image.shape[:2]
# get the center coordinates of the image to create the 2D rotation matrix
center = (width/2, height/2)

# using cv2.getRotationMatrix2D() to get the rotation matrix
rotate_matrix = cv2.getRotationMatrix2D(center=center, angle=45, scale=0.5)

# rotate the image using cv2.warpAffine
rotated_image = cv2.warpAffine(src=image, M=rotate_matrix, dsize=(width, height))

cv2.imshow('Original image', image)
cv2.imshow('Rotated image', rotated_image)
# wait indefinitely, press any key on keyboard to exit
cv2.waitKey(0)
# save the rotated image to disk
#cv2.imwrite('rotated_image.jpg', rotated_image)
import cv2

# Reading the image
image = cv2.imread(r'C:\Users\harrizazham98\Desktop\OpenCVForPython\resources\Day 1\image\KL_view.jpg')

# dividing height and width by 2 to get the center of the image
height, width = image.shape[:2]
# get the center coordinates of the image to create the 2D rotation matrix
center = (width/2, height/2)

# using cv2.getRotationMatrix2D() to get the rotation matrix
rotate_matrix = cv2.getRotationMatrix2D(center=center, angle=45, scale=0.5)

# rotate the image using cv2.warpAffine
rotated_image = cv2.warpAffine(src=image, M=rotate_matrix, dsize=(width, height))

cv2.imshow('Original image', image)
cv2.imshow('Rotated image', rotated_image)
# wait indefinitely, press any key on keyboard to exit
cv2.waitKey(0)
# save the rotated image to disk
#cv2.imwrite('rotated_image.jpg', rotated_image)
# Reading the image # dividing height and width by 2 to get the center of the image # get the center coordinates of the image to create the 2D rotation matrix # using cv2.getRotationMatrix2D() to get the rotation matrix # rotate the image using cv2.warpAffine # wait indefinitely, press any key on keyboard to exit # save the rotated image to disk #cv2.imwrite('rotated_image.jpg', rotated_image)