digitalFAQ.com Forums [Archives]

digitalFAQ.com Forums [Archives] (http://www.digitalfaq.com/archives/)
-   Avisynth Scripting (http://www.digitalfaq.com/archives/avisynth/)
-   -   SansGrip Filters: FluxSmooth (http://www.digitalfaq.com/archives/avisynth/1597-sansgrip-filters-fluxsmooth.html)

SansGrip 11-16-2002 09:13 PM

FluxSmooth
 
Here's a new spatio-temporal smoother I wrote today based on ideas that came to me developing NoMoSmooth.

The source code is available. Here's the description from the documentation:

Quote:

One of the fundamental properties of noise is that it's random. One of the fundamental properties of motion is that it's not. This is the premise behind FluxSmooth, which examines each pixel and compares it to the corresponding pixel in the previous and last frame. Smoothing occurs if both the previous frame's value and the next frame's value are greater, or if both are less, than the value in the current frame.

I like to call this a "fluctuating" pixel, then I like to wipe that pixel from existence by averaging it with its neighbours. This is (by default) done in a spatio-temporal manner, in that for each fluctuating pixel its 8 immediate spatial neighbours as well as its 2 temporal neighbours (the abovementioned corresponding pixel from the previous and next frames) are considered for inclusion in the average. If the value of each pixel is within the specified threshold, it is included. If not, it isn't.

This filter seems to remove almost all noise from low-noise sources (such as DVD) and a lot of noise from high-noise sources (such as cable TV captures), while maintaining a good amount of detail.

The speed at which it operates depends upon the amount of noise in the clip.
As usual your mileage may vary. This filter is unrelated to flux capacitors, which enable one to travel temporally.

Edit: Removed links to old version.

kwag 11-17-2002 12:01 AM

Hi SansGrip,

So this filter supercedes NoMoSmooth?

Thanks,
-kwag

kwag 11-17-2002 12:04 AM

Re: FluxSmooth
 
Quote:

Originally Posted by SansGrip
This filter is unrelated to flux capacitors, which enable one to travel temporally.

:lol: Remember, on the latest version, we don't need to accelerate to 88MPH :) :wink:

-kwag

kwag 11-17-2002 12:32 AM

FluxSmooth Sample
 
To keep up with the tradition ;) , here's a sample with FluxSmooth+Blockbuster:
http://mpeg.0catch.com/test6-flux-smooth-LBR.m1v
I use default parameters with the filter ( FluxSmooth() )
Sample encoded with the LBR template at CQ_VBR value of 27. Average bit rate is 610Kbps. It's 11 seconds, and file size is 932KB.

-kwag

jorel 11-17-2002 01:03 AM

help please,the links to download don't work SansGrip,help.

:cry: :cry: :cry:

kwag 11-17-2002 01:05 AM

Quote:

Originally Posted by jorel
help please,the links to download don't work SansGrip,help.

:cry: :cry: :cry:

I posted a link for you in your previous post.

-kwag

SansGrip 11-17-2002 09:59 AM

Quote:

Originally Posted by kwag
So this filter supercedes NoMoSmooth?

Nope. NoMo is motion adaptive, Flux isn't.

In other words, with NoMo you can use very strong spatial smoothing on areas of motion to improve compressibility (though you will very occasionally notice some artifacts if you look carefully). Flux is just a "noise remover".

Flux should be a lot more gentle than NoMo if maintaining detail is a priority.

SansGrip 11-17-2002 09:59 AM

Re: FluxSmooth
 
Quote:

Originally Posted by kwag
Remember, on the latest version, we don't need to accelerate to 88MPH :)

I think NoMo could do with some acceleration... :D

SansGrip 11-17-2002 10:00 AM

Quote:

Originally Posted by jorel
help please,the links to download don't work SansGrip,help.

I've had several posts about this from Doom9 too. They all work fine for me. The server must've gone down for a while.

SansGrip 11-17-2002 12:21 PM

New version
 
Here's version 0.2 with a minor bugfix, some optimizations, and support for Avisynth 2.5/YV12. I also changed the defaults as I found them too high.

Edit: Removed links to old version.

SansGrip 11-17-2002 12:22 PM

Re: FluxSmooth Sample
 
Quote:

Originally Posted by kwag
To keep up with the tradition ;) , here's a sample with FluxSmooth+Blockbuster

How do you find it compares to other tests, wrt both quality and file size?

kwag 11-17-2002 04:40 PM

Re: FluxSmooth Sample
 
Quote:

Originally Posted by SansGrip
Quote:

Originally Posted by kwag
To keep up with the tradition ;) , here's a sample with FluxSmooth+Blockbuster

How do you find it compares to other tests, wrt both quality and file size?

I like the FluxSmooth+Blockbuster better than NoMoSmooth+Blockbuster.
The file size difference is almost none. In a 1 minute, 30 second file prediction test, the difference is 16KB larger on the NoMoSmooth+Blockbuster. And that's negligible. However, I can see a MUCH better artifact reduction with the FluxSmooth+Blockbuster.
Here's a sample of what the complete 120 minute movie looks like on one CD-R. I encoded it last night with FluxSmooth+Blockbuster: http://mpeg.0catch.com/test7-fluxsmooth-blockbuster.m1v

-kwag

edmund 11-17-2002 05:37 PM

hey kwag what does your script look like??

kwag 11-17-2002 05:54 PM

Quote:

Originally Posted by edmund
hey kwag what does your script look like??

Like this ( the one I'm using on the LBR ) :

FluxSmooth()

######## Auto Strength, proportional strength depending on resolution #####
## Remove only one "#" on front of the resolution that matches your encoding.

BB_Resolution = 352*240
#BB_Resolution = 352*480
#BB_Resolution = 528*480
#BB_Resolution = 544*480
#BB_Resolution = 704*480

BB_StrengthConstant = 352 * 240 * 20 # Base strength
StrengthValue = round (BB_StrengthConstant / BB_Resolution)
Blockbuster( method="noise", detail_min=1, detail_max=10, lv=1 ) # Apply noise if complexity is <= 10%.
Blockbuster( method="sharpen", detail_min=20, detail_max=90, strength=StrengthValue) # Sharpen only if complexity is >= 20% AND <=90%.

# The last ~10% is left untouched (pass-through), to avoid sharpening highest frequency components ( Peak artifacts, sharpest edge, etc. )
##
################## End Auto Strength ####################



-kwag

SansGrip 11-17-2002 06:14 PM

Re: FluxSmooth Sample
 
Quote:

Originally Posted by kwag
However, I can see a MUCH better artifact reduction with the FluxSmooth+Blockbuster.

That's interesting. What settings? The defaults for 0.1 were quite strong. How do you find Flux wrt speed?

Quote:

Originally Posted by kwag
Here's a sample of what the complete 120 minute movie looks like on one CD-R. I encoded it last night with FluxSmooth+Blockbuster

That looks really good. I had no idea you could get such good results on a single disc...

kwag 11-17-2002 06:31 PM

Re: FluxSmooth Sample
 
Quote:

Originally Posted by SansGrip
Quote:

Originally Posted by kwag
However, I can see a MUCH better artifact reduction with the FluxSmooth+Blockbuster.

That's interesting. What settings? The defaults for 0.1 were quite strong. How do you find Flux wrt speed?

I used the default. Just FluxSmooth()
But I didn't do any benchmarks 8O . Sorry!, I'm so amazed at the results, that I really don't care about encoding speed :) .
I'm encoding on a P4 @1.6Ghz, and at 352x240, it's about .9 real-time.

Quote:

Originally Posted by kwag
Here's a sample of what the complete 120 minute movie looks like on one CD-R. I encoded it last night with FluxSmooth+Blockbuster

Quote:

That looks really good. I had no idea you could get such good results on a single disc...
I have to encode "The Green Mile" ( 180 minutes ) with the LBR AND your filters :D
Last time I did, it looked good, considering it was encoded for one CD-R , but your filters were not around. That should be a good "stress" test to put your filters through :lol:
Also," Pearl Harbor" is also ~180 minutes, and was also encoded on one CD-R. I'll pull out my "Green Mile" tonight and run it again with your filters.
We'll see the results late late tonight or tomorrow ;)

-kwag

SansGrip 11-17-2002 06:46 PM

Re: FluxSmooth Sample
 
Quote:

Originally Posted by kwag
I used the default. Just FluxSmooth()

Ok, well, when you do your next encode you might want to specify the old defaults as parameters then:

FluxSmooth(temporal_threshold=7, spatial_threshold=7)

Quote:

Originally Posted by kwag
I have to encode "The Green Mile" ( 180 minutes ) with the LBR AND your filters :D

hehehe I'm going to have to try an encode with LBR. I've not played with it yet.

kwag 11-17-2002 06:53 PM

Re: FluxSmooth Sample
 
Quote:

Originally Posted by SansGrip
Quote:

Originally Posted by kwag
I used the default. Just FluxSmooth()

Ok, well, when you do your next encode you might want to specify the old defaults as parameters then:

FluxSmooth(temporal_threshold=7, spatial_threshold=7)

Will do. Just starting the rip now :D

Quote:

Originally Posted by kwag
I have to encode "The Green Mile" ( 180 minutes ) with the LBR AND your filters :D

Quote:

hehehe I'm going to have to try an encode with LBR. I've not played with it yet.
When you do, don't use the default CQ_VBR setting. Use the file prediction formula to adjust it, so that space and quality are optimized.
And let us know your results ;)

-kwag

jorel 11-17-2002 07:11 PM

@SansGrip

why don't you put the FluxSmooth-01.zip here,please?
i can't download it from your link! :(

SansGrip 11-17-2002 07:12 PM

Re: FluxSmooth Sample
 
Quote:

Originally Posted by kwag
When you do, don't use the default CQ_VBR setting. Use the file prediction formula to adjust it, so that space and quality are optimized.

Ok, I'll do a search for that.

By the way, I just did a couple of test clips with the 528x480 template (the first of yours I've ever tried) with FluxSmooth and Blockbuster and it looks fantastic. I'm going to read up on the formula and do a two-disc of American Pie :).

By the way, I'm playing these on my Panasonic CV52 and the clips worked just fine. I've had bad luck with VBR movies in the past, though, with corruption problems around what I believe to be the middle of the disc. I'm thinking this might have something to do with the minimum bitrate... What do you think?

SansGrip 11-17-2002 07:13 PM

Quote:

Originally Posted by jorel
why don't you put the FluxSmooth-01.zip here,please?
i can't download it from your link! :(

That's very odd. How would I attach it to a message here?

kwag 11-17-2002 07:18 PM

Re: FluxSmooth Sample
 
Quote:

Originally Posted by SansGrip
Quote:

Originally Posted by kwag
When you do, don't use the default CQ_VBR setting. Use the file prediction formula to adjust it, so that space and quality are optimized.

Ok, I'll do a search for that.

http://www.kvcd.net/forum/viewtopic.php?t=1369 ;)

Quote:

By the way, I just did a couple of test clips with the 528x480 template (the first of yours I've ever tried) with FluxSmooth and Blockbuster and it looks fantastic. I'm going to read up on the formula and do a two-disc of American Pie :).
:mrgreen:

Quote:

By the way, I'm playing these on my Panasonic CV52 and the clips worked just fine. I've had bad luck with VBR movies in the past, though, with corruption problems around what I believe to be the middle of the disc. I'm thinking this might have something to do with the minimum bitrate... What do you think?
Yes. I had to set mine to 300Kbps MIN. Lower than that, it doesn't play smooth. And on completely black scenes, it would sometimes stutter. Worse than slow motion. So it needs at least a low constant bit stream to stay in sync. I set all templates to MIN=300Kbps.

-kwag

kwag 11-17-2002 07:19 PM

Quote:

Originally Posted by SansGrip
Quote:

Originally Posted by jorel
why don't you put the FluxSmooth-01.zip here,please?
i can't download it from your link! :(

That's very odd. How would I attach it to a message here?

Is it ok if I put your .zip files here for people to download?

-kwag

SansGrip 11-17-2002 07:24 PM

Quote:

Originally Posted by kwag
Is it ok if I put your .zip files here for people to download?

Absolutely. It's always best to have more than one download source.

(Though I also always attach them to my Doom9 announcements, so in a pinch people can get them there too).

SansGrip 11-17-2002 07:26 PM

Re: FluxSmooth Sample
 
Quote:

Originally Posted by kwag
Yes. I had to set mine to 300Kbps MIN. Lower than that, it doesn't play smooth.

Strangely, this was CQ 500-2500, padded. I'm wondering if my player needs a higher minimum bitrate.

kwag 11-17-2002 07:32 PM

Here they are:

http://mpeg.0catch.com/FluxSmooth-0.2.zip
http://mpeg.0catch.com/NoMoSmooth-0.1a.zip
http://mpeg.0catch.com/Blockbuster-0.4.zip

-kwag

SansGrip 11-17-2002 07:45 PM

Quote:

Originally Posted by kwag
Here they are

Thanks :).

kwag 11-17-2002 07:52 PM

I am currently ripping "The Green Mile". No need to wait for the complete movie to encode. I'll run the file prediction formula, to target the movie for one CD-R with the filters, and I'll post the sample and script so everyone can take a look how it will look once encoded.

-kwag

jorel 11-17-2002 08:02 PM

big thanks
 
Thanks Kwag and SansGrip,now i can download all(i'm doing this)
came so fast!

8) :wink: :!:

jorel 11-17-2002 08:07 PM

@ SansGrip and Kwag
don't want to bore....
but read this and post your opinion there,please!
thanks in advance! :)

http://www.kvcd.net/forum/viewtopic....b57286e7b027f7

:?: what do you think?

kwag 11-17-2002 09:16 PM

Well, here it is. This is the way "The Green Mile" will look on a single CD-R. Remember that when I did the LBR I clearly specified that this was a "Convenience" template, for travelers, etc, to watch on small screens. So quality is way below a VCD. On small portable DVD players, it is perfectly watchable.
So here it is: http://mpeg.0catch.com/green-LBR-nom...fluxsmooth.m1v
That's the way it will look. The complete three hours on a 80 minute CD-R. Audio at 112Kbps, and I did set the MAX bit rate on the LBR to 1,150Kbps. That's it. Good for some, crap for others :lol:

Here's the script I used:


LoadPlugin("C:\encoding\MPEG2DEC.dll")
LoadPlugin("C:\encoding\nomosmooth.dll")
LoadPlugin("C:\encoding\fluxsmooth.dll")
LoadPlugin("C:\encoding\blockbuster.dll")
mpeg2source("K:\THE_GREEN_MILE\VIDEO_TS\mile.d2v")
BilinearResize(336,192,45,0,630,480)

nomosmooth()
FluxSmooth(temporal_threshold=7, spatial_threshold=7)

######## Auto Strength, proportional strength depending on resolution #####
## Remove only one "#" on front of the resolution that matches your encoding.


BB_Resolution = 352*240
#BB_Resolution = 352*480
#BB_Resolution = 528*480
#BB_Resolution = 544*480
#BB_Resolution = 704*480

BB_StrengthConstant = 352 * 240 * 20 # Base strength
StrengthValue = round (BB_StrengthConstant / BB_Resolution)
Blockbuster( method="noise", detail_min=1, detail_max=10, lv=1 ) # Apply noise if complexity is <= 10%.
Blockbuster( method="sharpen", detail_min=20, detail_max=90, strength=StrengthValue) # Sharpen only if complexity is >= 20% AND <=90%.

# The last ~10% is left untouched (pass-through), to avoid sharpening highest frequency components ( Peak artifacts, sharpest edge, etc. )
##
################## End Auto Strength ####################


AddBorders(8,24,8,24)


-kwag

SansGrip 11-17-2002 09:40 PM

Quote:

Originally Posted by kwag
Well, here it is.

It looks surprisingly good. Quite a bit of mosquito noise, but that's to be expected considering just how much data you're squeezing onto a CD-R.

At the moment I'm trying out file size prediction and KVCDx3, and all this mucking around with a calculator made me think it might be nice to have a GUI tool to do most of this for us: enter movie length, sample length, scaling factor, disc size, number of discs, audio bitrate, etc. and tell us the maximum size the encoded sample can be in kb. We can then play with CQ levels and bitrates etc. until we're as close as possible to that target.

Does something like this already exist, or should I fire up VisualStudio? ;)

kwag 11-17-2002 09:48 PM

Quote:

Originally Posted by SansGrip
Quote:

Originally Posted by kwag
Well, here it is.

It looks surprisingly good. Quite a bit of mosquito noise, but that's to be expected considering just how much data you're squeezing onto a CD-R.

At the moment I'm trying out file size prediction and KVCDx3, and all this mucking around with a calculator made me think it might be nice to have a GUI tool to do most of this for us: enter movie length, sample length, scaling factor, disc size, number of discs, audio bitrate, etc. and tell us the maximum size the encoded sample can be in kb. We can then play with CQ levels and bitrates etc. until we're as close as possible to that target.

Does something like this already exist, or should I fire up VisualStudio? ;)


YES YES :lol: Fire it up :lol:
:lol: We are ALL in sync :lol: . Rendalunit send me about two hours ago a small C command line program to do the manual steps automatically. But we really need a GUI. Here's his code, which does compile and work:

// This is a very simple program to calculate what the final file size of the
// 100 second sample should be using the file size prediction method (thnks Kwag
// and Ozzi!). The estimated audio file size by Headac3he is subtracted from the total space
// available to determine how much video space is available. This program assumes
// you're using 80 min cdrs (if not change the const cd_size value)
// This program will crash if the wrong data type is entered:-(

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
const long long cd_size = 800000000;
const long convert_to_mb = 1000000;
float framerate, error_margin;
double sample_video_size;
int number_of_cds;
long total_movie_frames, est_audio_size;
long long video_space;

printf("enter estimated audio size in mb >");
scanf("%d", &est_audio_size);
printf("%dmb audio \n\n",est_audio_size);
est_audio_size = est_audio_size * 1000000;

printf("enter the number of 80 min cds to use >");
scanf("%d", &number_of_cds);
printf("%d cd(s) to burn \n\n",number_of_cds);

video_space = (cd_size * number_of_cds)-est_audio_size;
printf("there's %lldmb space for video \n\n",video_space / convert_to_mb);

printf("enter total frames of video >");
scanf("%d", &total_movie_frames);
printf("%d total frames \n\n",total_movie_frames);

printf("enter the framerate >");
scanf("%f", &framerate);
printf("%.2f frames per second \n\n",framerate);

printf("enter percent error margin (5 is suggested, enter 0 for none) >");
scanf("%f",&error_margin);
printf("error margin >%.1f percent \n\n",error_margin);
error_margin = (100 - error_margin) / 100;

sample_video_size = (video_space / ((total_movie_frames/framerate) /100)) * error_margin;

printf("the target sample size should be about %.1fmb \n", sample_video_size / convert_to_mb);
printf("\npress <enter> to end..");
getchar();
getchar();
return 0;
}

-kwag

edmund 11-17-2002 10:16 PM

hey kwag.. i have a problem.. every time i try to use the filters it says in tmpgenc that i need to convert to yuy2 formate.. why is that and if i really need to.. do i put the ConvertoYUY2() right before the nomosmooth() function??
thanks

SansGrip 11-17-2002 10:21 PM

Quote:

Originally Posted by edmund
hey kwag.. i have a problem.. every time i try to use the filters it says in tmpgenc that i need to convert to yuy2 formate

Forgive me for answering a post addressed to kwag, but I happened to read it and know the answer ;).

Yes, almost all Avisynth plugins work only in YUY2 mode. If you're using a source other than YUY2 you'd be best to do a ConvertToYUY2() straight after the ...Source line. In other words, if you're pulling in an RGB AVI:

Quote:

AviSource("interesting_clip.avi")
BlahFilter()
SuperResize()
AwesomeSmoother()
etc., stick the ConvertToYUY2() between AviSource and BlahFilter. This way all the filters get to work in YUY2 mode and everyone's happy.

edmund 11-17-2002 10:24 PM

hey thanks alot SansGrip!!

SansGrip 11-17-2002 10:25 PM

Quote:

Originally Posted by kwag
YES YES :lol: Fire it up :lol:
:lol: We are ALL in sync :lol: . Rendalunit send me about two hours ago a small C command line program to do the manual steps automatically. But we really need a GUI.

heheh ok, I'll start on it tonight and will hopefully have something ready tomorrow. It'll be in C#, though, so it'll require the .NET runtime.

.NET's the future anyway, so you might as well download it now :twisted:.

Quote:

Here's his code, which does compile and work
Cool, that's almost exactly what I was thinking as far as the back end goes. Nice to know we're all on the same wavelength :).

Jellygoose 11-18-2002 04:19 PM

Hi kwag, hi SansGrip...

I have read this whole topic and also downloaded the samples, which i find pretty damn awesome :wink: ...
My question is just why ya'll always limit the testing to one resoulution... See I really like higher resolutions better, at least standard SVCD resolution seems good to me...
No offend, kwag your KVCD LBR Template DOES look awesome on small TV-Sets... I wouldn't dare to put a 180 min. movie like The Green Mile on one CD-R, but I'm interested in seeing the effects of FluxSmooth and Blockbuster on one of your higher resolution templates like 704x480 or 480x480 or the KVCD x3 Templates...
Honestly I think you can use your KVCDx2 (704x480) templates WITHOUT these filters for at least 105 minutes of high quality video (still on a normal TV-Screen) on ONE CD-R... How far could you tweak that with these filters?
Why don't you try that out and show us the results?

Best Regards guys...

kwag 11-18-2002 05:58 PM

Quote:

Originally Posted by Jellygoose
Hi kwag, hi SansGrip...

I have read this whole topic and also downloaded the samples, which i find pretty damn awesome :wink: ...
My question is just why ya'll always limit the testing to one resoulution... See I really like higher resolutions better, at least standard SVCD resolution seems good to me...
No offend, kwag your KVCD LBR Template DOES look awesome on small TV-Sets... I wouldn't dare to put a 180 min. movie like The Green Mile on one CD-R, but I'm interested in seeing the effects of FluxSmooth and Blockbuster on one of your higher resolution templates like 704x480 or 480x480 or the KVCD x3 Templates...
Honestly I think you can use your KVCDx2 (704x480) templates WITHOUT these filters for at least 105 minutes of high quality video (still on a normal TV-Screen) on ONE CD-R... How far could you tweak that with these filters?
Why don't you try that out and show us the results?

Best Regards guys...

Hi Jellygoose,

The 352x240 resolution is IDEAL to test filters, just because of that. Low resolution. The higher resolutions don't need that much of "sharpen" filters, but they do need the Blockbuster filter, to remove DCT blocks on black areas. That's one of the reasons I wrote the script that automatically lowers the "sharpen" value, the more you increase the resolution ;)
So on 704x480, the sharpen is actually very low, but the "Noise" method is in there, doing all it's work.

-kwag

SansGrip 11-19-2002 01:40 AM

Just a quick update:

I was puzzled by why I had to reduce the default thresholds so much in the last release I made, so I took a look at the code and spotted a pretty major bug that was messing up the smoothing. I fixed it and changed some things around, and now it's significantly faster and you can use much higher thresholds (exactly how high I'll leave to the testers...).

On my system it runs on a 720x480 clip at about 17-18fps, that's roughly 6-7fps faster than Convolution3D in preset="movieHQ" mode (but bear in mind its performance changes depending on the amount of noise in the clip -- this was with American Pie, a fairly clean DVD). It also, IMO, smooths more where it's needed and less where it isn't, resulting in better noise reduction and more details kept :D. I was surprised at just how destructive C3D can be when you look real close. No wonder it does such good things for compression...

Of course, I might be slightly biased ;). Anyway, it's very late now and I need to get to bed, but in the morning I'll port the changes over to the YV12 version, update the docs and make a release.

I'm very excited about what I'm seeing from this filter, and I'd really like it if you guys could give this one a good test. I think it might be even better than NoMo, and I'd love to know just how high you can push those thresholds before you start to see unacceptable softening. For me it's pretty darn high, but I won't give any numbers out so I don't influence anyone :).


All times are GMT -5. The time now is 05:04 PM  —  vBulletin © Jelsoft Enterprises Ltd

Site design, images and content © 2002-2026 The Digital FAQ, www.digitalFAQ.com
Forum Software by vBulletin · Copyright © 2026 Jelsoft Enterprises Ltd.