HOME

TheInfoList



OR:

Seam carving (or liquid rescaling) is an algorithm for content-aware image resizing, developed by Shai Avidan, of
Mitsubishi Electric Research Laboratories Mitsubishi Electric Research Laboratories (MERL) is a subsidiary of Mitsubishi Electric US Holdings, Inc., which, in its turn, is the principal subsidiary of Mitsubishi Electric in the United States. MERL is the North American arm of the Corporat ...
(MERL), and Ariel Shamir, of the
Interdisciplinary Center Reichman University ( he, אוניברסיטת רייכמן) is Israel's only private university, located in Herzliya, Tel Aviv District. It was founded in 1994 as the IDC Herzliya private college, before being rebranded in 2021. It receives no ...
and MERL. It functions by establishing a number of ''seams'' (paths of least importance) in an image and automatically removes seams to reduce image size or inserts seams to extend it. Seam carving also allows manually defining areas in which pixels may not be modified, and features the ability to remove whole objects from photographs. The purpose of the algorithm is image retargeting, which is the problem of displaying images without distortion on media of various sizes (cell phones, projection screens) using document standards, like HTML, that already support dynamic changes in page layout and text but not images. Image Retargeting was invented by Vidya Setlur, Saeko Takage, Ramesh Raskar, Michael Gleicher and Bruce Gooch in 2005. The work by Setlur et al. won the 10-year impact award in 2015.


Seams

Seams can be either vertical or horizontal. A vertical seam is a path of pixels connected from top to bottom in an image with one pixel in each row. A horizontal seam is similar with the exception of the connection being from left to right. The importance/energy function values a pixel by measuring its contrast with its neighbor pixels.


Process

The below example describes the process of seam carving: The seams to remove depends only on the dimension (height or width) one wants to shrink. It is also possible to invert step 4 so the algorithm enlarges in one dimension by copying a low energy seam and averaging its pixels with its neighbors.


Computing seams

Computing a seam consists of finding a path of minimum energy cost from one end of the image to another. This can be done via
Dijkstra's algorithm Dijkstra's algorithm ( ) is an algorithm for finding the shortest paths between nodes in a graph, which may represent, for example, road networks. It was conceived by computer scientist Edsger W. Dijkstra in 1956 and published three years ...
, dynamic programming,
greedy algorithm A greedy algorithm is any algorithm that follows the problem-solving heuristic of making the locally optimal choice at each stage. In many problems, a greedy strategy does not produce an optimal solution, but a greedy heuristic can yield locally ...
or graph cuts among others.


Dynamic programming

Dynamic programming Dynamic programming is both a mathematical optimization method and a computer programming method. The method was developed by Richard Bellman in the 1950s and has found applications in numerous fields, from aerospace engineering to economics. ...
is a programming method that stores the results of sub-calculations in order to simplify calculating a more complex result. Dynamic programming can be used to compute seams. If attempting to compute a vertical seam (path) of lowest energy, for each pixel in a row we compute the energy of the current pixel plus the energy of one of the three possible pixels above it. The images below depict a DP process to compute one optimal seam. Each square represents a pixel, with the top-left value in red representing the energy value of that pixel. The value in black represents the cumulative sum of energies leading up to and including that pixel. File:DynamicProgrammingLeastEnergyPathA.svg, The top row has nothing above it, so the energies are the same as the source image. File:DynamicProgrammingLeastEnergyPathB.svg, For each pixel in the rest of the rows, the energy is its own energy plus the minimal of the three energies above. Repeat until the bottom is reached. File:DynamicProgrammingLeastEnergyPathC.svg, For the lowest energies we have at the end, work back up the minimals to recover the seam with minimal energy. The energy calculation is trivially parallelized for simple functions. The calculation of the DP array can also be parallelized with some interprocess communication. However, the problem of making multiple seams at the same time is harder for two reasons: the energy needs to be regenerated for each removal for correctness and simply tracing back multiple seams can form overlaps. Avidan 2007 computes all seams by removing each seam iteratively and storing an "index map" to record all the seams generated. The map holds a "nth seam" number for each pixel on the image, and can be used later for size adjustment. If one ignores both issues however, a greedy approximation for parallel seam carving is possible. To do so, one starts with the minimum-energy pixel at one end, and keep choosing the minimum energy path to the other end. The used pixels are marked so that they are not picked again. Local seams can also be computed for smaller parts of the image in parallel for a good approximation.


Issues

# The algorithm may need user-provided information to reduce errors. This can consist of painting the regions which are to be preserved. With human faces it is possible to use face detection. # Sometimes the algorithm, by removing a low energy seam, may end up inadvertently creating a seam of higher energy. The solution to this is to simulate a removal of a seam, and then check the energy delta to see if the energy increases (forward energy). If it does, prefer other seams instead.Improved Seam Carving for Video Retargeting.
Michael Rubinstein, Ariel Shamir, Shai Avidan. SIGGRAPH 2008.


Implementations

File:Broadway_tower_seam_carving_interactive.svg, 250px, Interactive SVG demonstrating seam-carving using ImageMagick's liquid-rescale function
In the SVG file
hover over the percentages to compare the original image (top), its width rescaled to the percentage using seam-carving (middle), and rescaled to the same size using interpolation (bottom). defaul

File:Creation_of_Adam_seam_carving_interactive.svg, 250px, Interactive SVG demonstrating seam-carving using ImageMagick's liquid-rescale function
In the SVG file
hover over the percentages as above. Note that the faces are affected less than their surroundings. defaul

Adobe Systems Adobe Inc. ( ), originally called Adobe Systems Incorporated, is an American multinational computer software company incorporated in Delaware and headquartered in San Jose, California. It has historically specialized in software for the cr ...
acquired a non-exclusive license to seam carving technology from MERL, and implemented it as a feature in
Photoshop Adobe Photoshop is a raster graphics editor developed and published by Adobe Inc. for Microsoft Windows, Windows and macOS. It was originally created in 1988 by Thomas Knoll, Thomas and John Knoll. Since then, the software has become the indu ...
CS4, where it is called Content Aware Scaling. As the license is non-exclusive, other popular computer graphics applications (e. g.
GIMP GIMP ( ; GNU Image Manipulation Program) is a free and open-source raster graphics editor used for image manipulation (retouching) and image editing, free-form drawing, transcoding between different image file formats, and more specialized ta ...
, digiKam, and
ImageMagick ImageMagick, invoked from the command line as magick, is a free and open-source cross-platform software suite for displaying, creating, converting, modifying, and editing raster images. Created in 1987 by John Cristy, it can read and write ov ...
) as well as some stand-alone programs (e. g. iResizer) also have implementations of this technique, some of which are released as
free and open source software Free and open-source software (FOSS) is a term used to refer to groups of software consisting of both free software and open-source software where anyone is freely licensed to use, copy, study, and change the software in any way, and the sou ...
.


Improvements and extensions

* Better energy function and application to video by introducing 2D (time+1D) seams. ** Faster implementation on GPU. ** Application of this forward energy function to static images. * Multi-operator: Combine with cropping and scaling. * Much faster removal of multiple seams A 2010 review of eight image retargeting methods found that seam carving produced output that was ranked among the worst of the tested algorithms. It was, however, a part of one of the highest-ranking algorithms: the multi-operator extension mentioned above (combined with cropping and scaling). See also th
RetargetMe benchmark


See also

*
Inpainting Inpainting is a conservation process where damaged, deteriorated, or missing parts of an artwork are filled in to present a complete image. This process is commonly used in image restoration. It can be applied to both physical and digital art me ...
*
Texture synthesis Texture synthesis is the process of algorithmically constructing a large digital image from a small digital sample image by taking advantage of its structural content. It is an object of research in computer graphics and is used in many fields, amo ...


References


External links


Interactive demo of seam carving
* Seam Carving demonstration videos: *
on YouTube
*
on Ariel Shamir's pages
on the Interdisciplinary Center web site (higher resolution)
Explanation of seam carving (Liquid rescaling)
at the
ImageMagick ImageMagick, invoked from the command line as magick, is a free and open-source cross-platform software suite for displaying, creating, converting, modifying, and editing raster images. Created in 1987 by John Cristy, it can read and write ov ...
website
Implementation tutorial of seam carving
{{Mitsubishi Electric Image processing Mitsubishi Electric products, services and standards