Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 19th February 2007, 21:05   #1  |  Link
AMSS0815
Registered User
 
Join Date: Aug 2006
Posts: 29
New sharpening plugin: Shock Filter

Hi everybody,

finally I managed to create my first AviSynth plugin. This is the abstract (from the filter docu file):
Quote:
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.
Warning: It is likely that this plugin violates U.S. Patent 5.664.513. As a consequence, any distribution and/or use is prohibited in the U.S. For details see the documentation file coming with the plugin. Any infingement might be prosecuted by the patent holders.
Because of this I don't have the heart to publish this filter in this forum. Instead it is published in the German doom9 forum. I encourage everyone outside the U.S. to go to the Shock filter thread there and download and try it.

If you have some comments on this plugin (technically or legally), please don't hesitate and post it here - every comment is wellcome!

Here are some problems I came across during the development:
  • I'm using Kevin Atkinsons great C-Plugin-Interface, and the file AviSynth_C.dll is needed for the plugin to operate. As far as I understand this file isn't needed in newer versions of the C-Interface. When I simply replace AviSynth_C.lib with AviSynth.lib that comes with the latest AviSynth version (and modify the Makefile accordingly), gcc gives me a couple of errors like AVSShock.obj(.text+0x1e):AVSShock.c: undefined reference to `_imp__avs_add_function@20'. Has anyone any experiences in compiling plugins with gcc?
  • Is malloc/free the correct way to allocate/free memory needed inside the GetFrame function?

I hope publishing in the German forum and discussing in the English forum does not violate any forum rules. I apologize otherwise

Best regards,
AMSS
AMSS0815 is offline   Reply With Quote
Old 19th February 2007, 22:46   #2  |  Link
HeadBangeR77
Registered User
 
HeadBangeR77's Avatar
 
Join Date: Dec 2006
Location: Heidelberg (DE), Kraków (PL)
Posts: 519
Sh**, if I register to Gleitz, I won't have time left for my real life.
Anyway, thanks for the info, at least I am willing to check how it works in practice.

cheers,
HDBR77
__________________
"Only two things are infinite: the universe and human stupidity, and I'm not sure about the former."
HeadBangeR77 is offline   Reply With Quote
Old 19th February 2007, 23:33   #3  |  Link
Terranigma
*Space Reserved*
 
Terranigma's Avatar
 
Join Date: May 2006
Posts: 953
thanks for the new sharpening filter. I'll see how this baby does with a few test clips.
Terranigma is offline   Reply With Quote
Old 20th February 2007, 05:03   #4  |  Link
JarrettH
Registered User
 
Join Date: Aug 2004
Posts: 838
Can't wait to see the results and the 10 pages of discussion to follow
JarrettH is offline   Reply With Quote
Old 20th February 2007, 10:06   #5  |  Link
AMSS0815
Registered User
 
Join Date: Aug 2006
Posts: 29
Hi,
Quote:
Originally Posted by HeadBangeR77 View Post
Sh**, if I register to Gleitz, I won't have time left for my real life.
That's no problem: You don't have to register to download the file (At least I can download at the moment without logging in and without any cookies ).
for checking practicability.

AMSS
AMSS0815 is offline   Reply With Quote
Old 20th February 2007, 11:06   #6  |  Link
Mug Funky
interlace this!
 
Mug Funky's Avatar
 
Join Date: Jun 2003
Location: i'm in ur transfers, addin noise
Posts: 4,547
interesting results!

it's quite slow though i'll be sticking to limitedsharpen or seesaw for now i think.

makes for some nice upsizing. this could be good for the anime buffs out there.
__________________
sucking the life out of your videos since 2004
Mug Funky is offline   Reply With Quote
Old 21st February 2007, 22:51   #7  |  Link
krieger2005
Registered User
 
krieger2005's Avatar
 
Join Date: Oct 2003
Location: Germany
Posts: 377
For my taste this simple script work good on upsized real-life content:
Code:
i=last
mm2=yv12lutxy(i.expand().blur(.8).expand(),i.inpand.blur(.8).inpand(),yexpr="x y - 2 *")
clean=i.Shock(strength=.4, steps=3).Blur(1.15)
maskedmerge(i,clean,mm2.expand.blur(1.58).expand .levels(32,1.0,strength,0,208,false))
My integration of "Shock" in LimitedSharpen give not that good result like the function above.
krieger2005 is offline   Reply With Quote
Old 22nd February 2007, 12:25   #8  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,394
Quote:
Originally Posted by krieger2005 View Post
My integration of "Shock" in LimitedSharpen
What exactly was that - did you just use Shock as the sharpener within LS?
If so, that is (should be) wasted effort: LS is cutting-away the overshoot of a sharpener. But Shock does not overshoot, so why put it into LS?
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)
Didée is offline   Reply With Quote
Old 22nd February 2007, 13:22   #9  |  Link
krieger2005
Registered User
 
krieger2005's Avatar
 
Join Date: Oct 2003
Location: Germany
Posts: 377
Quote:
Originally Posted by Didée View Post
What exactly was that - did you just use Shock as the sharpener within LS?
yes.
Quote:
Originally Posted by Didée
If so, that is (should be) wasted effort: LS is cutting-away the overshoot of a sharpener. But Shock does not overshoot, so why put it into LS?
Just because of the mask. For natural content Shock is too heavy. But it make clear edges (without haloing). So i want just a function which make good and clear edges without to make a mosaik-image.

BTW: I just noticed the script above does not work as good as i thought... In general the Edges are to sharp for real content. And for Anime also i think. Maybe the add of an "antialiasing" option could give better results (you see in the script above i used blur).

Last edited by krieger2005; 22nd February 2007 at 14:37.
krieger2005 is offline   Reply With Quote
Old 24th February 2007, 18:20   #10  |  Link
Dreassica
Registered User
 
Join Date: May 2002
Posts: 384
Tried it on some anime content, and i agree with Krieger. It tends to make a mosaic out of the picture quite easy, an antialiasing option may be nice then. Effect does have soem similarities to certain linedarkening methods.
Dreassica is offline   Reply With Quote
Old 6th March 2007, 18:42   #11  |  Link
AMSS0815
Registered User
 
Join Date: Aug 2006
Posts: 29
Hi,

Quote:
Originally Posted by Mug Funky View Post
it's quite slow though
I'm on learning SSE right now, but it might take some time before I get productive. The code is currently pure C and compiled for i386. Best speed gain is given by switching the pre-blur off (but then noise is enhanced as well).

Quote:
Originally Posted by Dreassica View Post
It tends to make a mosaic out of the picture quite easy, an antialiasing option may be nice then.
Did I get this right: Mosaic are the staircases on diagonal edges. (That is, what I think, anti-aliasing should avoid ..?) I never implemented an anti-aliasing-algorithm before, I will think about it...

The only way to avoid these staircases I see right now is applying Shock to an upsized image (what reduces speed terribly, of course):
BilinearResize(2*Width,2*Height).Shock.ReduceBy2
Anyway, thanks for trying - I hope there will be a new version soon.

Regards,
AMSS
AMSS0815 is offline   Reply With Quote
Old 6th March 2007, 18:52   #12  |  Link
MfA
Registered User
 
Join Date: Mar 2002
Posts: 1,075
Mosaic means that the image becomes piecewise constant. Blending pixels with their neighbors rather than replacing them entirely might help (known as inverse diffusion).
MfA is offline   Reply With Quote
Old 23rd February 2008, 15:04   #13  |  Link
AMSS0815
Registered User
 
Join Date: Aug 2006
Posts: 29
Update to 2008.02.23

Hi everybody,

I updated AVSShock to version 2008.02.23. Main change is the removal of AviSynth_C.dll. Thanks to Fizick, this file isn't necessary anymore (Plugin is still loaded with LoadCPlugin). Further (minor) changes are listed in the help file. The file is attached to the original post in the german doom9 forum.

Please note the possible patent violation described in the original post of this thread.

Have fun,
AMSS
AMSS0815 is offline   Reply With Quote
Old 3rd March 2008, 22:38   #14  |  Link
Ignus2
Registered User
 
Join Date: Dec 2005
Posts: 249
In case you still need any, I have aplenty of XP with gcc+avisynth_c, I developed all my stuff with that. Works like a charm.

Here is an example I put together some time ago, commented out as best I could: http://forum.doom9.org/showthread.ph...740#post917740

--
Greets,
I.
Ignus2 is offline   Reply With Quote
Old 11th March 2008, 07:18   #15  |  Link
yup
Registered User
 
Join Date: Feb 2003
Location: Russia, Moscow
Posts: 854
Hi AMSS0815!
Main area for this plugin animation or computer graphics? I try for my analog capture and get very segregating image. May be exist parameter set for different type source parameter set? For my analog capture more satisfied results at step=1, and strength=0.25, increase strength give segregated image.
with kind regards yup.
yup is offline   Reply With Quote
Old 21st March 2008, 12:17   #16  |  Link
AMSS0815
Registered User
 
Join Date: Aug 2006
Posts: 29
Hi yup,
Quote:
Originally Posted by yup View Post
Main area for this plugin animation or computer graphics? [...] For my analog capture more satisfied results at step=1, and strength=0.25, increase strength give segregated image.
No. I didn't have any special application in mind, just everything which is blurred. Thanks for the feedback! Yes, it's a pretty strong sharpener. Maybe you can restrain it by increasing the Blur option, or changing the Canny option.

Good luck! AMSS
AMSS0815 is offline   Reply With Quote
Old 23rd March 2008, 13:06   #17  |  Link
mgh
Registered User
 
Join Date: Oct 2004
Location: India
Posts: 322
which is better-step=5 and strength =0.05
or -step=1 and strength=0.25?
or are they equivalent?
__________________
A shut mouth gathers no foot
mgh is offline   Reply With Quote
Old 23rd March 2008, 15:03   #18  |  Link
yup
Registered User
 
Join Date: Feb 2003
Location: Russia, Moscow
Posts: 854
Hi mgh!
Read documentation. Output this sharpener is solution for partial differential equation. Product strength and step is time distance between initial data and solution, but if step increase also increase solution accuracy, and sharpener quality.
yup.
yup is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:09.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.