PDA

View Full Version : ReTarget Plugin


vcmohan
17th July 2008, 12:31
Seam carving an image for resizing was earlier attempted and is available as 'Seamer' plugin. Recently Shai Avidan and Ariel Shamir in their paper titled "improved seam carving for video retargetting" proposed some new criteria for application to resizing video images to a target display device eg; cell phone. Using a modified approach to their proposed considerations a new plugin ReTarget is developed. This has the option to either use forward or backward energy for seam detection. Option to mask upto 4 areas for either protection or erasing is included. These areas can also translate frame to frame linearly. While the process is slow from second frame onwards it runs faster. Also unlike the formulation by the authors of the paper, this plugin does not use up much memory.

Mystery Keeper
17th July 2008, 14:42
Interesting in technological sense. But what is the practical use of such resizing?

Comatose
17th July 2008, 20:43
Resizing a video to fit another aspect ratio... if the filter eventually gets fast and reliable enough, it could be added to ffdshow and we'd say bye to black bars :p (in the case of upsizing only, ofcourse - so no info is lost)

mikeytown2
17th July 2008, 21:12
Thanks for doing this! I have a couple of questions/comments

What do Bool Peak and Bool Alt do?

The download link at the bottom is broken on this page
http://avisynth.org/vcmohan/ReTarget/ReTarget.html

Any Chance of using a clip for the mask, just like overlay? I think it would make the plugin easier to use.

When no resizing is taking place, have the clip pass threw untouched instead of throwing an error.




Did some quick tests using this image from wikipedia (http://en.wikipedia.org/wiki/Sunset)
http://img440.imageshack.us/img440/7429/wikipediamiamisunset200ke5.th.jpg (http://img440.imageshack.us/my.php?image=wikipediamiamisunset200ke5.jpg)



c = ImageReader("wikipediamiamisunset200ke5.jpg",0,99)

c.Animate(0,99,"ReTargeter",640,479,-1, 640,100,-1)
last + c.ReTarget(640,100).ZoomBox(640,480,Align=-1).Trim(0,9)
last + c.Animate(0,99,"ReTargeter",639,480,-3, 100,480,-3)
last + c.ReTarget(100,480).ZoomBox(640,480,Align=-3).Trim(0,9)
last + c.Animate(0,99,"ReTargeter",639,479,-5, 100,100,-5)
last + c.ReTarget(100,100).ZoomBox(640,480,Align=-5).Trim(0,9)


Function ReTargeter(clip c, int x, int y, int a)
{
c
ReTarget(x,y)
ZoomBox(640,480,Align=a)
}


It's cropping the image from the bottom and/or left instead of making seams, unless I'm doing something wrong???

Zoombox() (http://forum.doom9.org/showthread.php?p=1111789#post1111789)


EDIT: Only messes up when I use Animate

vcmohan
18th July 2008, 09:28
. if the filter eventually gets fast and reliable enough, it could be added to ffdshow and we'd say bye to black bars :p (in the case of upsizing only, ofcourse - so no info is lost)

As it is implemented it is a lot faster than the authors of the paper indicate in their paper. May be because I have taken some shortcuts and rounded corners. But it should not effect the end image that much.

At the moment this plugin does not do upsizing. Upsizing involves some inpainting techniques which I am not familiar with. The seamer plugin has the upsizing feature, which sometimes produce acceptable image quality.

I have devoloped this plugin as per discussions on seam carving in the Avisynth development forum.

Mystery Keeper
18th July 2008, 09:33
Comatose. You don't really need to resize it to any aspect ratio. You see, in most cases the video is smaller than your desktop resolution. You can encode it as anamorphic and set whatever DAR you need. It will be upscaled to fit it.

Comatose
18th July 2008, 14:51
The idea is being able to display it in a different AR... this is also something that the YouTube video mentions.

vcmohan
19th July 2008, 12:34
What do Bool Peak and Bool Alt do?
Sorry I missed your this post.
I need to remove these parameters. Relics from Seamer. Pl ignore them till I cleanup.

When no resizing is taking place, have the clip pass threw untouched instead of throwing an error.

I can do that. Initially I planned it like that but later thought throwing an error may be better so that user is warned.

Did some quick tests using this image
It's cropping the image from the bottom and/or left instead of making seams, unless I'm doing something wrong???


I checked with following code

im1 = imagereader("D:\transplugins\sunsetretarget.jpg", end = 20).converttoRGB32()
im1 = lanczosresize(im1,400,400)# save some time
trm1 = ReTarget(im1,x =400,y = 200,em1x=0, mvpx = 1, pvpx = 1)
trm2 = ReTarget(im1,x = 200,y = 200)
red = lanczosresize(im1,400,200)
red1 = reduceby2(im1)
s1 = stackhorizontal (trm1,trm2)
s2 = stackhorizontal(red, red1)
stackvertical(s1,s2)

I get the following comparison. It appears it is working as it should. The lower images are by resizing while the upper set is through Retarget.

http://img134.imageshack.us/img134/2268/retargettedsunset0af4.th.jpg (http://img134.imageshack.us/my.php?image=retargettedsunset0af4.jpg)


I found that unless the parameters pvpx, mvpx, phpx, mhpx are specified as 1 in a video some errors are creeping in. It looks it may take some time to debug this part.