Skip to content
Evergreen edited this page Jan 8, 2018 · 12 revisions

Welcome to the Seam-Carving-C-implementation wiki!

Seam carving, also known as "Content-Aware Image Resizing" by the original author, is a technique to change the size of an image without hurting its important contents. The idea of the algorithm is to compute the "energy" of each pixel to represent its importance, and then use Dynamic Programming to compute the vertical or horizontal "seam" with the least energy so as to delete exactly one pixel from each row/column and ensure the deletion is continuous to maintain the shape of important foreground contents.

Algorithm

  1. Without loss of generality, suppose we wish to shrink the horizontal size by 1. First we have a picture:

  1. Taking the $l_1_$ norm of its gradient (central difference used here), define it as the energy of each pixel.

  1. In order to get a "seam" with the least cumulative energy, Compute the cumulative energy of a pixel as [the minimum energy value of its adjacent pixels in the above row (i.e. upper-left, upper, upper-right)] plus [the energy value of itself]. Then compare the cumulative energy values in the bottom row of the image.

  1. This seam is labeled as follows:

  1. Delete more seams:

  1. Outcome

Clone this wiki locally