AI Glossary / Computer vision and multimodal AI / Advanced

Seam carving

Definition

Seam carving is a content-aware image-resizing technique that removes or inserts connected paths of pixels called seams. A vertical seam contains one pixel in each row, with neighboring selections connected across rows; a horizontal seam follows the corresponding column-wise pattern. A chosen energy or cost function determines which paths are preferred, so preservation depends on how that cost represents image content.

What it means

Ordinary scaling changes the whole image geometrically, while cropping discards a rectangular portion. Seam carving can change dimensions by distributing removals through selected paths. This can preserve some prominent regions while reducing less important areas, but it can also bend structures or distort relationships. The algorithm's notion of expendable content is not necessarily the viewer's. A low-cost region may contain meaningful context, and repeated removals can eventually force changes through areas that were initially well preserved.

How it works

Assign costs to pixels or transitions, then find an allowed seam with a low total cost. For a standard vertical formulation, dynamic programming accumulates the best predecessor cost from the row above and backtracking recovers a minimum-cost path. Remove that seam to reduce width by one pixel and update the image before further removals. Variants can incorporate protection masks or costs reflecting the disruption caused by removal. Seam insertion supports expansion, but inserted samples do not recover previously unseen scene detail. Each optimization is tied to its stated cost and constraints.

Three practical examples

  • A publishing team adapts a landscape photograph to a narrower layout while reviewing whether important objects retain plausible proportions.
  • A classroom exercise compares minimum-cost seams under two different energy maps for the same image.
  • A graphics workflow protects a marked subject and evaluates whether the remaining background can absorb the requested size change.

Think of it this way

Imagine shortening a woven picture by carefully removing a thread that winds through areas you judge less important, then joining the remaining fabric. Repeating the process changes the picture's width without cutting away one large side strip. However, the weaving can become distorted, and a thread that looks unimportant locally may cross a meaningful pattern. The analogy captures selective removal while emphasizing that connectivity and repeated edits affect the whole composition.

Worked example

Consider an original three-row energy grid with rows [5,1,5], [5,2,5] and [5,1,5]. A vertical seam through the middle column has total cost 1+2+1=4. It is connected and attains each row's minimum, so no allowed seam can have lower cost in this particular grid. Removing it changes a three-pixel-wide image to two pixels wide while retaining three rows. This arithmetic establishes optimality only for the supplied costs and one removal. It does not show that the removed pixels are semantically unimportant or that a sequence of individually optimal removals gives the best final composition.

Illustrative case study

A fictional travel publisher needs a narrower version of a photograph containing a monument and patterned paving. Seam carving preserves much of the monument, but repeated removals visibly bend the paving pattern. The editor compares a smaller adjustment, a crop and a combined workflow before choosing the final image. The team reviews the result at its actual display size. This scenario illustrates content-dependent suitability rather than claiming that an automated energy minimum produces the most natural-looking image or preserves the geometry of every object and background feature.

Common misconceptions and mistakes

Content-aware does not mean semantically infallible. An energy based on local contrast can undervalue smooth but meaningful objects or overvalue irrelevant texture. Another mistake is assuming seam carving preserves all proportions and straight lines. Large aspect-ratio changes can exceed what a scene can tolerate gracefully. Reusing an initial cost map without appropriate updates can also misrepresent the changing image. Finally, a minimum-cost seam is optimal under a mathematical objective; that statement should not be expanded into a guarantee of perceptual quality or globally optimal repeated resizing.

Business use

Seam carving can help adapt selected images to layout constraints, but it needs review where shape and spatial relationships matter. Compare it with cropping and scaling on representative content, including faces, architecture, text and repeated patterns. Keep the original image and record any protected regions or user guidance. Establish when the requested size change is too large for acceptable results. For documentary, measurement or product imagery, consider whether altered geometry undermines the intended meaning before adopting content-aware resizing as an automatic production step.

People also ask

Does removing a vertical seam reduce height?

No. It removes one selected pixel per row, reducing width by one.

Must a seam be a straight column?

No. It can shift between adjacent columns while remaining connected.

Is the lowest-energy result always visually best?

No. The energy is a proxy whose priorities may differ from human judgment.

Check your understanding

What was the example seam's cost?

Answer: Four.

Why was it minimal in that grid?

Answer: It used the minimum available cost in every row while satisfying connectivity.

Why did this not prove the final picture would look correct?

Answer: The cost values did not encode a complete judgment of meaning, geometry or visual quality.

Related terms

  • Dynamic programming
  • Image retargeting
  • Content-aware resizing
  • energy function
  • forward energy
  • protection mask

Learn next

Find a seam by hand in a small energy grid, checking the allowed predecessor positions. Remove it and redraw the grid dimensions. Then change the costs to protect a region and compare the selected path, explaining what the revised objective preserves and what it still ignores.

More in Computer vision and multimodal AI

  • Scanpath - A scanpath is an ordered description of where a person's gaze moves while viewing a stimulus, often represented as a sequence of fixations linked by saccades.
  • Scatter matrix - A scatter matrix summarizes multivariate variation through sums of outer products of centered observation vectors.
  • Scene text
  • Segmentation - In computer vision, segmentation divides an image or related visual representation into regions or assigns labels at a fine spatial level, commonly per pixel.
  • Self-similarity matrix - A self-similarity matrix compares elements of a sequence or collection with other elements of the same sequence or collection.
  • Semantic gap - The semantic gap is the mismatch between information represented or extracted by a computational system and the meaning people attach to that information in...

Sources

Avidan and Shamir, Seam Carving for Content-Aware Image Resizing, MERL publication record: https://www.merl.com/publications/TR2007-087 Princeton University, Seam Carving assignment: https://www.cs.princeton.edu/courses/archive/spring26/cos226/assignments/seam/specification.php The three-row calculation, woven-picture analogy and travel-publisher case are original educational illustrations. Minimum cost is defined relative to the stated objective and is not presented as a guarantee of semantic or visual preservation.

Previous: Sealed-bid second-price auction Next: Search

  • Home
  • Daily AI Updates
  • Blog
  • AIFBL Academy
  • AI Glossary
  • Products and Tools
  • Store
  • Free CFO AI Prompt Pack
  • About Shihan Sheriff
  • Privacy Policy
  • Terms of Use
  • Refund Policy
  • Cookie Policy
  • Earnings Disclaimer