Quantcast Sansgrip Filters: Removeborders - digitalFAQ.com Forums [Archives]
  #1  
01-06-2003, 09:19 PM
SansGrip SansGrip is offline
Free Member
 
Join Date: Nov 2002
Location: Ontario, Canada
Posts: 1,135
Thanks: 0
Thanked 0 Times in 0 Posts
I've been playing around today and whipped something together you might have fun with. It's the conceptual opposite of AddBorders: instead of surrounding the frame with black, it removes black borders from the source.

It tries to be accurate by sampling a number of frames over the course of the clip then taking the most common "border size" for each edge. More info -- slightly more, anyway -- is available in the readme.

I'm hoping to expand this into an Avisynth version of FitCD...

As usual, you can get it from my web site, to which you'll find a link below.

First, run it with no parameters (i.e. RemoveBorders()) and see if that works for you. Let me know if you have any problems.
Reply With Quote
Someday, 12:01 PM
admin's Avatar
Site Staff / Ad Manager
 
Join Date: Dec 2002
Posts: 42
Thanks: ∞
Thanked 42 Times in 42 Posts
  #2  
01-06-2003, 09:37 PM
black prince black prince is offline
Free Member
 
Join Date: Jul 2002
Posts: 1,224
Thanks: 0
Thanked 0 Times in 0 Posts
Hey SansGrip,

Sounds like AutoCrop(true,1,1,0,0,0,0,40,10) where 10 is the number
of frames samples, true is display mode, width multiplied by 1,
height multiplied by 1, etc. I used it to get full screen, but it would
not give the correct aspect ratio like FitCD.

-black prince
Reply With Quote
  #3  
01-06-2003, 09:39 PM
SansGrip SansGrip is offline
Free Member
 
Join Date: Nov 2002
Location: Ontario, Canada
Posts: 1,135
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by black prince
Sounds like AutoCrop(true,1,1,0,0,0,0,40,10)
Except this one you use like this:

RemoveBorders()

and it'll eventually do everything FitCD does -- at least with regard to resizing .
Reply With Quote
  #4  
01-06-2003, 10:00 PM
kwag kwag is offline
Free Member
 
Join Date: Apr 2002
Location: Puerto Rico, USA
Posts: 13,537
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by SansGrip
Quote:
Originally Posted by black prince
Sounds like AutoCrop(true,1,1,0,0,0,0,40,10)
Except this one you use like this:

RemoveBorders()

and it'll eventually do everything FitCD does -- at least with regard to resizing .
What do I set the Input Aspect to in TMPEG? I can see that it automatically filled the screen if I browse around on source range . The film is nice and clipped without borders. So what aspect do I set TMPEG to, and what about blocks overscan?

-kwag
Reply With Quote
  #5  
01-06-2003, 10:00 PM
black prince black prince is offline
Free Member
 
Join Date: Jul 2002
Posts: 1,224
Thanks: 0
Thanked 0 Times in 0 Posts
@SansGrip,

SansGrip wrote:
Quote:
RemoveBorders()

and it'll eventually do everything FitCD does -- at least with regard to resizing .
WOW!!! that's great
I thought you said it would be difficult to duplicate FitCD as a filter
That would be fantastic though

-black prince
Reply With Quote
  #6  
01-06-2003, 10:06 PM
SansGrip SansGrip is offline
Free Member
 
Join Date: Nov 2002
Location: Ontario, Canada
Posts: 1,135
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by kwag
The film is nice and clipped without borders. So what aspect do I set TMPEG to, and what about blocks overscan?
That's the stuff it doesn't do yet . Right now you'll still have to use FitCD to determine the correct resizing values, but you can use

RemoveBorders()
BilinearResize(..., ...)

instead of

Crop(..., ..., ..., ...)
BilinearResize(..., ...)

In future versions it'll do the resizing too .
Reply With Quote
  #7  
01-06-2003, 10:32 PM
kwag kwag is offline
Free Member
 
Join Date: Apr 2002
Location: Puerto Rico, USA
Posts: 13,537
Thanks: 0
Thanked 0 Times in 0 Posts
This looks VERY promising SansGrip
So this will basically remove FitCD from the ballgame
( You should call it: AutoFit : )

-kwag
Reply With Quote
  #8  
01-07-2003, 07:23 AM
SansGrip SansGrip is offline
Free Member
 
Join Date: Nov 2002
Location: Ontario, Canada
Posts: 1,135
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by kwag
So this will basically remove FitCD from the ballgame
That's what I plan.

Quote:
( You should call it: AutoFit : )
I do need to come up with a different name, but "AutoFit" might be confused with "AutoCrop" .
Reply With Quote
  #9  
01-07-2003, 08:31 AM
kwag kwag is offline
Free Member
 
Join Date: Apr 2002
Location: Puerto Rico, USA
Posts: 13,537
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by SansGrip
I do need to come up with a different name, but "AutoFit" might be confused with "AutoCrop" .
AutoGrip
Reply With Quote
  #10  
01-07-2003, 08:48 PM
black prince black prince is offline
Free Member
 
Join Date: Jul 2002
Posts: 1,224
Thanks: 0
Thanked 0 Times in 0 Posts
@SansGrip,

Quote:
CropsyX
Junior Member

Registered: Oct 2002
Location:
Posts: 7

ldivx

If you run AutoCrop with preview=false, then AviSynth will update it's built in width and height variables appropriately. Then you can use a function like the one below to set the new width and have the height calculated to main aspect ratio.

Sample Usage:

ResizeMaintainAspectWidth(384,"BiCubicResize")

That will call BiCubicResize with the width set to 384 and the height set to maintain aspect ratio.

function ResizeMaintainAspectWidth(clip c,int newwidth,string resizefn) {
nh=floor(eval(string(c.height)+". * "+string(newwidth)+". / "+string(c.width)+"."))
return eval(resizefn+"(c,"+string(newwidth)+","+string(nh )+")")
}
Have you seen this on Doom9 to calculate aspect ratio with AutoCrop.
Maybe AutoGrip could use some ideas from this

-black prince
Reply With Quote
  #11  
01-07-2003, 09:30 PM
Gaudi Gaudi is offline
Free Member
 
Join Date: Dec 2002
Location: Buenos Aires, Argentina
Posts: 131
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Gaudi
Quote:
Originally Posted by kwag
Quote:
Originally Posted by SansGrip

I do need to come up with a different name, but "AutoFit" might be confused with "AutoCrop" .
AutoGrip
A couple of suggestions:
  • RoboCrop
    RoboFit
    RoboGrip (perhaps)
Gaudi
Reply With Quote
  #12  
01-07-2003, 09:32 PM
kwag kwag is offline
Free Member
 
Join Date: Apr 2002
Location: Puerto Rico, USA
Posts: 13,537
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by Gaudi
RoboGrip (perhaps)
That's a good one
Even RoboCrop is great
Reply With Quote
  #13  
01-07-2003, 09:43 PM
Gaudi Gaudi is offline
Free Member
 
Join Date: Dec 2002
Location: Buenos Aires, Argentina
Posts: 131
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Gaudi
Thanks.

Lets see SansGrip oppinion.
Reply With Quote
  #14  
01-08-2003, 12:49 AM
katchupoy katchupoy is offline
Free Member
 
Join Date: Dec 2002
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
First try... Error... Illegal something.... can't remember...
Second try... It worked... did'nt touch anything... but I have a thick green line on the lower part of the screen...
Reply With Quote
  #15  
01-08-2003, 01:11 AM
black prince black prince is offline
Free Member
 
Join Date: Jul 2002
Posts: 1,224
Thanks: 0
Thanked 0 Times in 0 Posts
@SansGrip,

I created a avs script called RoboFit with automatic aspect ratio:

RoboFit.avs:
LoadPlugin("E:\DVD Backup\2 - DVD2SVCD\MPEG2DEC\MPEG2DEC2.dll")
LoadPlugin("E:\DVD Backup\2 - DVD2SVCD\MPEG2DEC\MPEG2DEC.dll")
LoadPlugin("E:\DVD Backup\2 - DVD2SVCD\LegalClip\LegalClip.dll")
LoadPlugin("E:\DVD Backup\2 - DVD2SVCD\Blockbuster\Blockbuster.dll")
LoadPlugin("E:\DVD Backup\2 - DVD2SVCD\FluxSmooth\FluxSmooth.dll")
LoadPlugin("E:\DVD Backup\2 - DVD2SVCD\Sampler\Sampler.dll")
LoadPlugin("E:\DVD Backup\2 - DVD2SVCD\RemoveBorders\RemoveBorders.dll")
mpeg2source("D:\Temp\movie.d2v")
LegalClip()
RemoveBorders()
#
# Get aspect ratio
#
Import("E:\DVD Backup\1 - DVD2KVCD\0 - Utilities\Avisynth\aspect_ratio.avs")
ResizeMaintainAspectWidth(496,"BilinearResize")

#
Blockbuster(method="noise",variance=.5,seed=1)
FluxSmooth()
LegalClip()
#Sampler()




Aspect_Ratio.avs:
function ResizeMaintainAspectWidth(clip c,int newwidth,string resizefn) {
nh=floor(eval(string(c.height)+". * "+string(newwidth)+". / "+string(c.width)+"."))
return eval(resizefn+"(c,"+string(newwidth)+","+string(nh )+")")
}


Tmpgenc gives me a resolution of 496x327, where as manually it came
to 496x336. Of course Tmpgenc takes care of borders.
I just filled in the width, 496 in red in RoboFit and the function
created the proper height to keep aspect ratio. It's, 327, off by 9 to
come to 336. The formula needs tweaking or maybe it's correct.
Using preview in Tmpgenc, it looks good. TV-overscan is accounted
for by using 496 as width.

-black prince
Reply With Quote
  #16  
01-08-2003, 01:16 AM
kwag kwag is offline
Free Member
 
Join Date: Apr 2002
Location: Puerto Rico, USA
Posts: 13,537
Thanks: 0
Thanked 0 Times in 0 Posts
Ah! black prince really getting to be a real "Hard Core" programmer on AviSynth
That script is cool

-kwag
Reply With Quote
  #17  
01-08-2003, 10:26 AM
SansGrip SansGrip is offline
Free Member
 
Join Date: Nov 2002
Location: Ontario, Canada
Posts: 1,135
Thanks: 0
Thanked 0 Times in 0 Posts
That formula won't be as accurate as FitCD (since FitCD uses the pixel aspect ratio of the source and target rather than simply going by frame size). I'm also not sure how it works with anamorphic material, which needs special handling.

I'm working on RemoveBorders's big brother right now (I called it GripFit but I like RoboCrop a lot better -- I'd buy that for a dollar! ). It guesses the (hopefully) correct pixel aspect ratios from the original and desired frame sizes and also attempts to use a sensible default for whether the source is anamophic or not (if it thinks the clip is from a DVD it treats it as anamorphic by default, otherwise it treats it as non-anamorphic).

I'm not too far away from first release, maybe a day or two .
Reply With Quote
  #18  
01-08-2003, 09:19 PM
SansGrip SansGrip is offline
Free Member
 
Join Date: Nov 2002
Location: Ontario, Canada
Posts: 1,135
Thanks: 0
Thanked 0 Times in 0 Posts
Just a quick update --

I have RoboCrop () successfully guessing both the source and destination pixel aspect ratios for a number of sources and targets, NTSC and PAL.

Right now it crops existing borders, resizes (with an adjustment for anamorphic sources) and adds borders back in to make the final frame size. Brief tests indicate (at least to the eye) that it's preserving aspect ratio correctly.

The source is very messy, though (since it kind of evolved from RemoveBorders) and I need to rewrite it. I also need to optimize the algorithm somewhat, since at the moment it crops, resizes, crops again if necessary, then adds borders. I want to get rid of that second crop. In addition I have to implement height rounding like FitCD does. And finally I'll need to make sure that there are a good number of options (e.g. rounding values, whether or not to add borders -- what would be nice is if you could run it multiple times, once with mode="resize" where it resizes but doesn't add borders, then again later with mode="borders" to finish the job -- and so on).

I would say I'm probably a few days away from a release, but it's looking very promising .
Reply With Quote
  #19  
01-08-2003, 11:17 PM
katchupoy katchupoy is offline
Free Member
 
Join Date: Dec 2002
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
You Guys are really incredible... You guys are the man!!!
Reply With Quote
  #20  
01-08-2003, 11:24 PM
Gaudi Gaudi is offline
Free Member
 
Join Date: Dec 2002
Location: Buenos Aires, Argentina
Posts: 131
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Gaudi
I am willing to see the baby...





Gaudi
Reply With Quote
Reply




Similar Threads
Thread Thread Starter Forum Replies Last Post
SansGrip Filters: SansGrip Is Back Thread! Jellygoose Avisynth Scripting 8 02-28-2003 04:57 AM
SansGrip Filters: Small explanation needed about filters AgNa Avisynth Scripting 2 02-07-2003 12:25 PM
SansGrip Filters: Trying to find the GripFIt, GripCrop and GripSize filters Bud Avisynth Scripting 4 01-19-2003 06:40 PM
SansGrip Filters: Filters/settings for animation/anime akrein62 Avisynth Scripting 2 11-24-2002 01:39 AM
SansGrip Filters: Blockbuster + Nomosmooth filters syk2c11 Avisynth Scripting 2 11-18-2002 02:29 PM

Thread Tools



 
All times are GMT -5. The time now is 01:59 PM  —  vBulletin © Jelsoft Enterprises Ltd