Title: Cropping Images
Slug: cropping_images
Summary: How to cropping images using OpenCV in Python.
Date: 2017-09-11 12:00
Category: Machine Learning
Tags: Preprocessing Images
Authors: Chris Albon
In [5]:
# Load image
import cv2
import numpy as np
from matplotlib import pyplot as plt
In [6]:
# Load image as grayscale
image = cv2.imread('images/plane_256x256.jpg', cv2.IMREAD_GRAYSCALE)
In [7]:
# Select first half of the columns and all rows
image_cropped = image[:,:126]
In [8]:
# View image
plt.imshow(image_cropped, cmap='gray'), plt.axis("off")
plt.show()