반응형
import numpy as np
import cv2
import matplotlib.pyplot as plt
img = cv2.imread('D:/21_pycharm_project/Proj02/mark4.bmp')
rows,cols,ch = img.shape
# input potision
pts1 = np.float32([[98,21],[187,21],[96,102],[188,102]])
# output position
pts2 = np.float32([[128,21],[157,21],[96,102],[188,102]])
# get perspective transform matrix
M = cv2.getPerspectiveTransform(pts1,pts2)
# warp
dst = cv2.warpPerspective(img,M,(300,120))
plt.subplot(121),plt.imshow(img),plt.title('Input')
plt.subplot(122),plt.imshow(dst),plt.title('Output')
plt.show()
cv2.imwrite('D:/21_pycharm_project/Proj02/mark4_.bmp', dst)
'Python' 카테고리의 다른 글
Copy files in a directory to another directory (0) | 2017.12.01 |
---|---|
Get file list in a directory (0) | 2017.11.30 |
how to plot a histogram : matplotlib (0) | 2017.09.26 |
How to resize an image : skimage library (0) | 2017.08.01 |
How to show an image : skimage library (0) | 2017.07.21 |