For this project the task was to implement the algorithm described in the paper "Seam Carving for Content-Aware Image Resizing" by Shai Avidan and Ariel Shamir. The idea is to be able to shrink an image (either horizontally or vertically) to a given dimension without deforming the objects in the image.
The algorithm works in the folowing way:
To shrink the image n pixels in the horizontal direction
- Filter the image with a gaussian blur
- Compute the partial derivative in the horizontal direction using a convolution between the image and the kernel = [-1 1]
- Take the absolute value of the derivatives. This is our energy function
- Using dynamic programming find the seam with less energy
- Remove this seam from the image
- repeat the last 5 steps n times
To shrink in the vertical direction the image is transposed, the same algorithm is applied and the image is transposed again.