Research Replication: Seam Carving

08 Oct 2019

Seam Carving is a novel technique for doing content-aware image resizing aka “image retargeting”. The idea is to remove seams of low-energy pixels one at a time until the image is truncated to the desired dimensions. In the papers cited below we are introduced to the concept and its applications.

We present an implementation of the Seam Carving technique in pure JavaScript running in the browser. The implementation of the algorithm is summarized:

  • Calculate image gradient in x and y direction
  • Use dynamic programming to calculate minimum seam energies over the entire image
  • Extract the minimum energy seam, this removes exactly 1 pixel along one dimension
  • Repeat until the desired dimension is achieved

In the results below we see that a typical scaling operation will uniformly flatten scene objects, while retargeting keeps the size of certain elements intact.

Scaled
Retargeted

Original