#!/usr/bin/env python # coding: utf-8 # ## Cropping # # # In[1]: import cv2 import numpy as np import matplotlib.pyplot as plt image = cv2.imread('images/input.jpg') plt.imshow(image[...,::-1]) # In[4]: height, width = image.shape[:2] # Simply use indexing to crop out the rectangle we desire cropped = image[250:400 , 250:550] plt.imshow(cropped[...,::-1]) # In[5]: cv2.imshow("original", image) cv2.imshow("cropped", cropped) cv2.waitKey() cv2.destroyAllWindows() # In[ ]: height, width = image.shape[:2] # Simply use indexing to crop out the rectangle we desire cropped = image[250:400 , 250:550] plt.imshow(cropped[...,::-1]) # In[ ]: