Liquid Resize & Seam Carving
Posted: 2007-12-17T17:18:34-07:00
It has been suggested that IM should provide an operator to allow you to do Liquid Resize, also known as Seam Carving...
YouTube Video Demo: http://www.youtube.com/watch?v=c-SSu3tJ3ns
PDF document: http://www.faculty.idc.ac.il/arik/imret.pdf
Wikipedia (source links): http://en.wikipedia.org/wiki/Seam_carving
The problem is not so much adding this to IM. IM would be very capable of doing this type of thing. It is getting programmers with some time to implement it.
Also as it is just direct pixel removal a lot of other aspects of resizing (filtering) is not needed, I am sure that some local filtering could also improve overall results for a higher quality IM output. An optional second image can be used to add positive / negative weights, perhaps with a user generated energy function, or face reconition masking.
In fact some of the sub-functions would be useful things in and of themselves.
One use that was not shown was the use of seam carving to generate 'fold lines' in an image animation. The YouTube Video uses something like that at the begining and end of the video when resizing the title image. It can also be used for the removal of interline space within a text file.
Also something that has not been mentioned was how the algorithm should remove seams that all have about the same minimal energy! Or methods that try to separate the seams so you don't end up remove a stack of seams that are all next to each other. This is something I noticed happening in some of the incremental demonstrations.
On thing I would like to try is to use the seam removal (pixel removal mask) to create a distortion map, rather than just direct pixel removal. That of course means access to the intermediate image processing stages. Of source the resulting image should be better as it will be properly smoothed from seam artifacts, but it will not be much good for object removal, not unless you did that in two stages.
You should have a look at this. It is very interesting. It is resizing by simple pixel removal but in a very special and interesting way, so as to try an preserve image content defined either by 'energy' functions, or adjusted by secondary masks (user or program generated)DeadlyDad wrote:How hard would it be to add liquid resizing/seam carving to IM? It would be a very cool addition to the library, though I understand that protection/deletion would have to be done with masks.
YouTube Video Demo: http://www.youtube.com/watch?v=c-SSu3tJ3ns
PDF document: http://www.faculty.idc.ac.il/arik/imret.pdf
Wikipedia (source links): http://en.wikipedia.org/wiki/Seam_carving
The problem is not so much adding this to IM. IM would be very capable of doing this type of thing. It is getting programmers with some time to implement it.
Also as it is just direct pixel removal a lot of other aspects of resizing (filtering) is not needed, I am sure that some local filtering could also improve overall results for a higher quality IM output. An optional second image can be used to add positive / negative weights, perhaps with a user generated energy function, or face reconition masking.
magick wrote:I added it to the TO-DO list. I have about 2 months of work (Wizards toolkit, textual data mining, started writing a book) before I have more than a few minutes of free time.
In fact some of the sub-functions would be useful things in and of themselves.
- the Autocrop method, that is mentioned at the start of the PDF paper. That is find the crop position of a specific size basied on maximizing the energy function.
- The generation of some of the various energy functions mentioned. (preservation masks)
- The generation of a the list of seams to be removed in sequence from the preservation mask (generated from combining a user selection with the energy function) as a gray-scale image that can be thresholded, based on the number of seams to be removed.
- A routine to delete a boolean mask of pixels (the thresholded seams list image) by shifting rows left or columns up. Assuming a equal number of pixels is removed from every row/column to preserve the rectangular image outline.
One use that was not shown was the use of seam carving to generate 'fold lines' in an image animation. The YouTube Video uses something like that at the begining and end of the video when resizing the title image. It can also be used for the removal of interline space within a text file.
Also something that has not been mentioned was how the algorithm should remove seams that all have about the same minimal energy! Or methods that try to separate the seams so you don't end up remove a stack of seams that are all next to each other. This is something I noticed happening in some of the incremental demonstrations.
On thing I would like to try is to use the seam removal (pixel removal mask) to create a distortion map, rather than just direct pixel removal. That of course means access to the intermediate image processing stages. Of source the resulting image should be better as it will be properly smoothed from seam artifacts, but it will not be much good for object removal, not unless you did that in two stages.