Skip to content

Instantly share code, notes, and snippets.

@obafgkm44
Last active March 31, 2019 17:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save obafgkm44/c4f99a8b41c377b30598ab5eaf5ad5d2 to your computer and use it in GitHub Desktop.
Save obafgkm44/c4f99a8b41c377b30598ab5eaf5ad5d2 to your computer and use it in GitHub Desktop.
画像を切り取る
# ダウンロードした画像を画面に表示する
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