[Go to Index] [Go to Next] [My Homepage]


2. Extensions

In the last section, I introduced shrinking an image with optimal order and optimal seams. The extensions can be: image enlarging, content amplification and object removal.

1.1 Image enlarging

To avoid the stretching artifact, the enlarging consists of two steps: first, find k seams for removal; second, duplicate the seams by average pixels with their neighbors in the enlarging direction.

Duplicating all the seams in an image is equivalent to conventional scaling. For excessive image enlarging, I break the process into several steps. Each step does not enlarge the size of the image in more than a fraction (less than 50%) of its size from the previous step, essentially guarding the important content from being stretched.


2.2 Content Amplification

Content amplification is to scale the image to a larger size and then to apply seam carving to shrink the image back to its original size.
As I do not find a good library of image scaling/resampling, I use IrfanView for scaling.


2.3 Object removal

Object removal can be achieved by using a mask to denote the removal region and the protected region.

This task is decomposed into three steps:
First, the direction (horizontal or vertical) of seam carving is determined. Let sx = max(x)-min(x) and sy = max(y)-min(y), where (x, y) is from the set of pixels to be removed. and then if sx < sy, vertical seam carving is selected; otherwise, horizontal seam carving is the choice.
Second, perform horizontal/vertical seam carving to the size (width, height-dy)/(width-dx, height), where dx is the maximum number of pixels to be removed in a row and dy is the maximum number of pixels to be removed in a column.
Third, perform image enlarging to resize the image to the original size (optional).

In my experiments, I found that sx and sy are good for determining the direction and dx and dy are appropriate for estimating the number of seams to be removed. Note that sx and sy overestimate this number (see Fig. for an example).

seam carving dynamic programming python
(a) Remove dx seams(b) Remove sx seams
Fig. 2 Comparison of object removal with different target sizes.


[Go to Index] [Go to Next]

-----------------------------------------------------------------------------------------------------

Copyright (c) 2009 Wei Zhang