PDA

View Full Version : Denoising/Increasing compressibility with BilinearResize()


JohnMK
15th June 2003, 10:09
Let's say I want to gain some compressibility. BilinearResize is a bit blurrier than other resizers given its anti-aliasing nature, and enhances compressibility. Wouldn't it be better to use BilinearResize than C3D or another denoiser/smoother, if speed is valuable, for the purpose of smoothing/gaining compressibility?

bilu
15th June 2003, 11:22
That's what MipSmooth is all about: :)

http://forum.doom9.org/showthread.php?s=&threadid=53548

without killing too much detail as Bilinear alone could have made.

Bilu

sh0dan
15th June 2003, 11:52
My personal preference is to use lanczos/bicubic resizing and use filters to gain compressability.

Piper
16th June 2003, 19:09
As have I. Recently however I've been using BiCublinResize in place of Lanczos, but not for increased compressibility (although it may be minor side effect) but because I like how it looks when downsizing after TomsMoComp when compared to the other common resize filters.

I would be interested in a general compressibility comparison with BiCublin and others however.

DDogg
17th June 2003, 16:09
Don't forget undot() and Deen(), used with Lanzos or bicubic if it is appropriate for your source. I get an average reduction of 3 points of Q in CCE without any major side effects video quality wise with only a small speed decrease.

mf
17th June 2003, 17:42
"Oops I did it again" :D

I made another AVISynth function that utilizes masks. This one tries to do what JohnMK describes, and is as usual horribly slow at it :p. It resizes detail areas with LanczosResize, and nondetail areas with BilinearResize, with configurable sharpness. It's a completely untested concept, I just whacked it together in no-time. So if anyone's interested just test it, I won't.


Here it is, HybridResize! :D
http://mf.onthanet.com/avisynth/HybridResize-0.1.avs

Usage example:
Import("HybridResize-0.1.avs")
HybridResize(320, 240)

Parameters:
sharpness - controls the resize sharpness. 0-255, default 255.

Dependencies: MaskTools.

Have fun testing!

Piper
17th June 2003, 18:08
Nice. I look forward to trying that.

Is this not the same concept that Bicublin uses with BiCubic & BiLinear? Adjusting sharpness is a nice feature add as well.

mf
17th June 2003, 18:27
Originally posted by Piper
Nice. I look forward to trying that.

Is this not the same concept that Bicublin uses with BiCubic & BiLinear? Adjusting sharpness is a nice feature add as well.
I thought Bicublin used Bicubic sizing for luma and bilinear for chroma, I could be wrong though. Because of some crazy chroma lag bug in EdgeMask only luma is processed, and chroma is simply copied from the LanczosResize.

sh0dan
17th June 2003, 18:34
@Piper/mf: mf is right about bicublin. It does however use a simpler algorithm for scaling, which doesn't provide the same level of filtering as AviSynth - thus greater speed - sometimes at the cost of subjective quality.

It is much more similar to mSmooth. I don't expect this to give much different compression results - as the soft areas are quite smooth - even with lanczos. You should try using msmooth to generate a mask for you, instead of using the resizer.

mf
17th June 2003, 18:44
Originally posted by sh0dan
It is much more similar to mSmooth. I don't expect this to give much different compression results - as the soft areas are quite smooth - even with lanczos. You should try using msmooth to generate a mask for you, instead of using the resizer.
Yeah, I don't expect miracles either, if you have looked inside my avs you should have seen my comment "Completely untested, probably totally useless." :p. It was just a crazy idea I had which I impulsively implemented.

mf
17th June 2003, 21:19
Ok, hikke has done some testing for me. Mind you, it's on upsizing, we don't know anything yet about downsizing.

20:09 <@hikke> Lancozresize: 9.16 MB (9,609,216 bytes), Hybridresize: 8.28 MB (8,687,616 bytes)

(that's constant quant 2)

20:11 <@hikke> lancoz has more details (divx3.11 errors), hybrid is nicer to eye, because those errors at stable surfaces aren't so visible

20:36 <@hikke> done that. hybridvlbe - hybridxvid = Total Average PSNR: 40.81

20:37 <@hikke> lanczosvlbe - lanczosxvid = Total Average PSNR: 40.69

20:37 < DeathWolf> so hybrid is better in the end, seems like it's worth it
20:37 < DeathWolf> better comp, better visual qual
20:37 < DeathWolf> all good

Seems nice, so far. Especially since my idea spawned in 10 seconds and it took me 10 minutes to write the script function. Hikke said to test downsizing tomorrow.

JohnMK
18th June 2003, 00:36
A 'HybridResize.dll' would be really cool. :D

Just testing it now, it appears to look really good on a downsize. I don't really have an eye for these things, but at the very least -- it looks good to me. Speed is a little slow, but I hope if this filter becomes popular, maybe some attention would happen here after the filter is stable enough.

Further testing has shown HybridResize gives me almost as much compressibility as BilinearResize. Very impressive. Hopefully that's the desired effect.

Compressibility results (higher number == higher compressibility) for the new James Bond "Die Another Day":

Bilinear: 59%
Hybrid: 57%
Bicubic: 52%
Lanczos: 49%

Yet further testing: the downsized image is blurry where it counts, unfortunately. Almost indiscernable from bilinear.

mf
18th June 2003, 12:04
Originally posted by JohnMK
Yet further testing: the downsized image is blurry where it counts, unfortunately. Almost indiscernable from bilinear.
I was too careful with the mask. I've now made a new version which should be a lot more aggressive (= sharp). I also added a new parameter:
reverse - soft resize on edges - true/false - default false

You can get it here:
http://mf.onthanet.com/avisynth/HybridResize-0.2.avs

(after hours of pain and agony I finally managed to upload a 958 byte textfile to my ftp server via commandline ftp -_-)

Didée
18th June 2003, 12:50
Originally posted by mf
I also added a new parameter:
reverse - soft resize on edges - true/false - default false Ah!
This I wanted to suggest - but when I refreshed this page, you already had it done...
"Inverse sharpening" is something that I've had on my mind for quite some time now. After denoising, usually some of the fine details disappear, and the remaining fine details get softened out. Trying to compensate for that by normal sharpening is not a good idea, because the hard edges will get oversharpened then.
But I never got a final script done, because I was always aware of a flaw in the concept, when it is done with layering: The "mixing" of a sharp and a soft version is not correct. Try to layer some blur(1.3).blur(1.3) with some sharpen(1.0) by 50%, and you see what I mean.
To get the "inverse sharpening" more correct, it would be necessary to perform the strength of the sharpening according to the "edge value" of every pixel in the edge mask. But to do that with AviSynth scripting would be very complex, and extremly sluggish. We'd need a plugin for that ...
However, when working within small ranges of sharpening/blurring, the difference might be hard to notice at all.

- Didée

Kurosu
18th June 2003, 13:23
With the available and most commonly used tools, layer("add") in RGB32 already does such job if you properly scale the edgemask and perform a strong sharpening. If I remember well, mode "add" does:

(clip2_alpha * strength)
------------------------ * (clip2 - clip1)
256
output =-------------------------------------------- + clip1
256
(256-(clip2_alpha * strength)/256)*clip2 - (clip2_alpha * strength/256)*clip1
= -------------------------------------------------------------------------
256

If you use edgemask as clip2_alpha, source as clip2 and sharpened source as clip1, you therefore get a weighed merge between sharpened picture and original, giving you a sharpening effect depending on edge value.

geoffwa
18th June 2003, 14:26
@mf

The Avisynth filter collection has a newer YV12 version of MaskTools available. Does this work with your scripts or is it borked in some weird and wonderful manner? (getting tired of playing colorspace hopscotch)

Kurosu
18th June 2003, 14:43
Originally posted by geoffwa
The Avisynth filter collection has a newer YV12 version of MaskTools available.
Where did you see that? 8-P

trbarry
18th June 2003, 14:43
My personal preference is to use lanczos/bicubic resizing and use filters to gain compressability.

Me too. But for downsizing I'll still use SimpleResize just because it's faster, and then add filters if I need them.

- Tom

geoffwa
18th June 2003, 15:29
Originally posted by Kurosu
Where did you see that? 8-P

Argh nOOb post! :D
(my bad)

r6d2
28th June 2003, 06:07
Originally posted by DDogg
Don't forget undot() and Deen(), used with Lanzos or bicubic if it is appropriate for your source. I get an average reduction of 3 points of Q in CCE without any major side effects video quality wise with only a small speed decrease.

Hi @DDogg,

I just installed 2.52 and attempted to follow your suggestion, but it seems that these filters are only for YV12... Is there a way to use them with 2.52 and CCE?

Thanks in advance.

Wilbert
28th June 2003, 13:57
http://www.avisynth.org/index.php?page=Section+3%3A+Filters%2C+plugins+and+colorspaces#q3.6

r6d2
28th June 2003, 16:42
Originally posted by Wilbert
http://www.avisynth.org/index.php?page=Section+3%3A+Filters%2C+plugins+and+colorspaces#q3.6
Thanks @Wilbert,

I had read that page before posting and I just don't get it. Sorta confused :confused:

The YV12 FAQ says that DVDs are in YV12, and that a conversion is needed for YV12 -> YUY2 -> YV12 in CCE. So it would just seem that, before the conversion line DVD2SVCD adds to the script, everything is/should be in YV12.

So, using undot() and deen() is straightforward. Is this that simple? Just insert the filters before the ConvertToYUY2 command?

Please confirm. I cannot believe it's that easy.

Wilbert
28th June 2003, 16:54
So, using undot() and deen() is straightforward. Is this that simple? Just insert the filters before the ConvertToYUY2 command?
Yup. Remember mpeg2dec3.dll outputs YV12 (while mpeg2dec.dll for AviSynth v2.08 outputs YUY2).

WILLIS
3rd February 2010, 15:31
hey mf nice work on the filter. Im interested in giving this resize a try but cant seem to find where to grab your filter from...can someone provide me with an updated download link? thx

StainlessS
24th October 2010, 15:36
@Willis

http://mf.creations.nl/avs/functions/