注
1.圖片的原點(diǎn)在左上角
2.在右下可以看x,y的值

代碼
from PIL import Image
import matplotlib.pyplot as plt
img = Image.open('pokemon.jpg') #打開圖片
plt.figure('pokemon') #設(shè)置figure
plt.subplot(1,2,1) #放置原圖
plt.title('origion')
plt.imshow(img)
plt.axis('off')
box=(110,50,220,190) #設(shè)置截取邊界(x1,y1,x2,y2)---(左邊界,上邊界,右邊界,下邊界)
temp=img.crop(box) #截取
plt.subplot(1,2,2),plt.title('temp') #放置截取圖片
plt.imshow(temp),plt.axis('off')
plt.show()
效果
