Content-aware image resizing with seam carving

The following code demonstrates how the scikit-image library's transform module's seam_curve() function can be used for content-aware image resizing. Let's first import the required packages, load the original input airplane image, and display the image using the following code block:

# for jupyter notebook uncomment the next line of code# % matplotlib inline from skimage import data, drawfrom skimage import transform, utilimport numpy as npfrom skimage import filters, colorfrom matplotlib import pyplot as pylabimage = imread('../images/aero.jpg')print(image.shape)# (821, 616, 3)image = util.img_as_float(image)energy_image = filters.sobel(color.rgb2gray(image))pylab.figure(figsize=(20,16)), pylab.title('Original ...

Get Hands-On Image Processing with Python now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.