Seam Carving: Resizing Images Without Distortion

Seam carving resizes images by removing or adding pixel "seams" of low importance, not by squashing or cropping the whole frame. It's used in content-aware tools to change aspect ratios without distorting key subjects like faces or buildings.
WHY IT EXISTS Traditional image resizing methods have major drawbacks. Scaling an image distorts its content, making people and objects look squashed or stretched. Cropping an image preserves the aspect ratio but throws away content at the edges. Seam carving was invented to resize images by removing or adding pixels in a way that preserves the most important visual information.
THE MENTAL MODEL Imagine an image is a piece of fabric. To make it narrower, you don't just squeeze it. Instead, you find the least interesting vertical threads (the "seams") and carefully pull them out one by one. The important patterns on the fabric remain intact, but the overall piece is smaller. To make it wider, you'd find those same boring threads and stitch in a copy next to them.
HOW IT WORKS The algorithm establishes a number of possible seams in an image, which are continuous paths of pixels from one edge to the opposite. To reduce an image's size, it identifies the seam that is least visually important (e.g., a path through a plain blue sky) and removes it. This process is repeated until the desired size is reached. To expand an image, it finds the least important seam and inserts a new seam next to it, with pixel values averaged from their neighbors. It can also be used to remove entire objects by repeatedly carving seams that pass through the object.
WHEN TO USE IT Use seam carving for content-aware resizing, like changing a wide landscape photo to fit a tall, narrow frame without distorting the mountains or trees. It is also effective for object removal, where an unwanted element can be cleanly carved out of a scene by removing all seams that intersect it. You can also manually define protected areas that the algorithm is forbidden from altering.
WHEN NOT TO USE IT Seam carving can produce visible artifacts in images with strong geometric patterns, straight lines, or complex textures. Since it removes pixels, it is inherently a destructive process and is not suitable for resizing where perfect fidelity is required, such as with technical diagrams or text.
ONE CANONICAL EXAMPLE A classic example is taking a wide photograph of a beach with a lighthouse on one side and a person on the other, separated by a large expanse of sand and sky. To make the image narrower, seam carving will remove vertical seams from the empty sand and sky, bringing the lighthouse and person closer together without distorting either subject.
Read the original → en.wikipedia.org
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.