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 17th March 2006, 23:44   #1  |  Link
tin3tin
Registered User
 
tin3tin's Avatar
 
Join Date: Mar 2005
Posts: 365
Bloom filter for film look

I think this could be very useful for making filmlooks:
Bloomfilter/Filtermeister

Couldn't this turn into a nice avisynth filter too? Personally I haven't the C skills needed - but I guess the math part might be a leap ahead?

The FilmMeister manuals looks quite interesting too.

Tin2tin
__________________
DVD slideshow GUI(Freeware).
tin3tin is offline   Reply With Quote
Old 17th March 2006, 23:54   #2  |  Link
Zarxrax
Registered User
 
Join Date: Dec 2001
Posts: 1,169
A bloom is just levels+blur. You can composite this on top of the original with varying transparency settings for a nice look. You can do this with existing avisynth commands.
Zarxrax is offline   Reply With Quote
Old 18th March 2006, 23:33   #3  |  Link
Backwoods
ReMember
 
Backwoods's Avatar
 
Join Date: Nov 2003
Posts: 416


Code:
AVISource("hi.avi")
o=last

AVISource("hi.avi")
Blur(1.58).Blur(1.58).Blur(1.58).Blur(1.58).Blur(1.58).Blur(1.58).Blur(1.58)
Levels(15, .8, 80, 0, 255, coring=false)
e=last

Overlay(o,e,mode="add",opacity=.25)
Just tweak Levels() and Blur() for desired effect. Also I forgot the command to times a function instead of writing it out over and over.
Backwoods is offline   Reply With Quote
Old 19th March 2006, 00:26   #4  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,390
It might not matter too much in this case, because of the rather low opacity setting in Overlay ... however:

Never, never ever make a strong blur by chaining blur() several times. Not only it is slow, but more seriously blur() is not precise enough. Especially chroma will get *very noticeable* distortions.

Use VariableBlur() instead, or simulate it through down&up-bicubicresize (not quite as accurate, but fairly fast):

Code:
function FastGauss(clip clp, float rx, float ry)
{ ox=clp.width()
  oy=clp.height()
  clp.bicubicresize(m4(ox/rx),m4(oy/ry)).bicubicresize(ox,oy,1,0)
}
function m4(float x) {x<16?16:int(round(x/4.0)*4)}
(Could be bloated much more ... multitap resizing for radii > 3.0 aso., but hey...)
__________________
- 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 19th March 2006, 02:26   #5  |  Link
Backwoods
ReMember
 
Backwoods's Avatar
 
Join Date: Nov 2003
Posts: 416


I know I used FastGaussBlur, but I wasn't sure what parameters to use on FastGauss.

With FastGaussBlur there is more of a Bloom effect of glowing edges and Blurx7 seems to hold more detail but not really shine much.

I was thinking of using FastGaussBlur but then forgot to look for it and just went with Blur quickly.

So yes, FastGaussBlur would be better to use.

Code:
AVISource("yea.avi")
o=last

AVISource("yea.avi")
FastGaussBlur(24)
Levels(15, .8, 80, 0, 255, coring=false)
e=last

Overlay(o,e,mode="add",opacity=.25)

function FastGaussBlur(clip clp, float rx, float "ry")
{
ry = default(ry, rx)
rx = rx+1.0
ry = ry+1.0
ox = clp.width
oy = clp.height
oxs1 = int(round(ox/4.0/sqrt(rx))*4)
oys1 = int(round(oy/4.0/sqrt(ry))*4)
oxs2 = int(round(sqrt(ox*oxs1)/4.0)*4)
oys2 = int(round(sqrt(oy*oys1)/4.0)*4)
oxs1 = oxs1<16 ? 16 : oxs1
oys1 = oys1<16 ? 16 : oys1
clp.bicubicresize(oxs1,oys1)
rx>9.0||ry>9.0 ? bicubicresize(oxs2,oys2,0.5,0.25) : last
return bicubicresize(ox,oy,1,0) 
}
Backwoods is offline   Reply With Quote
Old 19th March 2006, 03:56   #6  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,390
I knew I had once posted FastGaussBlur, but couldn't find it ATM

Quote:
With FastGaussBlur there is more of a Bloom effect of glowing edges and Blurx7 seems to hold more detail but not really shine much.
That's because 7*Blur does not as much blurring as it should do. Basically, a chain of 7*Blur(1.0) should result in a standard Gaussian-Blur with radius=7 (or variance=49, hopefully ... tsp? ) However, using chaines of Blur() will "run dead" at some point, where it should do more blurring work, mathematically - but practically can't, because of the small radius and digital rounding (average of 1-2-2 is just 2, etc.)

Quote:
I know I used FastGaussBlur, but I wasn't sure what parameters to use on FastGauss.
Results are rather similar - blurry, but not mathematically exact for big radii.
FastGauss uses radius as parameter, FastGaussBlur uses variance, as does tsp's VariableBlur. Variance = radius^2 resp. radius = sqrt(variance).
Personally, I like much more to think in "radius" than "variance", because radius is the usual way how Gaussian blurring is handled in image editors.

Last note for this long useless post:
There's something interesting about the "precision" of Avisynth's Blur() filter.
Compare an 8fold chain of "Blur(1.0)" with the same 8fold chain of "Blur(1.58)". The former, being a true radius=1 Gaussian Blur, will produce a very noticeable color shift. The latter, being a plain 3*3 average blur, treats chroma correctly.
Then compare both with FastGauss(8,8), FastGaussBlur(64,64), and GaussianBlur(64,64, Y=3,U=3,V=3,border=2), and see all the differences.
Aditionally, check the histograms of all the outputs, it's interesting:
Code:
o = last
blur8gss = o.blur(1.0).blur(1.0).blur(1.0).blur(1.0).blur(1.0).blur(1.0).blur(1.0).blur(1.0)
blur8avg = o.blur(1.58).blur(1.58).blur(1.58).blur(1.58).blur(1.58).blur(1.58).blur(1.58).blur(1.58)
fastg8   = o.FastGauss(8,8)
fastgb8  = o.FastGaussBlur(64,64)
gb8exct  = o.GaussianBlur(64,64,Y=3,U=3,V=3, border=3) # VariableBlur.dll

interleave(o,blur8gss,blur8avg,fastg8,fastgb8,gb8exct) .histogram(mode="levels")
__________________
- 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 4th May 2006, 13:50   #7  |  Link
actionman133
Movie buff & shine
 
Join Date: Jan 2004
Location: Logan, the only hole above ground.
Posts: 257
I know its been a while since this thread has been visited, but I was recently creating a similar filter for this effect, based on similar settings found in the AfterEffects filter.

This what I came up with:

Code:
Function Glow (clip Last, int "radius", int "min", int "max", int "opacity") {

radius = Default (radius, 5)
min = Default (min, 234)
max = Default (max, min + 1)
opacity = Default (opacity, 1.0)

Mask = Levels (min, 1, max, 0, 255, false).ConvertToYUY2 ().\
SpatialSoften (radius, 255, 255).Levels (0, 1, 127, 0, 255, False)
White = Blankclip (Mask).Invert ("Y")

Overlay (Last, White, mask = mask, opacity = opacity)

}
__________________
I'm a boxer who can Bob () & Weave (). I like to Overlay () punches and Blur () his vision to ShowFiveVersions (). My KO punch will always Pulldown ().TimeStretch () and all he will hear is Tone ().
actionman133 is offline   Reply With Quote
Old 4th May 2006, 22:04   #8  |  Link
Backwoods
ReMember
 
Backwoods's Avatar
 
Join Date: Nov 2003
Posts: 416
No sample images?
Backwoods is offline   Reply With Quote
Old 5th May 2006, 02:41   #9  |  Link
actionman133
Movie buff & shine
 
Join Date: Jan 2004
Location: Logan, the only hole above ground.
Posts: 257
I've uploaded two samples to my website here...

http://actionman133.isa-geek.net:808...w/preview.html
__________________
I'm a boxer who can Bob () & Weave (). I like to Overlay () punches and Blur () his vision to ShowFiveVersions (). My KO punch will always Pulldown ().TimeStretch () and all he will hear is Tone ().
actionman133 is offline   Reply With Quote
Old 5th May 2006, 07:31   #10  |  Link
kevin23
Registered User
 
Join Date: Apr 2006
Posts: 10
Quote:
Originally Posted by Didée
I knew I had once posted FastGaussBlur, but couldn't find it ATM
Here is FastGaussBlur


Code:
function FastGaussBlur(clip clp, float rx, float "ry")
{
ry = default(ry, rx)
rx = rx+1.0
ry = ry+1.0
ox = clp.width
oy = clp.height
oxs1 = int(round(ox/4.0/sqrt(rx))*4)
oys1 = int(round(oy/4.0/sqrt(ry))*4)
oxs2 = int(round(sqrt(ox*oxs1)/4.0)*4)
oys2 = int(round(sqrt(oy*oys1)/4.0)*4)
oxs1 = oxs1<16 ? 16 : oxs1
oys1 = oys1<16 ? 16 : oys1
clp.bicubicresize(oxs1,oys1)
rx>9.0||ry>9.0 ? bicubicresize(oxs2,oys2,0.5,0.25) : last
return bicubicresize(ox,oy,1,0) 
}
kevin23 is offline   Reply With Quote
Old 5th May 2006, 22:03   #11  |  Link
Backwoods
ReMember
 
Backwoods's Avatar
 
Join Date: Nov 2003
Posts: 416
Quote:
Originally Posted by actionman133
I've uploaded two samples to my website here...

http://actionman133.isa-geek.net:808...w/preview.html
Very nice.
Backwoods is offline   Reply With Quote
Old 7th May 2006, 00:51   #12  |  Link
actionman133
Movie buff & shine
 
Join Date: Jan 2004
Location: Logan, the only hole above ground.
Posts: 257
Quote:
Originally Posted by Backwoods
Very nice.
Thanks! I've actually gone back and updated it a little bit. Although you can't see it in those examples, SpatialSoften seemed to leave out pixels near the edges of the frame. I've fixed it with Addborders, Soften, then Crop the borders away. It also ensures it ConvertsToYUY2 () for the mask (necessary for SpatialSoften ().

Only bug so far.... still takes 5 seconds to filter a single frame! If anyone knows any efficient way to apply a radial blur, please let me know...

Code:
Function Glow (clip Last, int "radius", int "min", int "max", int "opacity") {

radius = Default (radius, 5)
edges = (radius % 4) == 0 ? radius : radius + 4 - (radius % 4)
min = Default (min, 254)
max = Default (max, min + 1)
opacity = Default (opacity, 1.0)

Mask = ConvertToYUY2 ().Levels (min, 1, max, 0, 255, false)
Mask = Mask.AddBorders (edges, edges, edges, edges).SpatialSoften (radius, 255, 255).Crop (edges, edges, edges * -1, edges * -1).Levels (0, 1, 127, 0, 255, False)
White = Blankclip (Mask).Invert ("Y")

Overlay (Last, White, mask = mask, opacity = opacity, output = "YV12")

}
__________________
I'm a boxer who can Bob () & Weave (). I like to Overlay () punches and Blur () his vision to ShowFiveVersions (). My KO punch will always Pulldown ().TimeStretch () and all he will hear is Tone ().
actionman133 is offline   Reply With Quote
Old 8th May 2006, 10:17   #13  |  Link
Mug Funky
interlace this!
 
Mug Funky's Avatar
 
Join Date: Jun 2003
Location: i'm in ur transfers, addin noise
Posts: 4,547
spatialsoften only gives a box blur IIRC.

try variableblur, as mentioned earlier in the thread. there's also a pretty fast convo filter in masktools that can give you some interesting blur effects.
__________________
sucking the life out of your videos since 2004
Mug Funky is offline   Reply With Quote
Old 9th May 2006, 09:01   #14  |  Link
actionman133
Movie buff & shine
 
Join Date: Jan 2004
Location: Logan, the only hole above ground.
Posts: 257
I know spatialsoften () isn't perfect. It wasn't doing the edges and it was damn slow...

I've actually found that the cubic mode in the box blur filter in VDub is very good at making a glow mask as well and it is very fast. Can I somehow load that into AVISynth to use? LoadVirtualDubPlugin only seems to support external plugins...

PS. Tried VariableBlur (0.3, I think it was) but it refused to load...
__________________
I'm a boxer who can Bob () & Weave (). I like to Overlay () punches and Blur () his vision to ShowFiveVersions (). My KO punch will always Pulldown ().TimeStretch () and all he will hear is Tone ().
actionman133 is offline   Reply With Quote
Old 20th May 2006, 04:15   #15  |  Link
actionman133
Movie buff & shine
 
Join Date: Jan 2004
Location: Logan, the only hole above ground.
Posts: 257
I think this might be the true bloom

I should first say that I should renounce the first function that I posted, as it was a glow filter, one that makes it look like objects were emitting more light, not reflecting light.

This one should be a more accurate bloom. It works similarly to ones previously posted, but changes a couple steps. Rather than simply blending a blurred version of the clip with itself with low opacity, it uses Overlay's "add" mode at full opacity, combined with a mask based on the brightness of the blurred clip. Using "add" guarantees the the clip will only brighten the darker parts of the image, and the mask prevents excessive blooming in dark areas of the image (which normally wouldn't bloom).

NOTE: this has only been tested with YUV data, and it REQUIRES Donald Graft's plugin port of VirtualDub's BoxBlur. Download it at http://www.neuron2.net

threshold: the strength of the bloom. Values from 0-255, default 255. Decreasing the threshold will enhance the bloom effect. Lower values can add a 'dreamy' effect to the clip, but going too low can produce muddy shadows.

radius: increases the size of the bloom. Default is 1/120 of the clip's width.

Code:
Function Bloom (clip Last, int "threshold", int "radius") {

LoadVirtualDubPlugin ("BoxBlur.vdf", "BoxBlur")
radius = Default (radius, Round (Width / 120.0))
threshold = Default (threshold, 255)
threshold = Round (Threshold * 219 / 255.0) + 16

bloom = ConvertToRGB32 ("pc.601").BoxBlur (radius, 3, 1000).ConvertToYV12 (matrix = "pc.601")
bloommask = bloom.Tweak (sat = 0, coring = false).Levels (16, 1, threshold, 0, 255, false)
Overlay (last, bloom, mode = "lighten", mask = bloommask)

}
__________________
I'm a boxer who can Bob () & Weave (). I like to Overlay () punches and Blur () his vision to ShowFiveVersions (). My KO punch will always Pulldown ().TimeStretch () and all he will hear is Tone ().

Last edited by actionman133; 20th May 2006 at 04:17.
actionman133 is offline   Reply With Quote
Old 22nd May 2006, 04:23   #16  |  Link
NormanBates
Registered User
 
NormanBates's Avatar
 
Join Date: Aug 2005
Location: Asylum
Posts: 46
@actionman133
thank you! this works very well for me!

Norman Bates
NormanBates is offline   Reply With Quote
Old 22nd May 2006, 08:17   #17  |  Link
Dark-Cracker
Registered User
 
Dark-Cracker's Avatar
 
Join Date: Feb 2002
Posts: 1,195
work like a charm thank u.
++
__________________

AutoDub v1.8 : Divx3/4/5 & Xvid Video codec and .OGG/.MP3/.AC3/.WMA audio codec.
AutoRV10 v1.0 : Use RealVideo 10 Codec and support 2 Audio Streams and Subtitles.

Dark-Cracker is offline   Reply With Quote
Old 8th July 2013, 03:57   #18  |  Link
MJLives12
Registered User
 
Join Date: Mar 2012
Posts: 29
Color lighting

I'm still new to this, I use gaussresize for speed and mt_lutxy u and v to enhance color (experiemental) for 30p DVDNTSC video or HD downscale to 720X480p (simple resize s fastest to me)

code :

Function CBloom (clip Last, int "radius", int "radiusc", int "min", int "max", int "sat") {

radius = Default (radius, 5)
edges = (radius % 4) == 0 ? radius : radius + 4 - (radius % 4)
radiusc = Default(radiusc,Round (Width / 120.0))
min = Default (min, 254)
max = Default (max, min + 1)
sat = Default (sat, 128)

Mask = ConvertToYV12().Levels (min, 1, max, 0, 255, false)
Mask = MergeLuma(Mask.GaussResize(width/radiusc,height/radiusc,p=1)
\ .BilinearResize(width,height).Levels (0, 1, 127, 0, 255, False), 0.5)
\ .ColorYUV(cont_u = sat, cont_v = sat)

White = BlankClip(Mask, color=$FFFFFF, pixel_type = "YV12")
\ .MT_lutxy(Mask.AddBorders (edges, edges, edges, edges)
\ .FastGaussBlur(24)
\ .Crop (edges, edges, edges * -1, edges * -1)
\ ,yexpr="256 256 x - 256 y - * 256 / -"
\ ,uexpr=" y 128 < x y * 128 /"
\ ,vexpr=" y 128 < x y * 128 /" ,Y=3,U=3,V=3)

MT_Merge (Last, White, mask, chroma = "process")

}

CBloom (radiusc=12,min=100,max=200,sat=512) #720X480psimpleresize and 24p_30p footage on 2 core cpu (1.6 ghz), media player classic set to evr in options.

feel free to edit, enjoy
Attached Images
  

Last edited by MJLives12; 9th July 2013 at 21:20. Reason: corrections in color
MJLives12 is offline   Reply With Quote
Old 15th July 2013, 14:00   #19  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,377
Quote:
Originally Posted by MJLives12 View Post
feel free to edit, enjoy
Nice! Works best with darkish images; if result is too washed out on lighter sources, try a little gamma correction:
Code:
Levels(16, 0.8, 235, 16, 235, coring=false, dither=false)
CBloom(radiusc=12, min=100, max=200, sat=128)
raffriff42 is offline   Reply With Quote
Old 19th July 2013, 21:51   #20  |  Link
MJLives12
Registered User
 
Join Date: Mar 2012
Posts: 29
NeonBloom (experiemental)


Here's a cleaner way for color (trying to get that neon light look)

code :

Function NeonBloom (clip c, int "radius", int "min", int "max", int "sat", int "blur") {
c
radius = Default (radius, 2)
min = Default (min, 254)
max = Default (max, min +1)
sat = Default (sat, 255)
blur = Default (blur, 96)

Mask = YLevelsG (min, 1, max, 0, 255) #gradient

Mask = Mask.ConvertToRGB32 ().RGBAdjust(sat,sat,sat).ConvertToYV12 ()
\ .AddBorders (radius, radius, radius, radius)
\ .FastGaussBlur (blur)
\ .Crop (radius, radius, radius * -1, radius * -1)
White = MT_lutxy (Mask
\ ,yexpr="256 0 x - 256 y - * 256 / -"
\ ,uexpr="x 255 == x 255 y y * 255 x - / min ?"
\ ,vexpr="x 255 == x 255 y y * 255 x - / min ?", U = 3, V = 3)

MT_Merge (white, Mask, U = 3, V = 3)



}

NeonBloom (min = 200, sat = 20)

Enjoy.
MJLives12 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 09:50.


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