Last active
March 31, 2019 17:12
-
-
Save obafgkm44/c4f99a8b41c377b30598ab5eaf5ad5d2 to your computer and use it in GitHub Desktop.
画像を切り取る
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ダウンロードした画像を画面に表示する | |
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