Seam Carving

Author: Ulf Dittmer, based on seam carving code by Mathias Lux

Date:2/11/2007

Description: Seam Carving (a.k.a content-aware image resizing) is an image manipulation technique for resizing images by removing image content that contributes little to image appearance. Thus more image features are preserved compared to cropping or scaling. It was suggested by Shai Avidan and Ariel Shamir in the paper Seam Carving for Content-Aware Image Resizing. I can't do it justice here, but you can find the paper and an amazing video (that you should watch even if you have no further interest in this subject) at http://www.faculty.idc.ac.il/arik/site/seam-carve.asp.

Mathias Lux has implemented the algorithm in Java (you can find it here). This plugin is an ImageJ adaptation of Mathias' code. The only difference is the addition of the ImageJ plugin and GUI code, and that Java 1.4 is used instead of Java 6; otherwise it's unchanged. Since Mathias' code is distributed under the GPL, so is this plugin.

Basic usage: Open an RGB image and select "Seam Carving..." from the Plugins menu. A new window appears in which the seam carving operation will take place. Select a new width and/or height for the image (the new size of the image will be marked by red grid lines), and click Process. You'll see the new image appear in the window. After the operation is done, click Save to copy the image to a regular ImageJ window that you can save or otherwise manipulate.
The Brush size and Remove controls are used for preserving or deleting certain features of the image that have been marked with the brush cursor; this is demonstrated in the video.

Installation: Download the SeamCarving_.jar file and place it in the plugins directory of your ImageJ Installation. Next time you start the program, a new menu entry "Seam Carving..." will appear in the Plugins menu.

The source code can be found here.

The jar file is also a double-clickable application. It has menus for opening, processing and saving images.

Example:
These images are taken from the above-mentioned paper. The top image is to be horizontally stretched and vertically shrunk. (Note that the implementation described here can only shrink images, not stretch them.)

The red lines are the horizontal and vertical seams of the lowest energy. In other words, those pixels would be removed first when shrinking this image.

This image is a traditionally scaled version. The house, the trees and the rock in the foreground have become distorted.
This is the version obtained by seam carving. The proportions of the house and the trees have largely been preserved. The area taken up by the sky and the water has become smaller in comparison.
Changes: February 2008
  • Initial version, based on version 4 of the seam carving code
  • version 2: now shows the seams that are about to be removed, and the target image size

Back To ImageJ Plugin Page | Back To Home Page