5 Apr 2022
Given an input image with dimension , how can we get an output image with size , where ? Ideally, we'd like to be a good representative of the original image . However, there is no definitive measure to how good of a representative an image is.
With scaling, we may stretch or compress an image into a viewport; but this does not preserve the proportions of perceptually "important" content.
With cropping, we reduce the viewport to just the "important" part, but if we desire to keep two objects in the scene that are farther apart than the cropping window, we cannot preserve both.
Then it becomes apparent that we need a retargeting scheme that is "content-aware", or a method that preserves the important parts of an image.
In seam carving, we remove the unimportant pixels from an image – again, this raises the question of what is an "unimportant" pixel?
One measure is "energy", which can be expressed as
The human vision system is more sensitive to edges, so by using the gradients as an energy metric should preserve strong contours that are important in human perception.
todo: include images to better illustrate the drawbacks
A (vertical) seam is defined to be a connected path of pixels from the top to the bottom of an image, with exactly one pixel per row.
The optimal seam is defined as
Unfortunately, this requires us to find all seams in an image, then find the seam with minimal energy – this is extremely inefficient.
However, by using a recursive formulation for a seam, we can use dyanmic programming to get ( in this case).
todo: include illustration of dynamic programming approach
There is much freedom in the method of computing the gradients and , below are the results of a selection of various finite difference convolution filters.
Original
Prewitt
Sobel
Roberts
Laplacian
RieszOn the background building, the Riesz transform had the least distortion on this building in the background of the image.
The Riesz filter is based off of the rotation-invariant Riesz transform and was described in "Riesz Pyramids for Fast Phase-Based Video Magnification" by Wadhwa et al. Then, the gradients using the Riesz filter can be defined by and .
We can also choose to duplicate seams instead of deleting them in order to perform content-aware image expansion.
In order to expand an image by pixels, we must first perform seam carving to find the first seams. Then, we can duplicate the seams to add pixels to an image dimension. We cannot just find a seam, duplicate it, then repeat by finding a seam on the expanded image – this will most likely result in us picking the same seam many times, this produces an undesirable "streaking" effect instead of content-aware expansion.
The process is described in from Avidan and Shamir's "Seam Carving for Content-Aware Image Resizing".
Using a print by Utagawa Hiroshige, I was able to extend the width of the image by about 37%; by using a mask, I was able to expand the image without warping the subject of the print.

