Avisynth TUnsharp

From wiki.selur.net
Jump to navigation Jump to search

TUnsharp is an edge-aware sharpener by tritical. It sharpens only pixels whose edge strength lies between two thresholds, and it limits the result so that it cannot overshoot much.

Filtering → Avisynth → Sharpen

TUnsharp controls in Hybrid
TUnsharp controls in Hybrid

What it does

The filter measures the edge strength at each pixel. Pixels with an edge strength between the lower and upper Threshold are sharpened; flat areas (noise) and very strong edges (already sharp) are left alone. The sharpened value is then limited to stay close to the local minimum and maximum, which keeps halos small. Several sharpening operators are available. A blurred copy of the picture, made with the Radius, is used internally.

Typical uses:

  • Sharpen a soft source without amplifying flat-area noise.
  • Raise Strength for a stronger effect and lower Limit to keep halos in check.

Settings

Control Parameter Range Hybrid default Meaning
Strength strength 0–512 100 Amount of sharpening.
Threshold (L/U) thresholdL / thresholdU 0–255 2 / 40 Only pixels with an edge strength between the two values are sharpened. The upper value must not be lower than the lower one, otherwise the filter does nothing and runs slowly.
Type type linear (5 point), linear (9 point), teager, cubic, rational, subtract, Xsharpen linear (5 point) The sharpening operator.
Radius radius 1–3 2 Radius of the internal smoothing. Larger values are slower and handle noise better.
Map map 0–2 0 Debug output. 0 is the normal picture, 1 shows the pixels that would be sharpened, 2 shows a binary map (255 or 0, chroma 128).
Limit lim 0–256 2 With the first six types, the maximum deviation from the local minimum and maximum. With Xsharpen, the maximum distance used for the mapping.

Example

Default settings on a 10-bit YUV 4:2:0 source. Hybrid converts to 8 bit before the filter and back to 10 bit afterwards; with all defaults no argument is written:

# Converting from 10 to 8bit for TUnsharp
ConvertBits(8)
TUnsharp()
# Converting from 8 to 10bit for encoder
ConvertBits(10)

How Hybrid calls it

  • Loads the TUnsharp plugin (the 64-bit build in a 64-bit install).
  • The filter needs 8-bit YV12. Hybrid adds the conversions to and from that format.
  • Only arguments that differ from the defaults are written; Type is written as its index (0–6).
  • TUnsharp also offers the common options and can be added to the filter queue several times.

Background

  • TUnsharp 0.9.3 by tritical is a classic AviSynth 2.5 plugin released under the GPL.
  • The plugin also supports YUY2 and has a gui argument that opens a settings dialog with a preview. Hybrid offers neither.

Sources