what is retargeting using seam carving, anyway?
Image retargeting using seam carving allows an image to change sizes without distorting key areas of interest. Take this image for example:
If we want to widen the image so that it fits a particular screen size, we can use standard image scaling, but the result will look distorted:
With retargeting, pixels in the image that are in areas of interest are preserved, so the image is widened with little noticeable distortion:
For a more detailed explanation of how it works, check out the video
created by seam carving pioneers Shai Avidan and Ariel Shamir. rsizr offers an implementation of this resizing technique using a novel algorithm that allows for real-time retargeting along the horizontal and vertical axes simultaneously.
retargeting on rsizr
Choose the "retarget" button from the resize functions tab:
You'll see a vertical slider and horizontal slider surrounding your image:
To resize your image, you must first create seams. Moving the handle on the vertical slider will create horizontal seams, and moving the handle on the horizontal slider will create vertical seams.
- horizontal seams - allow you to shrink or stretch the image vertically.
- vertical seams- allow you to shrink or stretch the image horizontally.
Sounds complicated, but it's rather simple when you're doing it. Feel free to move the slider handles while seams are being calculated. For example, while seams are being calculated in one direction, you can move the other slider's handle to tell rsizr to (once this direction is done calculated) calculate seams in the other direction. Or, if you want to calculate fewer seams than you originally set it for, just move the slider handle back.
Stopping seam generation
. To stop seams from being generated, just move the slider back into the blue area.
Once seams are done calculating, you will see handles appear around your image that allow you to resize the image:
what exactly do these seams do?
The rsizr application looks at your picture and places seams where there are fewer high contrast areas. Because these high contrast areas (with many edges) generally contain key features in the image, they are avoided by seams. For example:
The vertical seams we calculated tend to avoid the building in the center because it has many edges. When we shrink the image horizontally, it is these vertical seams that are removed from the image:
And when we expand the image horizontally, it is these vertical seams that are duplicated in the image:
using the preserve, remove, and erase brushes
If you would like to change which areas are preserved or removed by seams, you can use the preserve and remove brushes:
When you are using these brushes, your cursor will reflect the size of brush that you are using. You can change the size of the brush using the Brush Size
submenu on the right. When you are using these brushes, the image will go back to the size it was before any resizing you may have done in retarget
- preserve - Areas marked with the preserve brush will be avoided by horizontal and vertical seams. When the image is resized either down or up, these areas will remain unchanged.
- remove - Areas marked with the remove brush will attract horizontal and vertical seams. When the image is resized to a smaller size, these areas will be removed first. When the image is resized to a larger size, these areas will be multiplied first.
- erase - Use this brush to remove markings made with either the preserve brush or the remove brush.
An example of when you might want to use these brushes is if seams are going through areas of your image that you want to protect. For example, with the building image above (with expanded red seams), seams are passing through the bottom left corner of the center building, causing distortion in that area when the image is expanded:
To prevent this distortion, we use the preserve brush and paint that corner of the building:
You can use the zoom in and out buttons (or the wheel on your mouse) to change your view of the canvas.
on the submenu and any seams you had set will be recalculated. The new seams will avoid the marked areas:
And now there is no distortion in the bottom left corner of the center building: