Image Processing กับ Python[04] : การใช้งาน plot จาก matlab module

step 1 ติดตั้ง matplotlib ด้วยคำสั่ง
py -m pip install matplotlib


step 2 ตัวอย่างการใช้งาน
#perspectiveTransformation.py
import cv2
import numpy as np
#from matplotlib.pyplot import *
import matplotlib.pyplot as plt

img = cv2.imread('sudokusmall.jpg')
rows,cols,ch = img.shape

pts1 = np.float32([[56,65],[368,52],[28,387],[389,390]])
pts2 = np.float32([[0,0],[300,0],[0,300],[300,300]])

M = cv2.getPerspectiveTransform(pts1,pts2)

dst = cv2.warpPerspective(img,M,(300,300))

plt.subplot(121),plt.imshow(img),plt.title('Input')
plt.subplot(122),plt.imshow(dst),plt.title('Output')
plt.show()

ไฟล์ทดสอบ


ผลลัพธ์

อ้างอิง : https://docs.opencv.org/3.0-beta/doc/py_tutorials/py_imgproc/py_geometric_transformations/py_geometric_transformations.html

เขียนโดย
ชลิตา จูมสีมา
--

ความคิดเห็น

โพสต์ยอดนิยมจากบล็อกนี้

CASIO fx-5800P : การ mod ด้วยเครื่องคิดเลข

sgsBB(SGS-Score Inserter) : โปรแกรมช่วยกรอกผลคะแนนจาก bookmark51 ใส่ระบบ SGS ของ สพฐ.

springMVC : เชื่อมต่อฐานข้อมูล mySQL ด้วย JDBC-Template