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 Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 15th October 2003, 19:45   #1  |  Link
mf
 
mf's Avatar
 
Join Date: Jan 2002
Posts: 1,729
New filter in the battle against oversmoothing: UnSmooth

Hi there .

While thinking of ways to combat oversmoothing (I had already made a filter for myself that does a series of Sharpen()s and runs that on flat areas of the picture, but wasn't satisfied) I was suddenly inspired by the old scripted unsharp mask at the top of every version of mfToon. I thought, can't I make a "smart unsharp mask" ? And apparently I could, and so I did. Lots of swearing at AVISynth (partly my fault, partly some stupid ways of how AVISynth works) and eager typing away at notepad later, and here is UnSmooth v0.1.

Get it here.

What does it do. It amplifies noise, small detail, and artifacts. Doesn't sound very attractive, but there can still be some detail left in oversmoothed encodes, and to make sure you don't filter those out when getting rid of the artifacts, you might want to try this.

Now how the hell does it work. Unsharp mask (a sharpening technique) works by subtracting a blurred version from the original in order to get a sharper version. UnSmooth works by subtracting a smart smoothed version from the original in order to get a sharper version on the spots that were smoothed. It works with any filter, even things like FlipVertical() or Levels() (try it for a funky effect). So you can put in your favorite smoother.

There are no dependencies, except for the default smoother (which can of course be overridden), which is Deen. Input has to be mod4, and a colorspace which your chosen smoother supports. Output will always be YV12.

Thanks go out to |MKSM| for tweaking Levels() so that it didn't darken the image. This patch will also go in the next version of mfToon, so look forward to it! It might fix those dark frames some of you are getting.

Have fun .

Last edited by mf; 15th October 2003 at 19:52.
mf is offline   Reply With Quote
Old 15th October 2003, 20:22   #2  |  Link
Soulhunter
Bored...
 
Soulhunter's Avatar
 
Join Date: Apr 2003
Location: Unknown
Posts: 2,812
Thanks...

I will play with it the next days, to see how it performs !

But as its a "mf's" I bet it will rock...

Keep on producing such scripts, I can't get enough of them !!!

Bye
__________________

Visit my IRC channel

Last edited by Soulhunter; 15th October 2003 at 20:29.
Soulhunter is offline   Reply With Quote
Old 16th October 2003, 00:16   #3  |  Link
NightMare
Registered User
 
NightMare's Avatar
 
Join Date: Jul 2003
Posts: 73
wooooooow this will do well for alot of animes i download from the net

thanx keep up the good work mf

u know u should get a prize or somthin
NightMare is offline   Reply With Quote
Old 17th October 2003, 17:48   #4  |  Link
Soulhunter
Bored...
 
Soulhunter's Avatar
 
Join Date: Apr 2003
Location: Unknown
Posts: 2,812
Ok, one question before I start playing with it the whole weekend...

It seems that "UnSmooth" is some kind of replacement for unfilter... !?!

Right... ???

Ok, I used Unfilter much till now... !

So my interest in UnSmooth grows even more !

Is it only recomendet to use with anime...

Or also with real movie content ? (I think so...)

A second question...

It will be used in the next "mfToon" version...

Ok, cool...

When my VideoIn works, Ill use it to encode my DBZ eps. !!!

When the response is well... (think so ! )

Could this also be implemented some way in "SharpTools" ???

Maybe "SharpTools-EX" ???

Bye
__________________

Visit my IRC channel

Last edited by Soulhunter; 17th October 2003 at 18:02.
Soulhunter is offline   Reply With Quote
Old 17th October 2003, 20:25   #5  |  Link
mf
 
mf's Avatar
 
Join Date: Jan 2002
Posts: 1,729
Eerm, it's not like it's a great filter ;/. It just does what I say it does, and, frankly, I haven't found a good use for it yet. My gad guard raws are so bad this only makes it worse. So, if you find a good use, tell me! Anyway, it does kinda dangerous things, so use with care.
mf is offline   Reply With Quote
Old 17th October 2003, 21:25   #6  |  Link
Soulhunter
Bored...
 
Soulhunter's Avatar
 
Join Date: Apr 2003
Location: Unknown
Posts: 2,812
Sounds.... ??? Uhm... ???

Yeah, it sounds Interesting !!!


I encode some stuff with it, and will see what it does... !

Its everytime fun to play around with stuff like this !


PS:

Just started a first encode of Gladiator (only a small part of it... )

Will post back tomorrow or so with some feedback... !

Bye
__________________

Visit my IRC channel

Last edited by Soulhunter; 17th October 2003 at 21:35.
Soulhunter is offline   Reply With Quote
Old 17th October 2003, 22:28   #7  |  Link
bilu
Registered User
 
bilu's Avatar
 
Join Date: Oct 2002
Location: Portugal
Posts: 1,182
How does it behave relative to Unfilter (+,+)?


Bilu
bilu is offline   Reply With Quote
Old 18th October 2003, 12:53   #8  |  Link
Soulhunter
Bored...
 
Soulhunter's Avatar
 
Join Date: Apr 2003
Location: Unknown
Posts: 2,812
Hi again !

Here are my first results... (more will follow, I hope ! )


Source was a Gladiator trailer (DVD/PAL)

Lenght is about 1:05 min.

Resized to 640x480 (no cropping)

DivX 5.05 settings - Quantizer2 / Default / Bidi. Encoding

XviD (last Koepis dev3) settings - Quantizer2 / MPEG / Default



DivX 5.05 - Without UnSmooth

time to encode (I don't know... )

Final size is 26.804.224 Bytes


DivX 5.05 - With UnSmooth (default settings)

time to encode ca. 11min. (P3'933)

Final size is 31.227.904 Bytes


About the visuals:

The UnSmooth encode seems to increase detail a bit !

But even more it increases the noise...

Background-detail is a way to noisy now !

But in some scenes it looks pleasent...

A bad side effect of this filter...

It looks like, that the gained details seems to flicker a bit !?!

I think its because the smoothing of deen is not static enough...



XviD - Without UnSmooth

time to encode ca. 6min. (P3'933)

Final size is 34.013.184 Bytes


XviD - With UnSmooth (default settings)

time to encode ca. 12min. (P3'933)

Final size is 39.288.832 Bytes


About the visuals:

The UnSmooth encode here, has even more increased the detail !

But also even more it increased the noise here...

Its overall a way to noisy now !

I will try it next time with lowered strenght... !

Flickering effect is same here...


Conclusion:

Ehm... Yeah, could be a nice thing that UnSmooth filter, but for this source it is not so nice... !

I think, its because this source is already overloaded with details n' noise !

Maybe it works better with less-detail and/or blurry sources... !?!

Would be logical, when you consider what it does...


In this example deen was used as smoother...

I have not much exp. with deen, because I don't use it much !

Maybe I do some tests with some other smoothers as replacement...

Is a smoother out there, that only smooths detail, but let noise and artefact's untouched... ???

Could be a challenge for someone, to produce such a "bad" smoother...


About this flickering...

Its not so bad, but still visible here and there !

I think there are only two ways to prevent this...

1st. Make the smoothing more static...

2nd. Make the noise in the movie more static...

Now, whats easier to do... ???


No matter, this filter rocks !!!

Thanks again, mf !!!


@Bilu
Quote:
How does it behave relative to Unfilter (+,+)?
Think, Its the same principle, only in a other way...

AFAIK, Unfilter uses the negatives "reverted result" from usually blurring...

Unsmooth uses the negatives from a smoother like deen or any other !

Hope this is right... !

But I bet mf could answer this question much better !


Bye
__________________

Visit my IRC channel

Last edited by Soulhunter; 18th October 2003 at 14:03.
Soulhunter is offline   Reply With Quote
Old 18th October 2003, 15:29   #9  |  Link
mf
 
mf's Avatar
 
Join Date: Jan 2002
Posts: 1,729
Yes, it is true that sharpening is technically the opposite of blurring. Sharpen(-1.0) does the same as Blur(1.0), and unsharp mask works through this principle. Though with less than optimal results, it's also possible to use a sharpener as "smoother" on unsmooth and get a blurred result. Anyway, the staticness of your amplified noise depends on the temporal influence you set in deen, i think. I haven't yet figured out yet if that also works reversed, as with the spatial smoothing, where more smoothing means more sharpening. It is most logical though.
mf is offline   Reply With Quote
Old 19th October 2003, 01:23   #10  |  Link
Soulhunter
Bored...
 
Soulhunter's Avatar
 
Join Date: Apr 2003
Location: Unknown
Posts: 2,812
Hi again mf !

Maybe Im a bit to dummy or so...

But, how can I make you script work with other smoothers with parameters ?

Example:

Temporalsoften(2,3,3,mode=2,scenechange=10)


I thought, its enough to change "smoother" and the "default(params,)" stuff !?!

But I cant get it work...

What lines to change what way... ???


PS:

In order to keep things like this easier...

It would be cool if your script's would come with a small "how to modify" example...

This could help less advanced PPL like me, to work with it !


Bye
__________________

Visit my IRC channel

Last edited by Soulhunter; 19th October 2003 at 02:34.
Soulhunter is offline   Reply With Quote
Old 19th October 2003, 02:46   #11  |  Link
mf
 
mf's Avatar
 
Join Date: Jan 2002
Posts: 1,729
Quote:
Originally posted by Soulhunter
Hi again mf !

Maybe Im a bit to dummy or so...

But, how can I make you script work with other smoothers with parameters ?

Example:

Temporalsoften(2,3,3,mode=2,scenechange=10)


I thought, its enough to change "smoother" and the "default(params,)" stuff !?!

But I cant get it work...

What lines to change what way... ???


PS:

In order to keep things like this easier...

It would be cool if your script's would come with a small "how to modify" example...

This could help less advanced PPL like me, to work with it !


Bye
To use temporalsoften as smoother (using Soulhunter's parameters):
UnSmooth(smoother="Temporalsoften", params="2,3,3,mode=2,scenechange=10")
To use simple blur as smoother (resulting effect is unsharp mask sharpening):
UnSmooth(smoother="Blur", params="1.0")

That should pretty much explain it. Strings need to be wrapped in Chr(34)s instead of quotes, because of AVISynth's undocumented inability to use TEX-Style quotes.
Example:
UnSmooth(smoother="Subtitle", params=Chr(34)+"This will give a funky effect"+Chr(34)+", font_color=$FF0000")
As you can see the Chr() and strings are chained together using math operators.
mf is offline   Reply With Quote
Old 19th October 2003, 03:04   #12  |  Link
Soulhunter
Bored...
 
Soulhunter's Avatar
 
Join Date: Apr 2003
Location: Unknown
Posts: 2,812
Thanks for the quick response... !!!

Bye
__________________

Visit my IRC channel
Soulhunter is offline   Reply With Quote
Old 19th October 2003, 15:06   #13  |  Link
Soulhunter
Bored...
 
Soulhunter's Avatar
 
Join Date: Apr 2003
Location: Unknown
Posts: 2,812
Hi again !

Here are some more results...


Settings for DivX and AVS where same as before !!!



DivX 5.05 - With UnSmooth (VagueDenoiser (threshold=0.8,1,6,true))

time to encode was about 10min. (P3'933)

Final size is 28.278.784 Bytes


About the visuals:

Differences are only slightly visible here and there...

Not much better than the usually encode, but also not much worse !

I think, I should do some more tests with VagueDenoiser !



DivX 5.05 - With UnSmooth (Temporalsoften (9,20,20,2,10))

time to encode was about 5min. (P3'933)

Final size is 29.196.288 Bytes


About the visuals:

WOW !

Even more flickering than with deen(default) !!!

It also amplifies compression artefact's !

A real bad choice, I think...



DivX 5.05 - With UnSmooth (Convolution3d (0,6,10,6,8,2.8,0))

time to encode was about 5min. (P3'933)

Final size is 26.378.240 Bytes


About the visuals:

Uhm, What happens here... ???

The resulting file is smaller than with no UnSmooth !?!

Differences are not much visible... Would say worse !

Now I'm really confused !!!



DivX 5.05 - With UnSmooth (FluxSmooth (10,15))

time to encode was about 5min. (P3'933)

Final size is 29.294.592 Bytes


About the visuals:

Also some flickering here !

It also amplifies compression artefact's a bit...

Detail is not that much increased !!!



Conclusion:

1st.
I think I have to use higher values for further tests, because the differences to the original are only slightly visible...


2nd.
Also with some of this smoothers, I got this flickering ! Fine-adjusting the time parameters seems a bit difficult... Suggestions are welcomed !!!


3rd.
Think, deen was already a good choice foe this script...
But the thing with this flickering should be solved, before implementing this elsewhere !


Anyway, cool stuff this script !!!


Bye
__________________

Visit my IRC channel

Last edited by Soulhunter; 19th October 2003 at 15:12.
Soulhunter is offline   Reply With Quote
Old 19th October 2003, 15:17   #14  |  Link
Soulhunter
Bored...
 
Soulhunter's Avatar
 
Join Date: Apr 2003
Location: Unknown
Posts: 2,812
Ah, yeah !

Ive forgotten something...

Ive found a real nice use for UnSmooth... !

As I realized that it simply amplifies the opposite of the filter you add, Ive tried to use it with "AddGrain()" ! Normally this filter puts simply noise in the picture... Looks ok, but in some way unnatural ! But for the cause, that Ive not found a better method to add grain I used AddGrain for some encodes (mostly slight values, to prevent blocking in flat/uniform arears... ) But now I saw that UnSmooth(with AddGrain) does a better job in reproducing film grain ! For my eyes this result looks more natural than the normal AddGrain() ! Don't know why... Think it puts holes (satin-texture) in the pic, instead of putting dust on it... Looks really nice to my eyes !!! Could also be nice for undersized files I think, because it seems to prevent compression of details, without making the picture looking bad... Damn ! I hope something like this gets also implemented in ffdshow as PP-filter... Would be better than the default noise options now !!!


Here are the settings and results:

DivX 5.05 - With UnSmooth(smoother="AddGrain", params="5,0,0")

time to encode was about 5min. (P3'933)

Final size is 29.294.592 Bytes


All other settings where same as in my last testings...


PS:

Feedback about this method would be nice...


Bye
__________________

Visit my IRC channel
Soulhunter is offline   Reply With Quote
Old 20th October 2003, 11:21   #15  |  Link
mf
 
mf's Avatar
 
Join Date: Jan 2002
Posts: 1,729
I think the flickering you're getting is from the original DVD's B-frames. Either that or from the keyframes. I've always annoyed myself at the once a second keyframe interval, which always causes a flicker every second. It could be that this (especially with temporal smoothers) is being enhanced.
mf is offline   Reply With Quote
Old 20th October 2003, 20:17   #16  |  Link
Soulhunter
Bored...
 
Soulhunter's Avatar
 
Join Date: Apr 2003
Location: Unknown
Posts: 2,812
Quote:
I think the flickering you're getting is from the original DVD's B-frames. Either that or from the keyframes.
You mean this flickering is already in the source, but not visible before "UnSmooth"... ?

Hmm... Cant remember, but was there not a filter to stabilize the luma-change... ? Think it was "Antiflicker()" or so... !?!

Maybe adding this filter before UnSmooth could solve this problem... !

Will do some research this week... (When I find the time for it ! )

I'm always a bit bussy...

PS: Have you tryed UnSmooth(AddGrain) ???

Bye
__________________

Visit my IRC channel

Last edited by Soulhunter; 20th October 2003 at 20:22.
Soulhunter is offline   Reply With Quote
Old 20th October 2003, 20:54   #17  |  Link
trbarry
Registered User
 
trbarry's Avatar
 
Join Date: Oct 2001
Location: Gainesville FL USA
Posts: 2,092
Quote:
As I realized that it simply amplifies the opposite of the filter you add, Ive tried to use it with "AddGrain()" ! Normally this filter puts simply noise in the picture... Looks ok, but in some way unnatural ! But for the cause, that Ive not found a better method to add grain I used AddGrain for some encodes (mostly slight values, to prevent blocking in flat/uniform arears... ) But now I saw that UnSmooth(with AddGrain) does a better job in reproducing film grain ! For my eyes this result looks more natural than the normal AddGrain() ! Don't know why...
There must be something else going on here that I don't understand. I can't for the life of me figure out why subtracting a random number is really different than adding one. Should I change the sign of the numbers in AddGrain?

But I haven't tried it yet, so who knows?

- Tom
__________________
My video filters (still) at www.trbarry.com.
trbarry is offline   Reply With Quote
Old 21st October 2003, 18:13   #18  |  Link
Soulhunter
Bored...
 
Soulhunter's Avatar
 
Join Date: Apr 2003
Location: Unknown
Posts: 2,812
Quote:
There must be something else going on here that I don't understand. I can't for the life of me figure out why subtracting a random number is really different than adding one.
Uhm... I don't know really, you are the specialist !!!

But I think its this way...

Noise that matches parts from the original pic gets lower...

While everything else get amplified !

The holes (blank places) in the "noise layer" (or what its called...) stay...

But the noise itself gets left/reduced !

Or so... !?!

Just guessing...

So there is a good chance that this is completely wrong !
Quote:
Should I change the sign of the numbers in AddGrain?
You mean AddGrain(-5,0,0) ???

Is this the same as the UnSmooth method ???

Bye
__________________

Visit my IRC channel

Last edited by Soulhunter; 21st October 2003 at 18:27.
Soulhunter is offline   Reply With Quote
Old 21st October 2003, 20:57   #19  |  Link
DarkNite
Almost Silent Member
 
DarkNite's Avatar
 
Join Date: Jun 2002
Location: Purgatory
Posts: 272
Hmm...

Quote:
Strings need to be wrapped in Chr(34)s instead of quotes, because of AVISynth's undocumented inability to use TEX-Style quotes.
Thank you for dropping that insightful little diddy. That explains a few of the problems I've been having lately.

Oh, and I confer on the point that temporal influence has an effect upon flickering of "details" when using Deen as your smoother. This script with any temporal filter is going to give that effect (from what I've seen so far), some more so than others.

I really wish MarcFD had finished eDeen because this seems like it's almost made as a postprocessor for that spatial monster of a filter.
__________________
Rethinking the "Why?" chromosome.
DarkNite is offline   Reply With Quote
Old 23rd October 2003, 19:47   #20  |  Link
Soulhunter
Bored...
 
Soulhunter's Avatar
 
Join Date: Apr 2003
Location: Unknown
Posts: 2,812
Just to raise trbarry's confusion about it...

And my own too of course... !

Ive done some more tests with Unsmooth + AddGrain !


Here are the results:

DivX with AddGrain(15,0,0)
Size is 53.149.696 Bytes

DivX with UnSmooth(AddGrain 15,0,0)
Size is 32.047.104 Bytes

XviD with AddGrain(25,0,0)
Size is 69.632.000 Bytes

XviD with UnSmooth(AddGrain 25,0,0)
Size is 45.514.752 Bytes


Visuals:

All encodes look ugly, because of the high values Ive used...

But watching the different filesizes is interesting...


Ive also done A/B testings with some sample frames !

Ive used a app with slideshow function to skip btween two frames...

So its easy to spot out the differences !

What I can say so far...

AddGrain added noise everywhere the same way !

This UnAddGrain method added noise only in some places in diffent ways...

Not easy to discribe...

Maybe its because that some grain matches the original film grain !?!


Im not yet through with this... !

More testing in progress !!!


PS: Source & settings where same as in my first test !

[EDIT: Sure not Tom's... Sorry !!! ]

Bye
__________________

Visit my IRC channel

Last edited by Soulhunter; 23rd October 2003 at 22:23.
Soulhunter 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 08:45.


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