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
Register FAQ Calendar Today's Posts Search

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: 366
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,219
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,391
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,391
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, 07:31   #9  |  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 22nd May 2006, 04:23   #10  |  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   #11  |  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   #12  |  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   #13  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,373
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   #14  |  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
Old 20th July 2013, 13:18   #15  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,373
Quote:
Originally Posted by MJLives12 View Post
trying to get that neon light look
OMG my eyes :b
No seriously, that's really original and interesting. Not a "film look" at all, though!

When animated it makes an interesting variation of the "fade-to-white" scene transition
Code:
## neon fade from normal to white and back e.g. for scene transitions

centerframe=150 ## frame at center of transition; maximum whiteness
half_len=20 ## transition speed in frames (1/2 total duration)
C
C = C.Trim(0, (centerframe - half_len)) 
\
\ + Animate(C.Trim((centerframe - half_len), -half_len), 
\         1, half_len-1, "NeonBloom", 
\         2, 100, 235,  0,  96, 
\         2,   0, 235, 20,  96)
\
\ + Animate(C.Trim(centerframe, -half_len), 
\         1, half_len-1, "NeonBloom", 
\         2,   0, 235, 20,  96,
\         2, 100, 235,  0,  96)
\
\ + C.Trim((centerframe + half_len), 0)
return C


With a little tweaking it can make titles flare with that '80's neon look...

Last edited by raffriff42; 18th March 2017 at 01:35. Reason: (fixed image links)
raffriff42 is offline   Reply With Quote
Old 21st July 2013, 20:34   #16  |  Link
MJLives12
Registered User
 
Join Date: Mar 2012
Posts: 29
Impressive

This script looks better. I'll give it a try. thanks.

Last edited by MJLives12; 21st July 2013 at 20:35. Reason: icon
MJLives12 is offline   Reply With Quote
Old 21st July 2013, 23:31   #17  |  Link
MJLives12
Registered User
 
Join Date: Mar 2012
Posts: 29
FastGaussBlur no artifacts

Animate is a cool function with exception my cpu lags and I'm still new to editing.

Here's an improve bloom/glow function without the "white spikes"
or less blocky..

Code:
Function NeonGlow (clip c, int "min", int "max", float "r", float "g", float "b", int "blur", int "radius") {
c
radius = Default (radius, 2)
min = Default (min, 250)
max = Default (max, min +1)
r = Default (r, 1)
g = Default (g, 1)
b = Default (b, 1)
blur = Default (blur, 96)

cbloom = YLevelsG (min, 1, max, 0, 255)
\ .ConvertToRGB24 ().RGBAdjust (r, g, b).ConvertToYV12 ()
\ .ColorYUV (gain_y = 0, off_y = 10, cont_y = 80, gamma_y = 0
\ ,cont_u = 18, cont_v = 18)
c = MT_lutxy (cbloom
\ , yexpr="256 255 x - 256 y - * 256 / -"
\ , uexpr=" y 128 < x y * 128 /"
\ , vexpr=" y 128 < x y * 128 /", Y = 3, U = 3, V = 3, chroma = "process")
cbloom = cbloom.AddBorders (radius, radius, radius, radius)
\ .FastGaussBlur (blur)
\ .Crop (radius, radius, radius * -1, radius * -1)
MT_lutxy (cbloom
\ , yexpr="256 255 x - 256 y - * 256 / -"
\ , uexpr=" y 128 < x y * 128 /"
\ , vexpr=" y 128 < x y * 128 /", Y = 3, U = 3, V = 3, chroma = "process")

bloommask = BlankClip (cbloom, color_yuv = $FF8080, pixel_type = "YV12")

MaskedMerge (bloommask, cbloom)


}
############################################## 

Paste fastgaussblur in separate file


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 gaussresize(ox,oy,1,0,p=1) #just testing

}
#############################################
enjoy and feel free to edit.

Last edited by MJLives12; 1st August 2013 at 03:09. Reason: code tag, contrast control / separate functions
MJLives12 is offline   Reply With Quote
Old 1st August 2013, 03:16   #18  |  Link
MJLives12
Registered User
 
Join Date: Mar 2012
Posts: 29
Neon effect (experimental) with white light

Animate is an amazing function with the effect! My cpu lags and I'm still new to editing.
Here's an improve bloom/glow function without the "white spikes"
or less blocky.

Code:
Function NeonGlow (clip c, int "min", int "max", float "r", float "g", float "b", int "blur", int "radius") {
c
radius = Default (radius, 2)
min = Default (min, 250)
max = Default (max, min +1)
r = Default (r, 1)
g = Default (g, 1)
b = Default (b, 1)
blur = Default (blur, 96)

cbloom = YLevelsG (min, 1, max, 0, 255)
\ .ConvertToRGB24 ().RGBAdjust (r, g, b).ConvertToYV12 ()
\ .ColorYUV (gain_y = 0, off_y = 10, cont_y = 80, gamma_y = 0
\ ,cont_u = 18, cont_v = 18)
c = MT_lutxy (cbloom
\ , yexpr="256 255 x - 256 y - * 256 / -"
\ , uexpr=" y 128 < x y * 128 /"
\ , vexpr=" y 128 < x y * 128 /", Y = 3, U = 3, V = 3, chroma = "process")
cbloom = cbloom.AddBorders (radius, radius, radius, radius)
\ .FastGaussBlur (blur)
\ .Crop (radius, radius, radius * -1, radius * -1)
MT_lutxy (cbloom
\ , yexpr="256 255 x - 256 y - * 256 / -"
\ , uexpr=" y 128 < x y * 128 /"
\ , vexpr=" y 128 < x y * 128 /", Y = 3, U = 3, V = 3, chroma = "process")

bloommask = BlankClip (cbloom, color_yuv = $FF8080, pixel_type = "YV12")

MaskedMerge (bloommask, cbloom)


}
############################################## 

Paste fastgaussblur in separate file


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 gaussresize(ox,oy,1,0,p=1) #just testing

}
#############################################
Example : neonglow (min=200,r=3,g=5,b=2,blur=48), enjoy and feel free to edit.
MJLives12 is offline   Reply With Quote
Old 10th August 2013, 01:25   #19  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,373
@MJLives12, take a look at this for some inspiration: VirtualDub: Kagayaki filter

Wouldn't your soft bloom script look great with a star filter like this:



Last edited by raffriff42; 18th March 2017 at 01:33. Reason: (fixed image links)
raffriff42 is offline   Reply With Quote
Old 10th August 2013, 23:39   #20  |  Link
MJLives12
Registered User
 
Join Date: Mar 2012
Posts: 29
Kagayaki filter

Amazing! I've been looking for a filter like this. Thx!
MJLives12 is offline   Reply With Quote
Reply


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 14:25.


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