Log in

View Full Version : My new UnFilter.dll (soften/sharpen)


Pages : [1] 2 3

trbarry
28th June 2002, 23:13
I capture some things like Buffy that are sent on digital TV but upconverted to some huge 1920x1080 resolution in the process. Even after I resize them to something more reasonable they are very soft.

Now previously I tried a number of times to use the built-in Avisynth Sharpen filter but it always crashed. But yesterday I read here (somewhere) that it was fixed in the 1b7 Avisynth release I'm now running, so I thought I'd try it. It did indeed work and looked pretty good, but it seemed very slow.

So I've ported some of my DScaler code that does a similar thing and released it today as an Avisynth filter, UnFilter.dll.

UnFilter is a simple and reasonably fast Avisynth Soften/Sharpen filter.

It implements 5-tap user adjustable horizontal and vertical filters designed to (slightly) reverse previous efforts at softening or edge enhancement that are common but ugly in DVD mastering. Since DVD's were intended originally for interlaced displays this has caused content providers to vertically filter them even a bit more to hide interlacing artifacts. I don't know why they sometimes over do the edge enhancement.

When softening, the UnFilter will attempt to approximate the inverse of a simple 3-tap edge enhancement filter. When sharpening it will attempt to approximate the inverse of a simple 3-tap softening filter.

More details are in the www.trbarry.com/Readme_UnFilter.txt file or see the source and DLL at www.trbarry.com/UnFilter.zip.

Any feedback appreciated. ;)

- Tom

ARDA
29th June 2002, 00:40
@trbarry

As always I follow your work with great interest,so here my first report.
I have just made a short test,I daren't to give a depth opinion,but it
seems at first sight that at least we have a good and fast sharpen filter
for avisynth.Unluckly I've found some bugs or at least I think they are
with positive values in many cases it shows instead of the frame some lines,
most of them fine lines in black and some yellow areas.
Some examples where it shows those lines:
UnFilter(1,1) until (20,20) bug
but
UnFilter(1,31) is ok.
UnFilter(1,30) is ok.
UnFilter(1,29) bug
UnFilter(2,30) is ok.
UnFilter(20,30) is ok.
UnFilter(20,20) bug
UnFilter(31,30) is ok.
UnFilter(30,31) bug
UnFilter(31,31) bug
UnFilter(32,31) bug
UnFilter(32,30) is ok.

from UnFilter(40,40) until (100,100) it works ok,but I've also watched it accepts
values over 100 and under -100.

I hope this can be usefull.And thanks again for your great job.

ARDA

trbarry
29th June 2002, 03:04
ARDA -

Thanks for testing. Those are very strange results. I previously saw some of the lines you mentioned but only when I stacked up multiple instances of the filter to see what the effects would be. But I'll look into it.

But let me confirm; (1,29) will be a bug no matter what the source material is? I obviously did something silly here but hopefully it should be obvious. The interaction between the two values make me think there is a case where I get them mixed somehow. I'll check.

For now I'd suggest avoiding VSharp numbers right around 30. I think that is about the boundary condition where it actually will use a 5 tap filter since one term goes to zero below there abouts, and I optimized for that.

It is true that there is no range check currently. The results for values not -100 <= x <= 100 will be unpredictable, but probably ugly due to truncation errors. The range check in DScaler was in another part of the code I didn't port.

I only decided to do this yesterday afternoon, out for a walk with the dog. It just annoyed me that I liked the look of the now working Avisynth Sharpen command but it was too slow. So this whole thing was really just an impulse, designed to procrastinate working on finishing up something else. ;)

- Tom

trbarry
29th June 2002, 04:30
It looks like I over optimized one case. The UnFilter will currently give incorrect results when the absolute value of VSharp is less than about 31 (32?) and that of HSharp is greater than that number (both non-zero).

I think there could also be a problem when the source and dest pitch don't match, which might happen right after a Crop() maybe. I should be able to get a fix out tommorrow sometime for both of these.

I still have no idea why UnFilter(20,20) would be a problem but I'll deal with that one later if it doesn't get fixed by serendipity tomorrow. ;)

I think I also know why stacking UnFilters multiple times can cause a problem. This was interesting because it still seems to run faster with 5-6 UnFilter's instead of one Sharpen command, but gives incredibly ugly results.

- Tom

trbarry
30th June 2002, 04:15
I just put out a new version with fixes for the strange behavior with UnFilter(30,30), etc. Also added right click version info (0.0.1.1) and fixed a bug that could maybe have crashed P-II users if anyone had tried it.

Also fixed a potential problem with Avisynth buffer source and dest pitches not matched.

Same file locs:

www.trbarry.com/Readme_UnFilter.txt
www.trbarry.com/UnFilter.zip

- Tom

dividee
30th June 2002, 16:01
Is it just me or the archive is corrupt ?

Doom9
30th June 2002, 16:21
no.. I get the same..

trbarry
30th June 2002, 18:11
Grrrrrrrrr.....

Maybe SmartFTP hiccuped or something. The same zip is okay here but if I open it from the web it's busted.

But I just up-loaded it again and now I can open it and read all the members. So give it another try.

- Tom

ARDA
1st July 2002, 00:53
@tbarry
I couldn't make many tests with the new version.I've just
arrived home and I'm too tired; I've gotta work tomorrow.
I've still found some bugs round the 30 values.It is not
the same ,now it seems to me there is a problem in some width
loop,jumping some columns,every 4 maybe ,I can't be sure of that.
When the values of HSharp and VSharp are both negative I've watched
a problems of darkening ,or maybe some problems with
"potential problem with Avisynth buffer source and dest pitches not matched"
as you say.What I see are the four edges with a different bright.
The bigger the negative values ,the darker the image.
If HSharp > 0 and VSharp< 0 ,is ok. But If HSharp<0 and VSharp>0 the problem
is similar the one watched around the "30".Other information I'm working
on Athlon 1.4 , W2k and this the script:

LoadPlugin("C:\mpeg2dec_dll\mpeg2dec2\Release\mpeg2dec2.dll")
LoadPlugin("C:\Sharing\Release\Sharing.dll")
LoadPlugin("C:\copydvd\avisynth\UNFILTERBARRY\UnFilter300602\UnFilter.dll")
#####
MPEG2source"D:\MALDICIONESCORPIONDEJADE\MALDICION1771.d2v")
Crop(0,4,712,568)
SimpleResize(640,352)
UnFilter(51,-35)
Tweak(bright=5,cont=1.08,sat=0.75)

Thanks again ARDA

trbarry
1st July 2002, 01:42
ARDA -

Is UnFilter(51,-35) where the problem is? Or is it when ( HSharp<0 and VSharp>0 )? I'll test both. I admit more of my testing was with sharpening then softening, just because that's what I needed for myself at the moment.

But I don't notice any problems around the (30,30) area now. Could you post a pic?

It is true that UnFilter does 4 pixels at a time and the left 4 are not filtered. So it's something else to look at. But I thought I corrected the problem with the different pitches (I actually had had them backwards in the first version).

And I don't usually use Tweak. Are you trying to correct the problem with that?

Thank,

- Tom

edit: yep, I can dupl that every 4 pixels thing. Don't know why it happens yet though.

ARDA
1st July 2002, 21:31
@tbarry
I'm sorry but I had a lot of work today and I've just sat in front
of my computer.The UnFilter(51,-35),was accidentally the last value
I've tested ,of a serie of random ones.I've included Tweak to increase
contrast to be able to see if I could find any problemdirectly in VDub
using 2Xsize in a 21" monitor.My apologizes the problem when
HSharp<0 and VSharp>0 is always around "30".I'll try to attach two
examples.One for both negative and the other the case above mentioned.

ARDA

trbarry
2nd July 2002, 23:30
I just put out another version with more bug fixes.

Same file locs:

www.trbarry.com/Readme_UnFilter.txt
www.trbarry.com/UnFilter.zip

ARDA -

This should correct your errors with small and mixed parm values, including the 'every 4 pixels' error and the dark screens.

- Tom

ARDA
3rd July 2002, 06:47
@Tom

Just two quick tests ,I did't find anything wrong.
I'll do more when I'm back from job.
Once more great job.Thanks

ARDA

trbarry
3rd July 2002, 07:44
ARDA -

Thanks for all the work you've done on this. Hopefully I didn't overlook anything else incredibly dumb.

- Tom

trbarry
3rd July 2002, 08:03
Someone emailed me today about this so let me add a few words about the softer side of UnFilter ...

The negative (softening) parm values were a first attempt at an algorithm to remove overzelous Edge Enhancement. This is a problem that bothers videophiles with expensive hi rez projectors on some movies, though it might not show up anyway unless you were making very high rez high bit rate encodings. For more info, see Bjoern Roy's excellent page on the issue, at the Ultimate Guide to Edge Enhancement (http://home.t-online.de/home/bjoern.roy/Guide_EE/Html/Page_01.htm)

My experiment was only partly successful as UnFilter is sort of a 5-tap filter that can unwind a 3 tap EE filter. So UnFilter with softness settings can help a bit only if the EE isn't too wide. Also, a little bit of softening can give some movies back a film look. But in order to have a really great effect on EE you might have to over soften the clip. OTOH, that might make it compress better.

Still experimental. YMMV.

Here's a sample matching one sample on Bjoern Roy's page from Terminator 2, a known EE offender, plus a couple sample efforts at removing the EE.

www.trbarry.com/T2_orig_EE.jpg
www.trbarry.com/T2_softer.jpg
www.trbarry.com/T2_Softest.jpg

The pics above were actually done using the real time DScaler version of UnFilter built into the Greedy/HM deinterlace code, but the UnFilter code there is substantially the same as the Avisynth version.

- Tom

Bluedan
3rd July 2002, 11:33
couldn't reach your site, please take care, I'm curious about your filter...:)

trbarry
3rd July 2002, 15:31
Bluedan -

Dunno. Maybe try again. It seems to be up now.

- Tom

Boulder
5th July 2002, 22:07
@trbarry: This might be a rather simple (and stupid!) question, but does UnFilter(40,40) do almost the same sharpening effect as Sharpen(0.4)? As markrb suggested using the sharpen function for optimal SVCD quality, I'd much rather use this excellent and fast filter you've created than the slower one built in Avisynth.

Keep up the good work - the scene needs people like you:)

trbarry
6th July 2002, 00:39
@trbarry: This might be a rather simple (and stupid!) question, but does UnFilter(40,40) do almost the same sharpening effect as Sharpen(0.4)?

Boulder -

Nope. Almost certainly not. The algorithm is designed to be the inverse of something else I previous wrote and the '40' is scaled to be about 40% of the way to where I start getting artifacts due to overflow errors. ;)

I just wanted it normalized to a range of -100 through 100 because these values first appeared slider controls in the DScaler project.

- Tom

Dreassica
7th July 2002, 17:57
Great filter!! The encoding time in CCE 2.5 creating SVCD's using unfilter.dll in the avs script has dropped from 50 min. to 30 in each pass and the results are the same as the slow sharpen command!!

trbarry
8th July 2002, 00:35
Dreassica -

Thanks for your encouraging words. AFAIK you are only the 2nd person to try this filter, besides myself.

Glad I wasn't trying to sell it. ;)

- Tom

manono
8th July 2002, 07:38
Hi-

You sell yourself short Tom. I jumped on it as soon as it came out, as I've been trying to find something to lessen the effects of Edge Enhancement (I've run across a lot of it recently). Temp Smoothers usually damage the film before cleaning up EE and the associated pixelation. Unfortunately, my tests show that you have to blur-soften the film too much before it has much of an effect on a movie with bad EE. But combined with a light TemporalSoften2, it's not too bad.

However, as Dreassica said, as a sharpener for soft sources, it's great, and way faster than the Sharpen filter. They're just now getting wind of it down at the SVCD Forums where a lot of people like to sharpen up the source (for some reason) and have only had the Sharpen Filter before now. So you may hear some more reactions before too long.

Boulder
8th July 2002, 13:42
Since you wanted feedback, here's some: it's simply magnificent! I've encoded three TV captures and using a rather small value for UnFilter gives the same results as Sharpen ( +bicubic 0.00/0.75 ) but is a helluva lot faster!

Although, it seems to crash Avisynth (the infamous read access violation error) in Win XP sometimes. Win98SE has worked flawlessly.

Holomatrix
8th July 2002, 14:24
Hello, I just read about this new filter. What values would you use to get a sharpen of .5? I tried UnFilter(15,15) and did not notice any difference. My max ave bitrate was 2230, would the filter work better with low bitrates? and do you recommend using the higher values for Bicubic? (Increase from .6 to .8?)
Thanks

trbarry
8th July 2002, 16:53
Sorry, the UnFilter sharpen values don't correspond nicely to other filter values in Sharpen, BiCubicResize, etc. I'd just try raising them until you either get too much sharpening or reach 100.

- Tom

trbarry
8th July 2002, 16:56
Although, it seems to crash Avisynth (the infamous read access violation error) in Win XP sometimes. Win98SE has worked flawlessly.

Is UnFilter somehow implicated in the crash? Could you provide some more info?

And you might try updating to Avisynth beta 6 or 7 if it's not just an UnFilter problem.

- Tom

trbarry
8th July 2002, 16:59
@all

Glad to hear that some of you are using this after all. Thanks for the feedback.

- Tom

Gant
9th July 2002, 02:04
i come a little late... but still.. i'm using this filter and i'm finding it very usefull to me... thnaks for this great filter m8 :)

Again Thnaks for u'r hard work :)

Matta.

Gant

Dreassica
9th July 2002, 13:18
I haven't had any crashes with the unfilter on yet with my XP system!!

Boulder
9th July 2002, 18:17
Originally posted by trbarry
[B]

Is UnFilter somehow implicated in the crash? Could you provide some more info?

And you might try updating to Avisynth beta 6 or 7 if it's not just an UnFilter problem.


I'm currently using beta 6 I think. I've had crashes when using UnFilter but not without it. However, I've found out that XP sometimes speeds up the encoding so much that it crashes (sic!), especially when Sharpen is present. Win98 doesn't go as fast but is more stable.

Unfortunately I can't give any specific details yet as I've only done a couple of encodes, but as I said, Win98 works like a charm!

soulfx
10th July 2002, 11:14
I just ran across a strange side effect of using the UnFilter. I use an Animated MergeChroma and MergeLuma to blend in my name and episode info into the first couple seconds of video. This will usually drop the FPS during those seconds of blending down to around 8 FPS. However I noticed that if I have some form of UnFilter in the AVS script (and it doesn't even have to be set to do anything (Like UnFilter(0,0))) it will increase my FPS up to it's normal real-time 23-24FPS! That's sweet, but uh, I don't think it's supposed to do that.

I'm not sure if this speed improvement can be applied to other Filter's as I haven't tried yet, but I sure did a double take when I noticed it.

Any info or thoughts?

trbarry
10th July 2002, 16:28
soulfx -

I'm not sure how Avisynth does it but any time you combine multiple clips of different frame rate into one (using ANY filters) you maybe will end up with a single constant frame rate.

- Tom

Holomatrix
11th July 2002, 16:55
Any chance on getting some samples to show or if you can let me know what settings would you use (unfilter(20,20))?
Thanks

trbarry
11th July 2002, 17:23
I don't have any sharpening samples, or even any additional recommendations, but I posted some softening samples in the discussion on removing EE earlier in this thread.

- Tom

Dreassica
25th July 2002, 20:05
Maybe a stupid question, but isn't DivX Yuy2 compliant, because i used the unfilter in my avs to convert divx to SVCD, but it won't open the AVS in Vdub, stating that unfilter only supports Yuy2 color format. When i tried searching for explanation i found out it was the first DivX 3.11 file i tried encoding (the earlier ones were all DivX5).. I distictly remember reading that divX was Yuy2 native.

trbarry
26th July 2002, 07:20
I don't know what format Divx 3.11 uses. But you could probably just put in a ConverttoYUY2 statement.

- Tom

Dreassica
26th July 2002, 10:15
I did that, it now will load into Vdub, but i still get the crashes in CCE!!

h00z
31st July 2002, 04:06
I'm having some issues with Unfilter in my anime encoding. It seems that I end up with vertical "bars" running through my encodes with the settings I'm using (tried more than a few different settings of course).

Are you guys finding that you need different values for horizontal and vertical when sharpening?

trbarry
31st July 2002, 05:53
I have seen the vertical bars when I sharpen it too much, or especially when I tried sharpening it twice. But it seems to depend upon the material. Some video already has some edge enhancement and sharpening will make it worse.

Also, Vlad just sent me a fix, pointing out that this can crash on a K6-II, using an unsupported instruction. I'll try to incorporate that and make it available soon but anyone experiencing this please PM me.

- Tom

lovelegend
31st July 2002, 06:16
I'm a newbie amd I'm going to find a suitable filter chain for myself. Therefore, I would like to ask if I want to convert DVDrips to SVCD's, do I still use unfilter?

WarpEnterprises
31st July 2002, 07:51
Unfilter is exactly made for that purpose.
But use it only if the picture looks unsharp, because by sharpening unnecessarily you need more bitrate afterwards.

iago
19th October 2002, 13:07
Up! UnFilter back into the scene! ;)

@Tom,

Recently I've been experimenting using UnFilter with both (+,+) and (-,-) settings in various DVD test rips. I have a few questions I'm still looking the answers for and I'd be very glad if I get some reply directly from the author of this great filter ;).

If you remember the "lumi-masking" thread in the XviD forum, it was discussed that using UnFilter (somehow ;)) "helped" solving the black-blocking issue. I guess this may be due to some darkening effect introduced by UnFilter with both + and - settings. Can you confirm/reproduce such a darkening effect introduced by UnFilter?

Also, the issue of vertical bars with even some light settings such as UnFilter(5,5) seem to be more or less but consistently appearing in almost all my encodes with many different sources. Is it a bug or actually related to the sharpness/EE of the source?

Finally, I get some thin light lines at all four sides of the image when using UnFilter, seeming to be regardless of the resizing method and resizing parameters I use. Any ideas on that?

best regards,
and thanks again for your great filter,
iago

iago
19th October 2002, 14:00
@Tom

To be more specific:

* darkening effect -> both when softening and sharpening

* vertical bars -> when sharpening

* thin light lines on all four sides of the frames -> when softening (especially)

regards,
iago

trbarry
19th October 2002, 14:07
iago -

I have absolutely no idea why UnFilter helps with the lumi masking problem, though enough people have confirmed it that I can't argue.

I don't think unfilter darkens anything. If so, that would be a bug. But, if it turned out that UnFilter was slightly darkening everything, should I fix it? Or leave it alone to help with the lumi problem? ;)

I suspect the vertical bars are UnFilter sharpening some cyclical compression (block?) artifact that is already in the source material but have no way to prove that. The only thing I can say here is be careful not to over sharpen. I've previously searched long and hard to see if UnFilter was doing something wrong in this area but could not find anything.

Could you post a pic with the light lines at the edge? And what release are you using? I think there is version info if you right click on the dll.

- Tom

iago
19th October 2002, 14:47
@Tom,

First, thanks for the quick reply and your interest.

* The UnFilter.dll version is 0.0.1.1, dated 29.06.2002.

* The (slight) darkening effect of UnFilter is certain imho (and I can also post screenshots for comparison from many different test rips to prove it), but as you said it would be much better to leave this effect "as is" imho ;), since it is really very helpful against one of the ugliest problems of the encoding scene -> black-blocking! :p

* I have attached a sample image with light lines at edges (UnFilter(-10,-10) / XviD / BicubicResize(640,352,0,0.5) / MPEG2DEC2.dll / avisynth 2.06)

regards,
iago

iago
19th October 2002, 15:34
Sorry,

The sample image with light thin lines at edges is attached to this post.

regards,
iago

iago
21st October 2002, 08:56
Tom,

Any ideas on these light lines at edges (or the UnFilter.dll version I use)?

iago

trbarry
21st October 2002, 14:29
iago -

Sorry, I can't even see the light edges, but maybe that is my image preview on this machine with white borders around it.

But there is a newer version 0.0.1.2 (from July 2) that fixes a couple things when using low parm values. You might try that first.

www.trbarry.com/UnFilter.zip

- Tom

iago
21st October 2002, 16:01
-> Sorry, I can't even see the light edges, but maybe that is my image preview on this machine with white borders around it. (trbarry)

Tom,

It's OK, with the 0.0.1.2 version I don't see them light edges either! ;)

regards,
iago

trbarry
21st October 2002, 17:14
Ha! I weasled out of another one! ;)

- Tom