Seam Carving - Algorithm

Algorithm

1) We start with an image such as:

2) We then calculate the weight/density/energy of each pixel. This can be done by various algorithms: gradient magnitude, entropy, visual saliency, eye-gaze movement. Although gradient magnitude gives 'satisfactory results.'

3) After we have the energy of the image, we generate a list of seams. Seams are ranked by energy, with low energy seams being of least importance to the content of the image. We can choose to calculate seams via the dynamic programming approach.

Seams shown with the energy function:

Seams shown with the original image:

4) We then remove the seams from the image, reducing the size of the image as a result:

The recalculated energy function of the image would be:

Read more about this topic:  Seam Carving