User:Raffriff42/sandbox

From Avisynth wiki
< User:Raffriff42(Difference between revisions)
Jump to: navigation, search
m (intro)
(testing possible Resize changes)
Line 1: Line 1:
Template test; variant of [[:Template:Par2b]];
+
= [[Resize]] =
 +
Rescales the input video frames to an arbitrary new resolution. If you supply the optional source arguments, the result is the same as if you had applied [[Crop]] with those arguments to the clip before resizing.
 +
__TOC__
  
Rationale: see [[Talk:ColorYUV]]
+
== General information ==
 +
<div {{BoxWidthIndent|62|0}} >
 +
<!--
 +
* You can use offsets (as in [[Crop]]) for all resizers, using
  
----
+
i.e.<br>
== Syntax and Parameters ==
+
'''GaussResize'''(clip ''clip'', int ''target_width'', int ''target_height'', float ''src_left'', float ''src_top'', float -''src_right'', float -''src_bottom'')
{{Template:FuncDef|ColorYUV(clip [, float ''gain_y''] [, float ''off_y''] [, float ''gamma_y''] [, float ''cont_y''] [, float ''gain_u''] [, float ''off_u''] [, float ''gamma_u''] [, float ''cont_u''] [, float ''gain_v''] [, float ''off_v''] [, float ''gamma_v''] [, float ''cont_v''] [, string ''levels''] [, string ''opt''] [, boolean ''showyuv''] [, boolean ''analyze''] [, boolean ''autowhite''] [, boolean ''autogain''] [, boolean ''conditional''])}}
+
-->
<br>
+
* For all resizers you can use an expanded syntax which crops before resizing. The same operations are performed as if you put a [[Crop]] before the Resize.<br>
<br>
+
<div {{ListItemContinue}} >
:{{Par2b| |clip| |}}
+
Note the edge semantics are slightly different. [[Crop]] gives a hard absolute boundary, and the Resizer filter lobes can extend into the cropped region &ndash; but not beyond the physical edge of the image.
::Input clip
+
<br>
+
:{{Par2b|gain_y|float|0}}
+
:{{Par2b|gain_u|float|0}}
+
:{{Par2b|gain_v|float|0}}
+
::A multiplier for the value which for positive values stretches the signal up from the bottom and for negative values it shrinks the signal up from the bottom. When ''gain_X'' is set to -128, all values are multiplied by 0.5. When ''gain_X'' is set to 0, it preserves the values as they are. When ''gain_X'' is 256, all values are multiplied by 2 (twice as bright). When ''gain_X'' is set to 512 all values are multiplied by 3. Thus when ''gain_X'' = k*256 for some value ''k'' then ''Y'' becomes ''(k+1)*Y'' (idem for the chroma). ''gain_X'' is valid down to -256, where the signal is set to 0.
+
::*Although it is possible, it doesn't make sense to apply this setting to the chroma of the signal.
+
::*In order to confuse you, in the filter [[Tweak]] this setting is called ''contrast''.
+
<br>
+
:{{Par2b|off_y|float|0}}
+
:{{Par2b|off_u|float|0}}
+
:{{Par2b|off_v|float|0}}
+
::Adds an offset (a value) to the luma or chroma values. An ''off_X'' of 16 will add 16 to all pixel values.  An ''off_X'' of -32 will subtract 32 from all pixel values.
+
<br>
+
:{{Par2b|gamma_y|float|0}}
+
:{{Par2b|gamma_u|float|0}}
+
:{{Par2b|gamma_v|float|0}}
+
::Adjusts gamma of the specified channel as X^(1/g) where g=(''gamma_X''+256)/256. When ''gamma_X'' is set to 0, it applies a gamma of 1.0. When ''gamma_X'' is set to 256, it applies a gamma of 2.0. ''gamma_X'' is valid down to -256, where a minimal gamma of 0.01 is applied.
+
::*'''Note:''' gamma for chroma is not implemented (gamma_u and gamma_v are dummy parameters).
+
<br>
+
:{{Par2b|cont_y|float|0}}
+
:{{Par2b|cont_u|float|0}}
+
:{{Par2b|cont_v|float|0}}
+
::Like ''gain_X'', a multiplier for the value, but for positive values ''cont_X'' stretches the signal out from the center and for negative values it shrinks the signal trowards the center. This is most useful for the chroma components, where it translates to saturation. When ''cont_X'' is set to -128, all values (taken from the center) are multiplied by 0.5. When ''cont_X'' is set to 0, it preserves the values as they are. When ''cont_X'' is set to 256, all values (taken from the center) are multiplied by 2 (for Y, twice as much contrast; for U and V, twice as saturated). When ''cont_X'' is set to 512, all values (taken from the center) are multiplied by 3. Thus when ''cont_X'' = (k-1)*256'' for some value ''k '' (and zero gain) then ''U'' becomes ''128 + k*(U-128)'' (and V likewise). ''cont_X'' is valid down to -256, where the signal is set to 128.
+
::*Although it is possible, it doesn't make sense to apply this setting to the luma of the signal.
+
<br>
+
:{{Par2b|levels|string|""}}
+
::Can be set to either "TV->PC" or "PC->TV". This will perform a range conversion. Normally YUV values are not mapped from 0 to 255 (PC range), but a limited range (TV range). This performs conversion between the two formats. If no parameter is specified, no conversion will be made (default operation).
+
<br>
+
:{{Par2b|opt|string|""}}
+
::Can be either "coring" or "" (nothing, default setting). Specifying "coring" will clip your YUV values to the valid TV-ranges. Otherwise "invalid results" will be accepted.
+
<br>
+
:{{Par2b|showYUV|bool|false}}
+
::If ''true, ''this option will overwrite your image with a new 448x448 image showing all chroma values along the two axes. This can be useful if you need to adjust the color of your image, but need to know how the colors are arranged. At the topleft of the image, the chroma values are '16'. At the right side of the image, U is at maximum.  At the bottom of the screen V is at its maximum.  In the middle both chroma is 128 (or grey). See example image [[#Examples:|below]].
+
<br>
+
:{{Par2b|analyze|bool|false}}
+
::If ''true, ''this option will print out color statistics on the screen. There are maximum and minimum values for all channels. There is an average for all channels. There is a "loose maximum" and "loose minimum". The "loose" values are made to filter out very bright or very dark noise creating an artificially low or high minimum / maximum.
+
<br>
+
:{{Par2b|autowhite|bool|false}}
+
::If ''true, ''this option will use the information from the analyzer, and attempt to center the color offsets. If you have recorded some material, where the colors are shifted toward one color, this filter may help. But be careful - it isn't very intelligent - if your material is a clear blue sky, autowhite will make it completely grey! If you add "off_u" or "off_v" parameters at the same time as autowhite, they will not be used!
+
<br>
+
:{{Par2b|autogain|bool|false}}
+
::If ''true, ''this option will use the information from the analyzer, and attempt to create as good contrast as possible. That means, it will scale up the ''Y ''(luma) values to match the minimum and maximum values. This will make it act like an "autogain" setting on cameras, amplifying dark scenes very much, while leaving scenes with good contrast alone. Some places this is also refered to as "autolevels".
+
<br>
+
:{{Par2b|conditional|bool|false}}
+
::If ''false, ''this option will ignore any given conditional variables. See the [[#Conditional_Variables|Conditional Variables]] section for an overview of the conditional variables and their use with ColorYUV.
+
  
==Parameter Scaling==
+
Use Crop to remove any hard borders or VHS head switching noise; using the Resizer cropping may propagate the noise into the adjacent output pixels. Use the Resizer cropping to maintain accurate edge rendering when excising a part of a complete image.
 +
 
 +
Note the source cropping parameters are all floating point. This allows any resizer to be used as a sub-pixel shifter. [http://forum.doom9.org/showpost.php?p=938102&postcount=2]
 +
</div>
 +
 
 +
* AviSynth has completely separate vertical and horizontal resizers. If input is the same as output on one axis, that resizer will be skipped. The resizer with the smallest downscale ratio is called first. This is done to preserve maximum quality, so the second resizer has the best possible picture to work with. Data storing will have an impact on what [[Modulo|mods]] ''should'' be used for sizes when resizing and cropping; see the [[Crop]] page.
 +
</div>
 +
 
 +
 
 +
== Examples ==
 +
* Cropping:
 +
<div {{BoxWidthIndent|42|3}} >
 +
Crop(10, 10, 200, 300).BilinearResize(100, 150)
 +
#... CL  CT  CW  CH                  RW  RH
 +
</div>
 +
<div {{ListItemContinue}} >
 +
which is nearly the same as:
 +
</div>
 +
<div {{BoxWidthIndent|42|3}} >
 +
BilinearResize(100, 150, 10, 10, 200, 300)
 +
#...            RW  RH  CL  CT  CW  CH
 +
#("CL"=crop left" etc, "RW"="resize width" etc)
 +
</div>
 +
 
 +
* Load a video file and resize it to 240x180 (from whatever it was before)
 +
<div {{BoxWidthIndent|42|3}} >
 +
AviSource("video.avi").BilinearResize(240,180)
 +
</div>
 +
 
 +
* Load a 720x480 ([[Wikipedia:Rec._601|Rec. 601]]) video and resize it to 352x240 ([[Wikipedia:Video_CD|VCD]]), preserving the correct aspect ratio
 +
<div {{BoxWidthIndent|42|3}} >
 +
AviSource("dv.avi").BilinearResize(352, 240, 8, 0, 704, 480)
 +
</div>
 +
<div {{ListItemContinue}} >
 +
which is the same as:
 +
</div>
 +
<div {{BoxWidthIndent|42|3}} >
 +
AviSource("dv.avi").BilinearResize(352, 240, 8, 0, -8, -0)
 +
</div>
 +
 
 +
* Extract the upper-right quadrant of a 320x240 video and zoom it to fill the whole frame
 +
<div {{BoxWidthIndent|42|3}} >
 +
BilinearResize(320, 240, 160, 0, 160, 120)
 +
#...            RW  RH  CL  CT  CW  CH
 +
#("CL"=crop left" etc, "RW"="resize width" etc)
 +
</div>
 +
 
 +
 
 +
== BilinearResize ==
 +
<div {{BoxWidthIndent|62|0}} >
 +
{{Func2Def
 +
|BicubicResize(clip ''clip'', int ''target_width'', int ''target_height'' [, float ''b'', float ''c'' ] )
 +
|BicubicResize(clip ''clip'', int ''target_width'', int ''target_height'' [, float ''b'', float ''c'', <br>
 +
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;float ''src_left'', float ''src_top'', float ''src_width'', float ''src_height'' ] )
 +
}}
 +
 
 +
BilinearResize uses standard bilinear filtering and is almost identical to VirtualDub's "precise bilinear" resizing option. It's only "almost" because VirtualDub's filter seems to get the scaling factor slightly wrong, with the result that pixels at the top and right of the image get either clipped or duplicated. (This error is noticeable when expanding the frame size by a factor or two or more, but insignificant otherwise, so I wouldn't worry too much about it.)
 +
 
 +
(''Does anyone know the origin of this statement? The premise is not correct, as with standard mappings you must have duplicated or mirrored pixels around the border when enlarging. Looking at the sources and comparing outputs, VirtualDub 1.6 and Avisynth 2.5 appear to generate the same mappings. I wonder if this discrepancy has already been resolved. ? Avery'')
 +
</div>
 +
 
 +
 
 +
== BicubicResize ==
 +
<div {{BoxWidthIndent|62|0}} >
 +
{{Func2Def
 +
|BilinearResize(clip ''clip'', int ''target_width'', int ''target_height'' )
 +
|BilinearResize(clip ''clip'', int ''target_width'', int ''target_height'' [, <br>
 +
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;float ''src_left'', float ''src_top'', float ''src_width'', float ''src_height'' ] )
 +
}}
 +
 
 +
'''BicubicResize''' is similar to BilinearResize, except that instead of a linear filtering function it uses the Mitchell-Netravali two-part cubic. The parameters b and c can be used to adjust the properties of the cubic, they are sometimes referred to as "blurring" and "ringing" respectively.
 +
 
 +
With b = 0 and c = 0.75 the filter is exactly the same as VirtualDub's "precise bicubic" and the results are identical except for the VirtualDub scaling problem mentioned above. The default is b = 1./3. and c = 1./3., which were the values recommended by Mitchell and Netravali as yielding the most visually pleasing results in subjective tests of human beings. Larger values of b and c can produce interesting op-art effects--for example, try b = 0 and c = -5.
 +
 
 +
If you are magnifying your video, you will get much better-looking results with BicubicResize than with BilinearResize. However, if you are shrinking it, you are probably just as well off, or even better off, with BilinearResize. Although VirtualDub's bicubic filter does produce better-looking images than its bilinear filter, this is mainly because the bicubic filter sharpens the image, not because it samples it better. Sharp images are nice to look at--until you try to compress them, at which point they turn nasty on you very quickly. The BicubicResize default doesn't sharpen nearly as much as VirtualDub's bicubic, but it still sharpens more than the bilinear. If you plan to encode your video at a low bitrate, I wouldn't be at all surprised if BilinearResize yields better quality.
 +
 
 +
You have to set "b + 2 * c = 1" for the numerically most accurate filter. This gives for b = 0 the maximum value for c = 0.5, which is the Catmull-Rom spline and a good suggestion for sharpness.
 +
 
 +
From c>0.6 the filter starts to "ring". You won't get real sharpness, what you'll get is crispening like on a TV set.
 +
Negative values for b (although allowed) give undesirable results, so use b = 0 for values of c > 0.5.
 +
</div>
 +
 
 +
 
 +
== BlackmanResize ==
 +
<div {{BoxWidthIndent|62|0}} >
 +
{{Func2Def
 +
|BlackmanResize(clip ''clip'', int ''target_width'', int ''target_height'' )
 +
|BlackmanResize(clip ''clip'', int ''target_width'', int ''target_height'' [, <br>
 +
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;float ''src_left'', float ''src_top'', float ''src_width'', float ''src_height'', int ''taps'' ] )
 +
}}
 +
 
 +
'''BlackmanResize''' is a modification of LanczosResize that has better control of ringing artifacts for high numbers of taps. See LanczosResize for an explanation of the taps argument (default: taps=4, 1<=taps<=100).
 +
</div>
 +
 
 +
 
 +
== GaussResize ==
 +
<div {{BoxWidthIndent|62|0}} >
 +
{{Func2Def
 +
|GaussResize(clip ''clip'', int ''target_width'', int ''target_height'' )
 +
|GaussResize(clip ''clip'', int ''target_width'', int ''target_height'' [, <br>
 +
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;float ''src_left'', float ''src_top'', float ''src_width'', float ''src_height'', float ''p'' ] )
 +
}}
 +
 
 +
'''GaussResize''' uses a gaussian resizer with adjustable sharpness parameter ''p'' (default 30). ''p'' has a range from about 1 to 100, with 1 being very blurry and 100 being very sharp. GaussResize has similar speed as Lanczos4Resize. (added in v2.56)
 +
</div>
 +
 
 +
 
 +
== LanczosResize ==
 +
<div {{BoxWidthIndent|62|0}} >
 +
{{Func2Def
 +
|LanczosResize(clip ''clip'', int ''target_width'', int ''target_height'' )
 +
|LanczosResize(clip ''clip'', int ''target_width'', int ''target_height'' [, <br>
 +
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;float ''src_left'', float ''src_top'', float ''src_width'', float ''src_height'', int ''taps'' ] )
 +
}}
 +
 
 +
{{Func2Def
 +
|Lanczos4Resize(clip ''clip'', int ''target_width'', int ''target_height'' )
 +
|Lanczos4Resize(clip ''clip'', int ''target_width'', int ''target_height'' [, <br>
 +
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;float ''src_left'', float ''src_top'', float ''src_width'', float ''src_height'' ] )
 +
}}
 +
 
 +
'''LanczosResize''' is an alternative to BicubicResize with high values of c about 0.6 ... 0.75 which produces quite strong sharpening. It usually offers better quality (fewer artifacts) and a sharp image.
 +
 
 +
Lanczos was created for AviSynth because it retained so much detail, more so even than BicubicResize(x,y,0,0.75). As you might know, the more detail a frame has, the more difficult it is to compress it. This means that Lanczos is NOT suited for low bitrate video, the various Bicubic flavours are much better for this. If however you have enough bitrate then using Lanczos will give you a better picture, but in general I do not recommend using it for 1 CD rips because the bitrate is usually too low (there are exceptions of course).
 +
 
 +
The input parameter taps (default 3, 1<=taps<=100) is equal to the number of lobes (ignoring mirroring around the origin).
 +
 
 +
 
 +
'''Lanczos4Resize''' is a short hand for LanczosResize(taps=4). It produces sharper images than LanczosResize with the default taps=3, especially useful when upsizing a clip.
 +
 
 +
''Warning: the input argument named taps should really be lobes. When discussing resizers, taps has a different meaning, as described below (the first paragraph concerns LanczosResize(taps=2)):''
 +
 
 +
"For upsampling (making the image larger), the filter is sized such that the entire equation falls across 4 input samples, making it a 4-tap filter. It doesn't matter how big the output image is going to be - it's still just 4 taps. For downsampling (making the image smaller), the equation is sized so it will fall across 4 *destination* samples, which obviously are spaced at wider intervals than the source samples. So for downsampling by a factor of 2 (making the image half as big), the filter covers 2*4=8 input samples, and thus 8 taps. For 3x downsampling, you need 3*4=12 taps, and so forth.
 +
 
 +
Thus the total number of taps you need for downsampling is the downsampling ratio times the number of lobes (thus '''T'''x downsampling and Lanczos'''k'''Resize results in T*2*k taps). And practically, one needs to round that up to the next even integer. For upsampling, it's always 2*k taps." Source: [http://www.avsforum.com/forum/26-home-theater-computers/460922-lanczos-vs-bicubic-comparison-2.html#post4760581 avsforum post] ([[lanczos lobs/taps|mirror]]).
 +
 
 +
LanczosResize(clip clip, int target_width, int target_height, int taps)
 +
</div>
 +
 
 +
 
 +
== PointResize ==
 +
<div {{BoxWidthIndent|62|0}} >
 +
{{Func2Def
 +
|PointResize(clip ''clip'', int ''target_width'', int ''target_height'' )
 +
|PointResize(clip ''clip'', int ''target_width'', int ''target_height'' [, <br>
 +
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;float ''src_left'', float ''src_top'', float ''src_width'', float ''src_height'' ] )
 +
}}
 +
 
 +
'''PointResize''' is the simplest resizer possible. It uses a Point Sampler or Nearest Neighbour algorithm, which usually results in a very blocky image. So in general this filter should only be used, if you intend to have inferior quality, or you need the clear pixel drawings. Useful for magnifying small areas for examination.
 +
</div>
 +
 
 +
 
 +
== Spline based resizers ==
 +
<div {{BoxWidthIndent|62|0}} >
 +
{{Func2Def
 +
|Spline16Resize(clip ''clip'', int ''target_width'', int ''target_height'' )
 +
|Spline16Resize(clip ''clip'', int ''target_width'', int ''target_height'' [, <br>
 +
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;float ''src_left'', float ''src_top'', float ''src_width'', float ''src_height'' ] )
 +
}}
 +
 
 +
{{Func2Def
 +
|Spline36Resize(clip ''clip'', int ''target_width'', int ''target_height'' )
 +
|Spline36Resize(clip ''clip'', int ''target_width'', int ''target_height'' [, <br>
 +
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;float ''src_left'', float ''src_top'', float ''src_width'', float ''src_height'' ] )
 +
}}
 +
 
 +
{{Func2Def
 +
|Spline64Resize(clip ''clip'', int ''target_width'', int ''target_height'' )
 +
|Spline64Resize(clip ''clip'', int ''target_width'', int ''target_height'' [, <br>
 +
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;float ''src_left'', float ''src_top'', float ''src_width'', float ''src_height'' ] )
 +
}}
 +
 
 +
'''Spline16Resize''', '''Spline36Resize''' and '''Spline64Resize''' are three Spline based resizers. They are the (cubic) spline based resizers from [http://www.all-in-one.ee/~dersch/ Panorama tools] that fit a spline through the sample points and then derives the filter kernel from the resulting blending polynomials. See [http://forum.doom9.org/showthread.php?t=147117 this thread] for the details.
 +
 
 +
The rationale for Spline is to be as sharp as possible with less ringing artifacts as LanczosResize produces. Spline16Resize uses sqrt(16)=4 sample points, Spline36Resize uses 6 sample points, etc ... The more sample points is used, the sharper your clip will get. A comparison between several resizers is given [http://web.archive.org/web/20060827184031/http://www.path.unimelb.edu.au/~dersch/interpolator/interpolator.html here].
 +
</div>
 +
 
 +
 
 +
== SincResize ==
 +
<div {{BoxWidthIndent|62|0}} >
 +
{{Func2Def
 +
|SincResize(clip ''clip'', int ''target_width'', int ''target_height'' )
 +
|SincResize(clip ''clip'', int ''target_width'', int ''target_height'' [, <br>
 +
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;float ''src_left'', float ''src_top'', float ''src_width'', float ''src_height'', int ''taps'' ] )
 +
}}
 +
 
 +
'''SincResize''' is added in v2.6 and it uses the truncated sinc function as resizer. See LanczosResize for an explanation of the taps argument (default: taps=4; 1<=taps<=20).
 +
</div>
 +
 
 +
 
 +
== External Links ==
 +
* [http://hermidownloads.craqstar.de/videoresizefiltercomparasion/ AviSynth resize filter comparison] | [http://web.archive.org/web/20130815024055/http://hermidownloads.craqstar.de/videoresizefiltercomparasion archived link]
 +
* [http://jeanbruenn.info/2011/10/30/upscaling-in-avisynth-comparison-of-resizers/ Upscaling in Avisynth – Comparison of resizers] | [http://web.archive.org/web/20140207171106/http://jeanbruenn.info/2011/10/30/upscaling-in-avisynth-comparison-of-resizers/ archived link]
 +
 
 +
 
 +
== Changelog ==
 +
. . .

Revision as of 16:38, 31 January 2016

Resize

Rescales the input video frames to an arbitrary new resolution. If you supply the optional source arguments, the result is the same as if you had applied Crop with those arguments to the clip before resizing.

Contents


General information

  • For all resizers you can use an expanded syntax which crops before resizing. The same operations are performed as if you put a Crop before the Resize.

Note the edge semantics are slightly different. Crop gives a hard absolute boundary, and the Resizer filter lobes can extend into the cropped region – but not beyond the physical edge of the image.

Use Crop to remove any hard borders or VHS head switching noise; using the Resizer cropping may propagate the noise into the adjacent output pixels. Use the Resizer cropping to maintain accurate edge rendering when excising a part of a complete image.

Note the source cropping parameters are all floating point. This allows any resizer to be used as a sub-pixel shifter. [1]

  • AviSynth has completely separate vertical and horizontal resizers. If input is the same as output on one axis, that resizer will be skipped. The resizer with the smallest downscale ratio is called first. This is done to preserve maximum quality, so the second resizer has the best possible picture to work with. Data storing will have an impact on what mods should be used for sizes when resizing and cropping; see the Crop page.


Examples

  • Cropping:
Crop(10, 10, 200, 300).BilinearResize(100, 150)
#... CL  CT  CW   CH                   RW   RH

which is nearly the same as:

BilinearResize(100, 150, 10, 10, 200, 300)
#...            RW   RH  CL  CT   CW   CH
#("CL"=crop left" etc, "RW"="resize width" etc)
  • Load a video file and resize it to 240x180 (from whatever it was before)
AviSource("video.avi").BilinearResize(240,180)
  • Load a 720x480 (Rec. 601) video and resize it to 352x240 (VCD), preserving the correct aspect ratio
AviSource("dv.avi").BilinearResize(352, 240, 8, 0, 704, 480)

which is the same as:

AviSource("dv.avi").BilinearResize(352, 240, 8, 0, -8, -0)
  • Extract the upper-right quadrant of a 320x240 video and zoom it to fill the whole frame
BilinearResize(320, 240, 160, 0, 160, 120)
#...            RW   RH   CL  CT  CW   CH
#("CL"=crop left" etc, "RW"="resize width" etc)


BilinearResize

BicubicResize(clip clip, int target_width, int target_height [, float b, float c ] )
BicubicResize(clip clip, int target_width, int target_height [, float b, float c,
     float src_left, float src_top, float src_width, float src_height ] )

BilinearResize uses standard bilinear filtering and is almost identical to VirtualDub's "precise bilinear" resizing option. It's only "almost" because VirtualDub's filter seems to get the scaling factor slightly wrong, with the result that pixels at the top and right of the image get either clipped or duplicated. (This error is noticeable when expanding the frame size by a factor or two or more, but insignificant otherwise, so I wouldn't worry too much about it.)

(Does anyone know the origin of this statement? The premise is not correct, as with standard mappings you must have duplicated or mirrored pixels around the border when enlarging. Looking at the sources and comparing outputs, VirtualDub 1.6 and Avisynth 2.5 appear to generate the same mappings. I wonder if this discrepancy has already been resolved. ? Avery)


BicubicResize

BilinearResize(clip clip, int target_width, int target_height )
BilinearResize(clip clip, int target_width, int target_height [,
     float src_left, float src_top, float src_width, float src_height ] )

BicubicResize is similar to BilinearResize, except that instead of a linear filtering function it uses the Mitchell-Netravali two-part cubic. The parameters b and c can be used to adjust the properties of the cubic, they are sometimes referred to as "blurring" and "ringing" respectively.

With b = 0 and c = 0.75 the filter is exactly the same as VirtualDub's "precise bicubic" and the results are identical except for the VirtualDub scaling problem mentioned above. The default is b = 1./3. and c = 1./3., which were the values recommended by Mitchell and Netravali as yielding the most visually pleasing results in subjective tests of human beings. Larger values of b and c can produce interesting op-art effects--for example, try b = 0 and c = -5.

If you are magnifying your video, you will get much better-looking results with BicubicResize than with BilinearResize. However, if you are shrinking it, you are probably just as well off, or even better off, with BilinearResize. Although VirtualDub's bicubic filter does produce better-looking images than its bilinear filter, this is mainly because the bicubic filter sharpens the image, not because it samples it better. Sharp images are nice to look at--until you try to compress them, at which point they turn nasty on you very quickly. The BicubicResize default doesn't sharpen nearly as much as VirtualDub's bicubic, but it still sharpens more than the bilinear. If you plan to encode your video at a low bitrate, I wouldn't be at all surprised if BilinearResize yields better quality.

You have to set "b + 2 * c = 1" for the numerically most accurate filter. This gives for b = 0 the maximum value for c = 0.5, which is the Catmull-Rom spline and a good suggestion for sharpness.

From c>0.6 the filter starts to "ring". You won't get real sharpness, what you'll get is crispening like on a TV set. Negative values for b (although allowed) give undesirable results, so use b = 0 for values of c > 0.5.


BlackmanResize

BlackmanResize(clip clip, int target_width, int target_height )
BlackmanResize(clip clip, int target_width, int target_height [,
     float src_left, float src_top, float src_width, float src_height, int taps ] )

BlackmanResize is a modification of LanczosResize that has better control of ringing artifacts for high numbers of taps. See LanczosResize for an explanation of the taps argument (default: taps=4, 1<=taps<=100).


GaussResize

GaussResize(clip clip, int target_width, int target_height )
GaussResize(clip clip, int target_width, int target_height [,
     float src_left, float src_top, float src_width, float src_height, float p ] )

GaussResize uses a gaussian resizer with adjustable sharpness parameter p (default 30). p has a range from about 1 to 100, with 1 being very blurry and 100 being very sharp. GaussResize has similar speed as Lanczos4Resize. (added in v2.56)


LanczosResize

LanczosResize(clip clip, int target_width, int target_height )
LanczosResize(clip clip, int target_width, int target_height [,
     float src_left, float src_top, float src_width, float src_height, int taps ] )

Lanczos4Resize(clip clip, int target_width, int target_height )
Lanczos4Resize(clip clip, int target_width, int target_height [,
     float src_left, float src_top, float src_width, float src_height ] )

LanczosResize is an alternative to BicubicResize with high values of c about 0.6 ... 0.75 which produces quite strong sharpening. It usually offers better quality (fewer artifacts) and a sharp image.

Lanczos was created for AviSynth because it retained so much detail, more so even than BicubicResize(x,y,0,0.75). As you might know, the more detail a frame has, the more difficult it is to compress it. This means that Lanczos is NOT suited for low bitrate video, the various Bicubic flavours are much better for this. If however you have enough bitrate then using Lanczos will give you a better picture, but in general I do not recommend using it for 1 CD rips because the bitrate is usually too low (there are exceptions of course).

The input parameter taps (default 3, 1<=taps<=100) is equal to the number of lobes (ignoring mirroring around the origin).


Lanczos4Resize is a short hand for LanczosResize(taps=4). It produces sharper images than LanczosResize with the default taps=3, especially useful when upsizing a clip.

Warning: the input argument named taps should really be lobes. When discussing resizers, taps has a different meaning, as described below (the first paragraph concerns LanczosResize(taps=2)):

"For upsampling (making the image larger), the filter is sized such that the entire equation falls across 4 input samples, making it a 4-tap filter. It doesn't matter how big the output image is going to be - it's still just 4 taps. For downsampling (making the image smaller), the equation is sized so it will fall across 4 *destination* samples, which obviously are spaced at wider intervals than the source samples. So for downsampling by a factor of 2 (making the image half as big), the filter covers 2*4=8 input samples, and thus 8 taps. For 3x downsampling, you need 3*4=12 taps, and so forth.

Thus the total number of taps you need for downsampling is the downsampling ratio times the number of lobes (thus Tx downsampling and LanczoskResize results in T*2*k taps). And practically, one needs to round that up to the next even integer. For upsampling, it's always 2*k taps." Source: avsforum post (mirror).

LanczosResize(clip clip, int target_width, int target_height, int taps)


PointResize

PointResize(clip clip, int target_width, int target_height )
PointResize(clip clip, int target_width, int target_height [,
     float src_left, float src_top, float src_width, float src_height ] )

PointResize is the simplest resizer possible. It uses a Point Sampler or Nearest Neighbour algorithm, which usually results in a very blocky image. So in general this filter should only be used, if you intend to have inferior quality, or you need the clear pixel drawings. Useful for magnifying small areas for examination.


Spline based resizers

Spline16Resize(clip clip, int target_width, int target_height )
Spline16Resize(clip clip, int target_width, int target_height [,
     float src_left, float src_top, float src_width, float src_height ] )

Spline36Resize(clip clip, int target_width, int target_height )
Spline36Resize(clip clip, int target_width, int target_height [,
     float src_left, float src_top, float src_width, float src_height ] )

Spline64Resize(clip clip, int target_width, int target_height )
Spline64Resize(clip clip, int target_width, int target_height [,
     float src_left, float src_top, float src_width, float src_height ] )

Spline16Resize, Spline36Resize and Spline64Resize are three Spline based resizers. They are the (cubic) spline based resizers from Panorama tools that fit a spline through the sample points and then derives the filter kernel from the resulting blending polynomials. See this thread for the details.

The rationale for Spline is to be as sharp as possible with less ringing artifacts as LanczosResize produces. Spline16Resize uses sqrt(16)=4 sample points, Spline36Resize uses 6 sample points, etc ... The more sample points is used, the sharper your clip will get. A comparison between several resizers is given here.


SincResize

SincResize(clip clip, int target_width, int target_height )
SincResize(clip clip, int target_width, int target_height [,
     float src_left, float src_top, float src_width, float src_height, int taps ] )

SincResize is added in v2.6 and it uses the truncated sinc function as resizer. See LanczosResize for an explanation of the taps argument (default: taps=4; 1<=taps<=20).


External Links


Changelog

. . .

Personal tools