Nnedi3/nnedi3 rpow2

From Avisynth wiki
(Difference between revisions)
Jump to: navigation, search
m (category)
m (reformat)
Line 3: Line 3:
 
'''Back to [[nnedi3#Filters|nnedi3]] ←'''
 
'''Back to [[nnedi3#Filters|nnedi3]] ←'''
 
--------------------------------------------------
 
--------------------------------------------------
<br>
 
 
<br>
 
<br>
 
== Description ==
 
== Description ==
:nnedi3_rpow2 is for enlarging images by powers of 2.
+
nnedi3_rpow2 is for enlarging images by powers of 2.<br>
 
<br>
 
<br>
 
 
== [[Script variables|Syntax and Parameters]] ==
 
== [[Script variables|Syntax and Parameters]] ==
 
:{{Template:FuncDef|nnedi3_rpow2 (''clip'', ''int'' rfactor, ''int'' "nsize", ''int'' "nns", ''int'' "qual", ''int'' "etype", ''int'' "pscrn", ''string'' "cshift", ''int'' "fwidth", ''int'' "fheight", ''float'' "ep0", ''float'' "ep1",  ''int'' "threads", ''int'' "opt", ''int'' "fapprox")}}
 
:{{Template:FuncDef|nnedi3_rpow2 (''clip'', ''int'' rfactor, ''int'' "nsize", ''int'' "nns", ''int'' "qual", ''int'' "etype", ''int'' "pscrn", ''string'' "cshift", ''int'' "fwidth", ''int'' "fheight", ''float'' "ep0", ''float'' "ep1",  ''int'' "threads", ''int'' "opt", ''int'' "fapprox")}}
 +
<br>
 +
::{{Par2| |clip| }}
 +
:::Input clip.
 
<br>
 
<br>
 
::{{Par2|rfactor|int| }}
 
::{{Par2|rfactor|int| }}
:::Image enlargement factor. Must be a power of 2 in the range [2,1024].
+
:::Image enlargement factor. Must be a power of 2 in the range [2 to 1024].
 
<br>
 
<br>
 
::{{Par2|nsize|int|0}}
 
::{{Par2|nsize|int|0}}
:::Sets the size of the local neighborhood around each pixel that is used by the predictor
+
:::Sets the size of the local neighborhood around each pixel that is used by the predictor neural network.
:::neural network. Possible settings (x_diameter x y_diameter):
+
:::Possible settings (x_diameter x y_diameter):
  
 
::::*0 -  8x6
 
::::*0 -  8x6
Line 27: Line 28:
 
::::*6 -  32x4
 
::::*6 -  32x4
  
:::For image enlargement it is recommended to use 0 or 4. Larger y_diameter settings
+
:::For image enlargement it is recommended to use 0 or 4. Larger y_diameter settings will result in sharper output.  
:::will result in sharper output. For deinterlacing larger x_diameter settings will
+
:::For deinterlacing larger x_diameter settings will allow connecting lines of smaller slope. However, what setting to use really depends on the amount of aliasing (lost information) in the source.
:::allow connecting lines of smaller slope. However, what setting to use really
+
:::If the source was heavily low-pass filtered before interlacing then aliasing will be low and a large x_diameter setting wont be needed, and vice versa.
:::depends on the amount of aliasing (lost information) in the source. If the source was
+
:::heavily low-pass filtered before interlacing then aliasing will be low and a large
+
:::x_diameter setting wont be needed, and vice versa.
+
 
<br>
 
<br>
 
::{{Par2|nns|int|3}}
 
::{{Par2|nns|int|3}}
:::Sets the number of neurons in the predictor neural network. Possible settings are
+
:::Sets the number of neurons in the predictor neural network. Possible settings are 0, 1, 2, 3, and 4. 0 is fastest. 4 is slowest, but should give the best quality.  
:::0, 1, 2, 3, and 4. 0 is fastest. 4 is slowest, but should give the best quality. This
+
:::This is a quality vs speed option; however, differences are usually small. The difference in speed will become larger as '{{Template:FuncDef|qual}}' is increased.
:::is a quality vs speed option; however, differences are usually small. The difference
+
:::in speed will become larger as '{{Template:FuncDef|qual}}' is increased.
+
  
 
::::*0 - 16
 
::::*0 - 16
Line 47: Line 43:
 
<br>
 
<br>
 
::{{Par2|qual|int|1}}
 
::{{Par2|qual|int|1}}
:::Controls the number of different neural network predictions that are blended together
+
:::Controls the number of different neural network predictions that are blended together to compute the final output value.  
:::to compute the final output value. Each neural network was trained on a different set
+
:::Each neural network was trained on a different set of training data. Blending the results of these different networks improves generalization to unseen data.
:::of training data. Blending the results of these different networks improves generalization
+
:::Possible values are 1 or 2. Essentially this is a quality vs speed option. Larger values will result in more processing time, but should give better results.  
:::to unseen data. Possible values are 1 or 2. Essentially this is a quality vs speed
+
:::However, the difference is usually pretty small. I would recommend using {{Template:FuncDef|qual}}>1 for things like single image enlargement.
:::option. Larger values will result in more processing time, but should give better results.
+
:::However, the difference is usually pretty small. I would recommend using {{Template:FuncDef|qual}}>1 for
+
:::things like single image enlargement.
+
 
<br>
 
<br>
 
::{{Par2|etype|int|0}}
 
::{{Par2|etype|int|0}}
Line 62: Line 55:
 
<br>
 
<br>
 
::{{Par2|pscrn|int|2}}
 
::{{Par2|pscrn|int|2}}
:::Controls whether or not the prescreener neural network is used to decide which pixels
+
:::Controls whether or not the prescreener neural network is used to decide which pixels should be processed by the predictor neural network and which can be handled by simple cubic interpolation.
:::should be processed by the predictor neural network and which can be handled by simple
+
:::The prescreener is trained to know whether cubic interpolation will be sufficient for a pixel or whether it should be predicted by the predictor nn. The computational complexity of the prescreener nn is much less than that of the predictor nn.
:::cubic interpolation. The prescreener is trained to know whether cubic interpolation
+
:::Since most pixels can be handled by cubic interpolation, using the prescreener generally results in much faster processing. The prescreener is pretty accurate, so the difference between using it and not using it is almost always unnoticeable.
:::will be sufficient for a pixel or whether it should be predicted by the predictor nn.
+
:::The computational complexity of the prescreener nn is much less than that of the predictor
+
:::nn. Since most pixels can be handled by cubic interpolation, using the prescreener
+
:::generally results in much faster processing. The prescreener is pretty accurate, so the
+
:::difference between using it and not using it is almost always unnoticeable.
+
  
::::Version 0.9.3 adds a new, faster prescreener with three selectable 'levels', which
+
:::Version 0.9.3 adds a new, faster prescreener with three selectable 'levels', which trade off the number of pixels detected as only requiring cubic interpolation versus incurred error.
::::trade off the number of pixels detected as only requiring cubic interpolation versus
+
:::Therefore, pscrn is now an integer with possible values of 0, 1, 2, 3, and 4.
::::incurred error. Therefore, pscrn is now an integer with possible values of 0, 1, 2, 3,
+
::::and 4.
+
  
:::::*0 - no prescreening (same as false in prior versions)
+
::::*0 - no prescreening (same as false in prior versions)
:::::*1 - original prescreener (same as true in prior versions)
+
::::*1 - original prescreener (same as true in prior versions)
:::::*2 - new prescreener level 0
+
::::*2 - new prescreener level 0
:::::*3 - new prescreener level 1
+
::::*3 - new prescreener level 1
:::::*4 - new prescreener level 2
+
::::*4 - new prescreener level 2
  
:::: *Higher levels for the new prescreener result in cubic interpolation being
+
:::Higher levels for the new prescreener result in cubic interpolation being used on fewer pixels (so are slower, but incur less error). However, the difference is pretty much unnoticeable.
::::used on fewer pixels (so are slower, but incur less error). However, the
+
:::Level 2 is closest to the original prescreener in terms of incurred error, but is much faster.
::::difference is pretty much unnoticable. Level 2 is closest to the original
+
::::prescreener in terms of incurred error, but is much faster.
+
 
<br>
 
<br>
 
::{{Par2|cshift|string| }}
 
::{{Par2|cshift|string| }}
:::Sets the resizer used for correcting the image center shift that nnedi3_rpow2
+
:::Sets the resizer used for correcting the image center shift that nnedi3_rpow2 introduces. This can be any of Avisynth's [[Resize|internal resizers]], such as "[[Spline36Resize]]", "[[LanczosResize]]", etc...  
:::introduces. This can be any of Avisynth's [[Resize|internal resizers]], such as "spline36resize",
+
:::If not specified the shift is not corrected. The correction is accomplished by using the subpixel cropping capability of Avisynth's internal resizers.
:::"lanczosresize", etc... If not specified the shift is not corrected. The correction
+
:::is accomplished by using the subpixel cropping capability of Avisynth's internal
+
:::resizers.
+
 
<br>
 
<br>
 
::{{Par2|fwidth|int| }}
 
::{{Par2|fwidth|int| }}
 
::{{Par2|fheight|int| }}
 
::{{Par2|fheight|int| }}
:::If correcting the image center shift by using the '{{Template:FuncDef|cshift}}' parameter, {{Template:FuncDef|fwidth}}/{{Template:FuncDef|fheight}}
+
:::If correcting the image center shift by using the '{{Template:FuncDef|cshift}}' parameter, {{Template:FuncDef|fwidth}}/{{Template:FuncDef|fheight}} allow you to set a new output resolution.  
:::allow you to set a new output resolution. First, the image is enlarged by '{{Template:FuncDef|rfactor}}'
+
:::First, the image is enlarged by '{{Template:FuncDef|rfactor}}' using nnedi3. Once that is completed the image center shift is corrected, and the image is resampled to {{Template:FuncDef|fwidth}} x {{Template:FuncDef|fheight}} resolution.  
:::using nnedi3. Once that is completed the image center shift is corrected, and the
+
:::The shifting and resampling happen in one call using the internal Avisynth resizer you specify via the '{{Template:FuncDef|cshift}}' string. If {{Template:FuncDef|fwidth}}/{{Template:FuncDef|fheight}} are not specified, then they are set equal to {{Template:FuncDef|rfactor}}*width and {{Template:FuncDef|rfactor}}*height respectively (in other words they do nothing).
:::image is resampled to {{Template:FuncDef|fwidth}} x {{Template:FuncDef|fheight}} resolution. The shifting and resampling
+
:::happen in one call using the internal Avisynth resizer you specify via the '{{Template:FuncDef|cshift}}'
+
:::string. If {{Template:FuncDef|fwidth}}/{{Template:FuncDef|fheight}} are not specified, then they are set equal to {{Template:FuncDef|rfactor}}*width
+
:::and {{Template:FuncDef|rfactor}}*height respectively (in other words they do nothing).
+
 
<br>
 
<br>
 
::{{Par2|ep0|float| }}
 
::{{Par2|ep0|float| }}
 
::{{Par2|ep1|float| }}
 
::{{Par2|ep1|float| }}
:::Some Avisynth resizers take optional arguments, such as 'taps' for lanczosresize or
+
:::Some Avisynth resizers take optional arguments, such as 'taps' for [[LanczosResize]] or 'p' for [[GaussResize]]. ep0/ep1 allow you to pass values for these optional arguments when using the 'cshift' parameter.
:::'p' for gaussresize. ep0/ep1 allow you to pass values for these optional arguments
+
:::If the resizer only takes one optional argument then ep0 is used. If the argument that the resizer takes is not a float value, then ep0 gets rounded to an integer.  
:::when using the 'cshift' parameter. If the resizer only takes one optional argument
+
:::If the resizer takes two optional arguments, then ep0 corresponds to the first one, and ep1 corresponds to the second. The only resizer that takes more than one optional argument is [[BicubicResize]](), which takes 'b' and 'c'. So ep0 = b, and ep1 = c.
:::then ep0 is used. If the argument that the resizer takes is not a float value,
+
:::If ep0/ep1 are not set then the default value for the optional argument(s) of the resizer is used.
:::then ep0 gets rounded to an integer. If the resizer takes two optional arguments,
+
:::then ep0 corresponds to the first one, and ep1 corresponds to the second. The only
+
:::resizer that takes more than one optional argument is bicubicresize(), which takes
+
:::'b' and 'c'. So ep0 = b, and ep1 = c. If ep0/ep1 are not set then the default value
+
:::for the optional argument(s) of the resizer is used.
+
 
<br>
 
<br>
 
::{{Par2|threads|int|0}}
 
::{{Par2|threads|int|0}}
:::Controls how many threads will be used for processing. If set to 0, threads will
+
:::Controls how many threads will be used for processing. If set to 0, threads will be set equal to the number of detected processors.
:::be set equal to the number of detected processors.
+
 
<br>
 
<br>
 
::{{Par2|opt|int|0}}
 
::{{Par2|opt|int|0}}
:::Sets which cpu optimizations to use. Possible settings:
+
:::Sets which CPU optimizations to use. Possible settings:
  
 
::::*0 = auto detect
 
::::*0 = auto detect
::::*1 = use c
+
::::*1 = use C
::::*2 = use sse2
+
::::*2 = use [[SSE2]]
 
<br>
 
<br>
 
::{{Par2|fapprox|int|15}}
 
::{{Par2|fapprox|int|15}}
:::Bitmask which enables or disables certain speed-ups. Value range is [0,15].
+
:::Bitmask which enables or disables certain speed-ups. Value range is [0 to 15].
 
:::Mainly for debugging.
 
:::Mainly for debugging.
  
Line 142: Line 113:
 
  nnedi3_rpow2(rfactor=4, nsize=0, nns=3, qual=1, etype=0, pscrn=2, threads=0, opt=0, fapprox=15)
 
  nnedi3_rpow2(rfactor=4, nsize=0, nns=3, qual=1, etype=0, pscrn=2, threads=0, opt=0, fapprox=15)
 
<br>
 
<br>
*Enlarge image by 4x, don't correct for center shift.
+
*Enlarge image by 4x but do not correct for center shift.
 
  [[AviSource]]("Blah.avi")
 
  [[AviSource]]("Blah.avi")
 
  nnedi3_rpow2(rfactor=4)
 
  nnedi3_rpow2(rfactor=4)
 
<br>
 
<br>
*Enlarge image by 2x, correct for center shift using [[Resize#Spline_based_resizers|Spline36Resize]].
+
*Enlarge image by 2x and correct for center shift using [[Resize#Spline_based_resizers|Spline36Resize]].
 
  [[AviSource]]("Blah.avi")
 
  [[AviSource]]("Blah.avi")
 
  nnedi3_rpow2(rfactor=2,cshift="Spline36Resize")
 
  nnedi3_rpow2(rfactor=2,cshift="Spline36Resize")
Line 153: Line 124:
 
  [[AviSource]]("Blah.avi")
 
  [[AviSource]]("Blah.avi")
 
  nnedi3_rpow2(rfactor=8,cshift="LanczosResize",fwidth=width*7,fheight=height*7,ep0=5)
 
  nnedi3_rpow2(rfactor=8,cshift="LanczosResize",fwidth=width*7,fheight=height*7,ep0=5)
<br>
 
 
<br>
 
<br>
 
--------------------------------------------------------
 
--------------------------------------------------------
 
'''Back to [[nnedi3#Filters|nnedi3]] &larr;'''
 
'''Back to [[nnedi3#Filters|nnedi3]] &larr;'''

Revision as of 06:27, 17 September 2014

Back to nnedi3



Description

nnedi3_rpow2 is for enlarging images by powers of 2.

Syntax and Parameters

nnedi3_rpow2 (clip, int rfactor, int "nsize", int "nns", int "qual", int "etype", int "pscrn", string "cshift", int "fwidth", int "fheight", float "ep0", float "ep1", int "threads", int "opt", int "fapprox")


clip   =
Input clip.


int  rfactor =
Image enlargement factor. Must be a power of 2 in the range [2 to 1024].


int  nsize = 0
Sets the size of the local neighborhood around each pixel that is used by the predictor neural network.
Possible settings (x_diameter x y_diameter):
  • 0 - 8x6
  • 1 - 16x6
  • 2 - 32x6
  • 3 - 48x6
  • 4 - 8x4
  • 5 - 16x4
  • 6 - 32x4
For image enlargement it is recommended to use 0 or 4. Larger y_diameter settings will result in sharper output.
For deinterlacing larger x_diameter settings will allow connecting lines of smaller slope. However, what setting to use really depends on the amount of aliasing (lost information) in the source.
If the source was heavily low-pass filtered before interlacing then aliasing will be low and a large x_diameter setting wont be needed, and vice versa.


int  nns = 3
Sets the number of neurons in the predictor neural network. Possible settings are 0, 1, 2, 3, and 4. 0 is fastest. 4 is slowest, but should give the best quality.
This is a quality vs speed option; however, differences are usually small. The difference in speed will become larger as 'qual' is increased.
  • 0 - 16
  • 1 - 32
  • 2 - 64
  • 3 - 128
  • 4 - 256


int  qual = 1
Controls the number of different neural network predictions that are blended together to compute the final output value.
Each neural network was trained on a different set of training data. Blending the results of these different networks improves generalization to unseen data.
Possible values are 1 or 2. Essentially this is a quality vs speed option. Larger values will result in more processing time, but should give better results.
However, the difference is usually pretty small. I would recommend using qual>1 for things like single image enlargement.


int  etype = 0
Controls which set of weights to use in the predictor nn. Possible settings:
  • 0 - weights trained to minimize absolute error
  • 1 - weights trained to minimize squared error


int  pscrn = 2
Controls whether or not the prescreener neural network is used to decide which pixels should be processed by the predictor neural network and which can be handled by simple cubic interpolation.
The prescreener is trained to know whether cubic interpolation will be sufficient for a pixel or whether it should be predicted by the predictor nn. The computational complexity of the prescreener nn is much less than that of the predictor nn.
Since most pixels can be handled by cubic interpolation, using the prescreener generally results in much faster processing. The prescreener is pretty accurate, so the difference between using it and not using it is almost always unnoticeable.
Version 0.9.3 adds a new, faster prescreener with three selectable 'levels', which trade off the number of pixels detected as only requiring cubic interpolation versus incurred error.
Therefore, pscrn is now an integer with possible values of 0, 1, 2, 3, and 4.
  • 0 - no prescreening (same as false in prior versions)
  • 1 - original prescreener (same as true in prior versions)
  • 2 - new prescreener level 0
  • 3 - new prescreener level 1
  • 4 - new prescreener level 2
Higher levels for the new prescreener result in cubic interpolation being used on fewer pixels (so are slower, but incur less error). However, the difference is pretty much unnoticeable.
Level 2 is closest to the original prescreener in terms of incurred error, but is much faster.


string  cshift =
Sets the resizer used for correcting the image center shift that nnedi3_rpow2 introduces. This can be any of Avisynth's internal resizers, such as "Spline36Resize", "LanczosResize", etc...
If not specified the shift is not corrected. The correction is accomplished by using the subpixel cropping capability of Avisynth's internal resizers.


int  fwidth =
int  fheight =
If correcting the image center shift by using the 'cshift' parameter, fwidth/fheight allow you to set a new output resolution.
First, the image is enlarged by 'rfactor' using nnedi3. Once that is completed the image center shift is corrected, and the image is resampled to fwidth x fheight resolution.
The shifting and resampling happen in one call using the internal Avisynth resizer you specify via the 'cshift' string. If fwidth/fheight are not specified, then they are set equal to rfactor*width and rfactor*height respectively (in other words they do nothing).


float  ep0 =
float  ep1 =
Some Avisynth resizers take optional arguments, such as 'taps' for LanczosResize or 'p' for GaussResize. ep0/ep1 allow you to pass values for these optional arguments when using the 'cshift' parameter.
If the resizer only takes one optional argument then ep0 is used. If the argument that the resizer takes is not a float value, then ep0 gets rounded to an integer.
If the resizer takes two optional arguments, then ep0 corresponds to the first one, and ep1 corresponds to the second. The only resizer that takes more than one optional argument is BicubicResize(), which takes 'b' and 'c'. So ep0 = b, and ep1 = c.
If ep0/ep1 are not set then the default value for the optional argument(s) of the resizer is used.


int  threads = 0
Controls how many threads will be used for processing. If set to 0, threads will be set equal to the number of detected processors.


int  opt = 0
Sets which CPU optimizations to use. Possible settings:
  • 0 = auto detect
  • 1 = use C
  • 2 = use SSE2


int  fapprox = 15
Bitmask which enables or disables certain speed-ups. Value range is [0 to 15].
Mainly for debugging.
  • 0 = nothing
  • &1 = use int16 dot products in first layer of prescreener nn
  • &2 = use int16 dot products in predictor nn
  • &12 = 4 = use exp function approximation in predictor nn
  • &12 = 8|12 = use faster (and more inaccurate) exp function approximation in predictor nn


Examples

  • Enlarge image by 4x with default settings (identical to the 2nd example):
AviSource("Blah.avi")
nnedi3_rpow2(rfactor=4, nsize=0, nns=3, qual=1, etype=0, pscrn=2, threads=0, opt=0, fapprox=15)


  • Enlarge image by 4x but do not correct for center shift.
AviSource("Blah.avi")
nnedi3_rpow2(rfactor=4)


  • Enlarge image by 2x and correct for center shift using Spline36Resize.
AviSource("Blah.avi")
nnedi3_rpow2(rfactor=2,cshift="Spline36Resize")


  • Enlarge image by 8x, correct for center shift and downsample from 8x to 7x using LanczosResize with 5 taps.
AviSource("Blah.avi")
nnedi3_rpow2(rfactor=8,cshift="LanczosResize",fwidth=width*7,fheight=height*7,ep0=5)



Back to nnedi3

Personal tools