python 图像旋转

import cv2
import imutils
image = cv2.imread(r"C:\Users\HP\OneDrive\Desktop\Penskull Education.png")
 
rot = imutils.rotate(image, angle=45)
cv2.imshow("Rotated", rot)
cv2.waitKey(0)
from PIL import Image 
 
  
img = Image.open(r"C:\Users\HP\OneDrive\Desktop\Penskull Education -- 01.png") 
 
rotate_img= img.rotate(45)
 
rotate_img.show() 
import cv2
import numpy as np
 
 
img1 = cv2.imread('./Image/reba_color.jpg',cv2.IMREAD_COLOR)
 
 
tx = 20  # x
ty = 20  # y
 
affine_arr = np.float32([[1,0,tx],[0,1,ty]])
 
res = cv2.warpAffine(img1,affine_arr,(img1.shape[0],img1.shape[1]))
 
cv2.imshow('img',img1)
cv2.imshow('res',res)
 
cv2.waitkey(0)
import cv2

pre_img = cv2.imread('image.jpg', cv2.IMREAD_GRAYSCALE)
h, w = pre_img.shape

kernel = cv2.getStructuringElement(cv2.MORPH_RECT, ksize=(1, 2 * h))

dilated = cv2.dilate(pre_img, kernel)

cv2.imshow('input', pre_img)
cv2.imshow('output', dilated)
cv2.waitKey(0)

你可能感兴趣的:(Python技巧,python,pytorch)