Skip to content

Instantly share code, notes, and snippets.

@obafgkm44 obafgkm44/img_resize.py

Last active Mar 31, 2019
Embed
What would you like to do?
画像を切り取る
# ダウンロードした画像を画面に表示する
import matplotlib.pyplot as plt
import cv2
# 画像を読み込む
img = cv2.imread("sakura.jpg")
#一部を切り取り
im = img[100:300,100:300]
#画像を保存
cv2.imwrite("resize-sakura.png",im)
# axisの表示オフ
plt.axis("off")
plt.imshow(cv2.cvtColor(im, cv2.COLOR_BGR2RGB))
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.