AVSShock

From Avisynth wiki
Jump to: navigation, search
Abstract
Author AMSS0815
Version 2008-02-23
Download AVSShock-2008.02.23.zip
Category Sharpeners
License GPLv2
Discussion Doom9 Thread


Contents

Description

This Shock Filter sharpens edges of images by applying erosions or dilations depending on the sign of the Laplacian (or the so called Haralick-Canny edge detector).

Common sharpening algorithms often evolve the heat equation backwards (so called Gabor algorithm). This is done by convoluting the image with a mask with negative weights (like AviSynths build-in Sharpen function does). As this method violates a so called maximum principle (values of pixels calculated may be outside the value range of the original image), instabilities arise after some iterations, which can be observed as high oscillations.

This filter uses a morphological approach: In each iterations step, pixels are replaced by one of their neighbors. To avoid sharpening noise, a blurred version of the image is used only for the choice of each neighbor. This way high oscillations can be avoided even on large scales.

Note: AVSShock is a C-plugin so it must be loaded using LoadCPlugin, except if you're using AviSynth+, it allows autoloading of C-plugins.

Requirements


Syntax and Parameters

Shock(clip Clip, int "Steps", float "Strength", bool "Canny", float "Blur", int "BlurSize")


clip   =
Clip gives the source clip. YV12 or YUY2 are the only colorspaces currently allowed. The resulting clip will have the same properties as the source clip.


int  Steps = 1
Unsharp masking threshold.
Steps gives the number of iterations applied to each video frame. (Default: 1). If Steps is zero, the clip is returned unmodified. Use a negative number to display a copyright message (along with an error message).


float  Strength = 1.0
Strength gives the size of each iterations step. Values between 0.0 and 1.0 are allowed (Default: 1.0). The effective scale of the shock filter will be Steps∗Strength. If this product is zero, the source clip will be returned unchanged.


bool  Canny = false
Canny: If true, the Haralick-Canny edge-detector will be used, which is more precisely and requires more computation time. Otherwise, the Laplacian will be used. (Default: False).


float  Blur = 1.0
Blur defines how strong each frame will be blurred before the edge detector is applied. Note that the blurred image will not be processed further. After applying the edge-detector, the erosions and dilations are applied to the original frame. The Blur value is the standard deviation of a Gaussian convolution kernel which is applied to the frame for blurring. (Default: 1.0). If Blur is zero, the blurring step is completely omitted and computation will be considerably faster.


int  BlurSize =
BlurSize is the size of the blurring kernel: The kernel used will be a (2∗BlurSize+1)×(2∗BlurSize+1) matrix. (Default: Ceil(2∗Blur)). If BlurSize is zero, the blurring step is completely ommited and computation will be considerably faster.


Examples

AVSShock with default settings:

AviSource("Blah.avi")
Shock()


Changelog

2006.12.19

    Initial Version.

2007.01.04 	

    Changed the Blur default from 2.0 to 1.0.
    Changed the BlurSize default from Round(2∗Blur+1) to Ceil(2∗Blur).
    Added this helpfile
    Maybe memory consumption reduced: Source frame is released before second temporary frame is allocated. I don't know how AviSynth exactly handles frame allocation stuff.
    About 25% speed up: Temporary memory was allocated by creating frames, now malloc is used.
    Some minor code improvement. Numbering of pixels inside a 3×3 block is more elegant. Maybe undetectable speed up.

2007.01.25 	

    Small extensions in the help file.
    Small corrections in the help file html-layout.
    Small corrections/improvements in code: Added forgotten calling-convention macro to Shock_Free, moved color space dependent undefs in CS-file.
    Bug corrected: When an unknown color space was used (e.g. Y8), a "out of memory"-message came up.
    Raised gcc optimization level from -O1 to -O3 (silly me).

2007.02.19 	

    Simplified distinction of standard deviation and heat equation scale in Code.
    GetFrame function rewritten. Size of binary reduced by 1 kB.
    Added filter name to error messages.
    Changed error handling in filter create function to avoid multiple memory allocation.
    Small corrections in help file.
    First public version.

2008.02.23 	

    AviSynth_C.dll is not needed anymore (I updated MinGW (see the makefile) — thanks to Fizick).
    Changed a lot floats to doubles, which increased blurring accuracy and speed.
    Blur intensity is checked for too small values now.
    Minor change to CreateGaussKernel function.


Archived Downloads

Version Download Mirror
2008-02-23 AVSShock-2008.02.23.zip
2007-02-19 AVSShock-2007.02.19.zip


External Links




Back to External Filters

Personal tools