Cropping an image is typically limited to selecting rectangular portions of an image and removing them. Enlarging an image typically means stretching an image which can result in pixelation. Seam Carving, also known as Liquid Resizing is a technique that removes both of these limitations.
Seam carving works by finding the low energy seams of the image and then removing vertical or horizontal (but not necessarily straight) seams from the image. In this context low energy seams are parts of the image where there is not much change, and therefore are unlikely to be noticeable if removed.
For this implementation I created a program that uses a Sobel filter to determine low energy seams in the input image. These seams are marked with red in the featured images accompanying this post.
The technique can also be used to increase image size, essentially by working in reverse. The idea is to find the
k seams that would have been removed and then insert seams in those locations as they are unlikely to be
crucial to the overall image. In the last series of featured images these seams are marked in green. The color of these
seams is calculated by averaging the color of pixels on either side of the image.
This is known as “seam insertion” and its usefulness is one reason “Liquid Resizing” is
perhaps a better name for this algorithm in general.
This project implements the academic paper Region Filling and Object Removal by Exemplar-Based Image Inpainting by Shai Avidan and Ariel Shamir.