Log in

View Full Version : Bloom filter for film look


Pages : [1] 2

tin3tin
17th March 2006, 23:44
I think this could be very useful for making filmlooks:
Bloomfilter/Filtermeister (http://forum.jpatch.com/viewtopic.php?p=3242#3242)

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

Zarxrax
17th March 2006, 23:54
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.

Backwoods
18th March 2006, 23:33
http://img386.imageshack.us/img386/3544/bloomtest3bv.jpg

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.

Didée
19th March 2006, 00:26
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):

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...)

Backwoods
19th March 2006, 02:26
http://img93.imageshack.us/img93/6809/compare1bx.jpg

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.

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)
}

Didée
19th March 2006, 03:56
I knew I had once posted FastGaussBlur, but couldn't find it ATM :o

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.)

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:
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")

actionman133
4th May 2006, 13:50
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:

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)

}

Backwoods
4th May 2006, 22:04
No sample images?

actionman133
5th May 2006, 02:41
I've uploaded two samples to my website here...

http://actionman133.isa-geek.net:8080/preview/preview.html

kevin23
5th May 2006, 07:31
I knew I had once posted FastGaussBlur, but couldn't find it ATM :o

Here is FastGaussBlur



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
5th May 2006, 22:03
I've uploaded two samples to my website here...

http://actionman133.isa-geek.net:8080/preview/preview.html

Very nice.

actionman133
7th May 2006, 00:51
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! :mad: If anyone knows any efficient way to apply a radial blur, please let me know...

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")

}

Mug Funky
8th May 2006, 10:17
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.

actionman133
9th May 2006, 09:01
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...

actionman133
20th May 2006, 04:15
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.

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)

}

NormanBates
22nd May 2006, 04:23
@actionman133
thank you! this works very well for me!

Norman Bates

Dark-Cracker
22nd May 2006, 08:17
work like a charm :) thank u.
++

MJLives12
8th July 2013, 03:57
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

raffriff42
15th July 2013, 14:00
feel free to edit, enjoyNice! Works best with darkish images; if result is too washed out on lighter sources, try a little gamma correction: Levels(16, 0.8, 235, 16, 235, coring=false, dither=false)
CBloom(radiusc=12, min=100, max=200, sat=128)

MJLives12
19th July 2013, 21:51
:thanks:
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.

raffriff42
20th July 2013, 13:18
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 ## 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
https://www.dropbox.com/s/o4ju38bp9xmk8ot/neon-transition1.jpg?raw=1

With a little tweaking it can make titles flare with that '80's neon look...
https://www.dropbox.com/s/93mtrqjd11rkfxg/neon-flare2.jpg?raw=1

MJLives12
21st July 2013, 20:34
This script looks better. I'll give it a try. thanks.

MJLives12
21st July 2013, 23:31
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..

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. :)

MJLives12
1st August 2013, 03:16
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.

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. :)

raffriff42
10th August 2013, 01:25
@MJLives12, take a look at this for some inspiration: VirtualDub: Kagayaki filter (http://www.celestial-spells.com/en/logs/2012/04/kagayaki.php)

Wouldn't your soft bloom script (http://forum.doom9.org/showthread.php?p=1635890#post1635890) look great with a star filter like this:
https://www.dropbox.com/s/38wfngwak7chrf2/kayagaki-1.jpg?raw=1
https://www.dropbox.com/s/mw9uuhl3kkmyeh5/kayagaki-2.jpg?raw=1
https://www.dropbox.com/s/pxfyu6zo6khargy/kayagaki-3.jpg?raw=1

MJLives12
10th August 2013, 23:39
Amazing! I've been looking for a filter like this. Thx!:D

MJLives12
16th August 2013, 01:05
Doing some testing I think I got similar results, not sure but some tweaking min and max) :D

Function SoftBloom (clip c, int "radius", int "vradius", int "blur"
\ , int "min", int "max", int "threshold", float "sat") {
c

radius = Default (radius, Round (Width / 120.0))
vradius = Default (vradius, Round (Width / 120.0))
threshold = Default (threshold, 200)
threshold = Round (Threshold * 219 / 255.0) + 16
min = Default (min, 200)
max = Default (max, min + 1)
sat = Default (sat, 128)
blur = Default (blur, 1)

blm = YLevelsG(min, 1, max, 0, 255)
\ . ConvertToRGB32 ().ConvertToYV12 ()
\ . ColorYUV (cont_u = sat, cont_v = sat)
\ . GaussResize (width / radius, height / vradius, p = blur)
\ . BilinearResize (width, height)
bloommask = BlankClip (blm).Invert ("Y")

MT_Merge (bloommask, blm)
MT_lutxy (blm
\ . YLevels (16, 1.0, threshold, 0, 255)
\ , uexpr=" y 128 < x y * 128 /"
\ , vexpr=" y 128 < x y * 128 /", chroma = "process")

}


SoftBloom(min=150,radius=5,vradius=5,sat=256,threshold=127)
#Second Image
Experimental Plus effect (slightly takes a little cpu consumption)

Function SoftGlow (clip c, int "radius", int "vradius", int "blur"
\ , int "min", int "max", int "threshold", float "sat") {
c

radius = Default (radius, Round (Width / 120.0))
vradius = Default (vradius, Round (Width / 120.0))
threshold = Default (threshold, 200)
threshold = Round (Threshold * 219 / 255.0) + 16
min = Default (min, 200)
max = Default (max, min + 1)
sat = Default (sat, 128)
blur = Default (blur, 1)

blm = YLevelsG(min, 1, max, 0, 255)
\ . ConvertToRGB32 ().ConvertToYV12 ()
\ . ColorYUV (cont_u = sat, cont_v = sat)
blm = Merge (blm.GaussResize (width / radius, height, p = 1)
\ . BilinearResize (width, height)
\ , blm.GaussResize (width, height / vradius, p = 1)
\ . BilinearResize (width, height), 0.5)

bloommask = BlankClip (blm).Invert ("Y")

MT_Merge (bloommask, blm)
MT_lutxy (blm
\ . YLevels (16, 1.0, threshold, 0, 255)
\ , uexpr=" y 128 < x y * 128 /"
\ , vexpr=" y 128 < x y * 128 /", chroma = "process")

}

SoftGlow(min=200,radius=12,vradius=12,sat=256,threshold=127) #First Image

raffriff42
18th August 2013, 00:29
Got an error @ GaussResize with 720p source: "Planar destination height must be a multiple of 2"

Maybe replace width / radius (which can be non-mod 2 sometimes)
with something like (width / radius) + ((width / radius) % 2), and same for height / radius.

Don't see much blooming; changing threshold has no effect that I can see - maybe it's my source, but I tried a variety ;(

Still favor your first Bloom function (http://forum.doom9.org/showthread.php?p=1635890#post1635890) - it's great.

MJLives12
18th August 2013, 02:36
Oh sorry about that I was testing a 480p footage. With a 720p or 1280 X 720 divide a tenth of height/width (for example width 128, height 72 divided by 2 = 64 X 36 or divided by 2 = 32 X 18)
radius = 32, vradius = 18 or use smaller number like 16 X 9. I edited the first bloom function to have the plus effect.

Thanks for the radius correction, I figured it out.

Levels(16, 0.8, 235, 16, 235, coring=false, dither=false)

SoftGlow(radius=32, min=200, sat=128)

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

radius = Default (radius, 2)
edges = (width / radius) + ((width / radius) % 2) #bigger radius smaller effect
min = Default (min, 254)
max = Default (max, min + 1)
sat = Default (sat, 128)

Mask = YLevelsG (min, 1, max, 0, 255)
\ . ConvertToRGB32 ().ConvertToYV12 ()
\ . ColorYUV (cont_u = sat, cont_v = sat)
Mask = Merge (Mask.GaussResize (width / edges, height, p = 1)
\ . BilinearResize (width, height)
\ , Mask.GaussResize (width, height / edges, p = 1)
\ . BilinearResize (width, height), 0.5)
\ . Levels (0, 1, 127, 0, 255, False)
MT_lutxy (Mask
\ , uexpr = " y 128 < x y * 128 /"
\ , vexpr = " y 128 < x y * 128 /" , Y = 3, U = 3, V = 3)
White = BlankClip (Mask, color=$FFFFFF, pixel_type = "YV12")

MT_Merge (Last, White, mask)

}




Softbloom (non plus effect just blur)


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

radius = Default (radius, 2)
edges = (width / radius) + ((width / radius) % 2) #bigger radius smaller effect
min = Default (min, 254)
max = Default (max, min + 1)
sat = Default (sat, 128)

Mask = YLevelsG (min, 1, max, 0, 255)
\ . ConvertToRGB32 ().ConvertToYV12 ()
\ . ColorYUV (cont_u = sat, cont_v = sat)
Mask = Mask.GaussResize (width / edges, height / edges, p = 1)
\ . BilinearResize (width, height)
\ . Levels (0, 1, 127, 0, 255, False)
MT_lutxy (Mask
\ , uexpr = " y 128 < x y * 128 /"
\ , vexpr = " y 128 < x y * 128 /" , Y = 3, U = 3, V = 3)
White = BlankClip (Mask, color=$FFFFFF, pixel_type = "YV12")

MT_Merge (Last, White, mask)

}

boxblur bloom with fps control


Function CBloom (clip last, int "radius", float "cfps", float "afps"
\ , int "min", int "max", int "threshold") {

LoadVirtualDubPlugin("C:\Program Files\AviSynth 2.5\plugins\BoxBlur.vdf", "BoxBlur")

radius = Default (radius, Round (Width / 120.0))
threshold = Default (threshold, 250)
threshold = Round (Threshold * 219 / 255.0) + 16
min = Default (min, 200)
max = Default (max, min +1)
cfps = Default (cfps, last)
afps = Default (afps, last)

ChangeFps(cfps)

Assumefps(afps)

Mask = YLevelsG (min, 1.0, max, 0, 255)
\ .ConvertToRGB32 ("PC.601").Levels (0, 0.1, threshold, 0, 255, false)
\ .BoxBlur (radius, 3, 1000).ConvertToYV12 (matrix="PC.601")
White = BlankClip (Mask).Invert ("Y")

MT_Merge (MT_lutxy (Mask
\ ,uexpr = " y 128 < x y * 128 /"
\ ,vexpr = " y 128 < x y * 128 /", U = 3, V = 3).Addgrain(25,.1,.1), White, Mask, luma = true, chroma = "copy")

}

I'm still a noob I only found a way to make a plus blur effect (I'm over my head trying to create a cross (or X blur eftect )

Feel free to edit and enjoy:)

raffriff42
25th August 2013, 17:28
Here's an Avisynth wrapper for Kagayaki (see sample pics @ post #25) (http://forum.doom9.org/showthread.php?p=1639884#post1639884) #avisynth

## requires Kagayaki VirtualDub plugin
# http://www.celestial-spells.com/en/logs/2012/04/kagayaki.php

LoadVirtualdubPlugin("<vdub path>\plugins32\cs_kagayaki.vdf", "_VD_kagayaki")
# http://avisynth.nl/index.php/FAQ_using_virtualdub_plugins

#############################################################
##
#
# @param pre_cutoff - default=100, max=253 (lower = more bloom)
# @param pre_tonepwr - default=100, max=2000 (lower = more bloom)
# (if cross_type != 0, default=300 for less bloom)
#
# @param twinkle_enable - default=false
# @param twinkle_amp - default=80
# @param twinkle_freq - default=100, max=1000
#
# @param soft_radius - default=36, max=128 (higher = softer)
# @param soft_power - default=1200, max=2000 (lower = softer)
# @param soft_mult - default=255, max=50000 (higher = softer)
#
# @param cross_type - default=0 (star filter: 0=off, 1=cross, 2=X)
# @param cross_radius - default=72, max=128
# @param cross_power - default=100, max=5000
# @param cross_mult - default=300, max=5000
#
# @param adj_R, G, B - default=100, max=100 (lower = less saturation)
# @param adj_sat - default=100, max=200
#
function Kagayaki(clip C,
\ int "pre_cutoff", int "pre_tonepwr",
\ bool "twinkle_enable", int "twinkle_amp", int "twinkle_freq",
\ int "soft_radius", int "soft_power", int "soft_mult",
\ int "cross_type", int "cross_radius", int "cross_power", int "cross_mult",
\ int "adj_R", int "adj_G", int "adj_B", int "adj_sat")
{
twinkle_enable = Default(twinkle_enable, false) ## default = no twinkle
twinkle_amp = Min(Max(0, Default(twinkle_amp , 80)), 100)
twinkle_freq = Min(Max(0, Default(twinkle_freq , 100)), 1000)

soft_radius = Min(Max(0, Default(soft_radius , 36)), 128)
soft_power = Min(Max(0, Default(soft_power ,1200)), 2000)
soft_mult = Min(Max(0, Default(soft_mult , 255)), 50000)

cross_type = Min(Max(0, Default(cross_type , 0)), 2) ## default = no cross
cross_radius = Min(Max(0, Default(cross_radius , 72)), 128)
cross_power = Min(Max(0, Default(cross_power , 100)), 5000)
cross_mult = Min(Max(0, Default(cross_mult , 300)), 5000)

pre_cutoff = Min(Max(0, Default(pre_cutoff , 100)), 253)
pre_tonepwr = (cross_type==0)
\ ? Min(Max(0, Default(pre_tonepwr , 100)), 2000)
\ : Min(Max(0, Default(pre_tonepwr , 300)), 2000)

adj_R = Min(Max(0, Default(adj_R , 100)), 100)
adj_G = Min(Max(0, Default(adj_G , 100)), 100)
adj_B = Min(Max(0, Default(adj_B , 100)), 100)
adj_sat = Min(Max(0, Default(adj_sat , 100)), 200)

return C._VD_kagayaki(1,
\ pre_cutoff, pre_tonepwr,
\ (twinkle_enable ? 1 : 0), twinkle_amp, twinkle_freq,
\ 1, soft_radius, soft_power, soft_mult,
\ cross_type, cross_radius, cross_power, cross_mult,
\ adj_R, adj_G, adj_B, adj_sat)
}

MJLives12
27th August 2013, 19:36
I added ConvertToRGB32 to the script (return C.ConvertToRGB32 ()._VD_kagayaki(1,), works but my cpu is extremely weak to process (1 to 2 fps lol)

Kagayaki (soft_radius = 144, soft_power = 600, soft_mult = 500)

StainlessS
27th August 2013, 19:50
MJLives, for future reference, PhotoBucket.com allows jpg upload, and insert link in post shows image
immediately, no Pending Approval wait.

Link should be enclosed in blah...blah tags.

creaothceann
27th August 2013, 20:24
Better yet, use imgur (http://imgur.com/) or minus (http://minus.com/).

StainlessS
27th August 2013, 22:09
Better yet, use imgur (http://imgur.com/) or minus (http://minus.com/).

Anything in particular make them better yet ?

creaothceann
27th August 2013, 22:52
Both make it very easy to access the 'raw image' URL, and don't redirect the viewer who wants to see only that image.

Also, minus can host very large images, and doesn't re-encode to *.jpg.

MJLives12
27th August 2013, 23:04
Much quicker, :thanks:

http://i.imgur.com/oeG9Bzb.png

Kagayaki (soft_radius = 144, soft_power = 600, soft_mult = 500)

MJLives12
27th August 2013, 23:17
star effect

Kagayaki (cross_radius = 144, cross_power = 1000, cross_mult = 1000, cross_type = 2)

http://i.imgur.com/e84ugWV.png

MJLives12
27th August 2013, 23:31
And plus effect
audio
\ =FFAudioSource("C:\Fraps\movies\hdmp4\rc21.ac3")
video
\ =FFVideoSource("C:\Fraps\movies\hdmp4\rc21.mkv")

AudioDub(video, audio)

Simpleresize(720,480)

Kagayaki (cross_radius = 144, cross_power = 1000, cross_mult
\ = 1000, cross_type = 1)

ConverttoYV12()

all images are processed with virtual dub at 720X480, screenshot using Fraps on media player classic. I'm just testing out videos, thanks StainlessS and creaothceann for the advice and thanks raffriff42 for the script, I'm inspired to create a realtime script using avisynth tools. I'm enjoying it :)

http://i.imgur.com/8nOfUYp.png

MJLives12
31st August 2013, 21:11
Trying to make a real time script or faster post processor.

Function SoftBloom (clip last, int "radius", int "minlevels"
\ , int "min", int "max", int "threshold", int "blur", float "sat", float "cont") {

radius = Default (radius, 2)
edges = (width / radius) + ((width / radius) % 2) #bigger radius smaller effect
minlevels = Default (minlevels, 0)
threshold = Default (threshold, 250)
threshold = Round (Threshold * 219 / 255.0) + 16
min = Default (min, 254)
max = Default (max, min +1)
blur = Default (blur, 1)
sat = Default (sat, 0.7)
cont = Default (cont, 1.0)

Mask = ConvertToRGB32 ().RGBLevelsG (min, 1.0, max, 0, 1)
\ .Levels (minlevels, 0.1, threshold, 0, 255, false)
\ .ConvertToYV12 ()
\ .GaussResize (width / edges, height / edges, p = blur)
\ .Tweak (cont = cont, sat = sat)
\ .BilinearResize (width, height)
White = BlankClip (Mask).Invert ("Y")

MT_Merge (MT_lutxy (Mask
\ ,uexpr = " y 128 < x y * 128 /"
\ ,vexpr = " y 128 < x y * 128 /", U = 3, V = 3), White, Mask)

}

#RGBLevelsG from YLevelsG. RGBLevelsG needed for script to work

function RGBlevelsG(clip clp,
\ int "input_low", float "gamma", int "input_high",
\ int "output_low", int "output_high", bool "show_function")
{

input_low = Default(input_low, 0)
gamma = Default(gamma, 1.0)
input_high = Default(input_high, 255)
output_low = Default(output_low, 0)
output_high = Default(output_high, 255)
show_function = Default(show_function, false)

wicked = gamma > 1.0
\ ? "x " +string(input_low)+ " - " +string(input_high)+ " " +string(input_low)+ " - / 1 " +string(gamma)+
\ " / ^ " +string(output_high)+ " " +string(output_low)+ " - * " +string(output_low)+ " + x * x 255 x - * + 255 /"
\ : "x " +string(input_low)+ " - " +string(input_high)+ " " +string(input_low)+ " - / 1 " +string(gamma)+
\ " / ^ " +string(output_high)+ " " +string(output_low)+ " - * " +string(output_low)+ " + 255 x - * x x * + 255 /"

return( show_function ? clp.subtitle(wicked) : clp.rgblut(rexpr = wicked, gexpr = wicked,bexpr = wicked, R = 3, G = 3, B = 3) )


}




A = SoftBloom (radius = 144, min = 199, max = 296
\ , minlevels = -200, threshold = 200, sat = 2.0, cont = 2.0).ConvertToRGB32 # Left

K = Kagayaki (soft_radius = 128, soft_power = 992, soft_mult = 299, cross_type = 0) # Right

StackHorizontal (A, K)

http://i.imgur.com/UfDdv48.jpg

travolter
1st September 2013, 17:52
RGBlevelsG function crashes my avisynth.
Is there any syntax error?

raffriff42
1st September 2013, 19:19
RGBlevelsG function crashes my avisynth.
Is there any syntax error?I get "script error: there is no function named rgblut"
Seems to require MaskTools (http://avisynth.nl/index.php/MaskTools) (not Masktools2) - is that right? Which version?
Tried MaskTools version 1.5.5 through 1.5.8 and get the same error with Avisynth version 2.60.
EDIT - never mind, works OK with Masktools.dll in Plugins folder, ie not calling LoadPlugin.

OK, 2nd problem: Changing the value of radius creates a number of errors, such as:
"Resize: Source image too small for this resize method. Width=640, Support=2560" (radius=default, source=1280x720)
"Resize: Planar destination width must be a multiple of 2." (radius=most values between 68 thru 98, source=1280x720)

MJLives12
2nd September 2013, 03:06
RGBlevelsG function crashes my avisynth.
Is there any syntax error?

You can use levels (RGBlevelsG is experimental), you'll get less colors though. I'm updating the script, may delete rgblevelsg function from directory.

I get "script error: there is no function named rgblut"
Seems to require MaskTools (not Masktools2) - is that right? Which version?
Tried MaskTools version 1.5.5 through 1.5.8 and get the same error with Avisynth version 2.60.
EDIT - never mind, works OK with Masktools.dll in Plugins folder, ie not calling LoadPlugin.
OK, 2nd problem: Changing the value of radius creates a number of errors, such as:
"Resize: Source image too small for this resize method. Width=640, Support=2560" (radius=default, source=1280x720)
"Resize: Planar destination width must be a multiple of 2." (radius=most values between 68 thru 98, source=1280x720)

Use smaller values for example 1280 = 128, or 64, or 32, or 16 (smaller may crash)

Sorry had to edit this a bit to make it cleaner.

Function SoftBloom (clip last, int "radius", int "minlevels"
\ , int "min", int "max", int "threshold", int "blur", float "sat", int "cont", float "mul") {

radius = Default (radius, 2)
edges = (width / radius) + ((width / radius) % 2) #bigger radius smaller effect
minlevels = Default (minlevels, 0)
threshold = Default (threshold, 250)
threshold = Round (Threshold * 219 / 255.0) + 16
min = Default (min, 254)
max = Default (max, min +1)
blur = Default (blur, 1)
sat = Default (sat, 0.5)
cont = Default (cont, 127)
mul = Default (mul, 0.25)

Mask = ConvertToRGB32 ().RGBLevelsG (min, 1.0, max, 0, 255)
\ .Levels (minlevels, 0.1, threshold, 0, 255, false)
\ .ConvertToYV12 ()
\ .GaussResize (width / edges, height / edges, p = blur)
\ .BilinearResize (width, height)
\ .Tweak (sat = sat)
\ .Levels (0, 1.0, cont, 0, 255, false)
White = BlankClip (Mask).Invert ("Y")

MT_Merge (MT_lutxy (Mask
\ ,uexpr = " y 128 < x y * 128 /"
\ ,vexpr = " y 128 < x y * 128 /", U = 3, V = 3), White, luma = true
\ ,Merge (Tweak (cont = 0, sat = 0), Mask, mul))

}

Glow script without using resize method

Function SGlow (clip last, int "radius", int "minlevels"
\ , int "min", int "max", int "threshold", int "blur", float "sat", int "cont", float "mul") {

radius = Default (radius, 5)
edges = (radius % 4) == 0 ? radius : radius + 4 - (radius % 4)
minlevels = Default (minlevels, 0)
threshold = Default (threshold, 250)
threshold = Round (Threshold * 219 / 255.0) + 16
min = Default (min, 254)
max = Default (max, min +1)
blur = Default (blur, 96)
sat = Default (sat, 0.5)
cont = Default (cont, 127)
mul = Default (mul, 0.25)

Mask = ConvertToRGB32 ().RGBLevelsG (min, 1.0, max, 0, 255)
\ .Levels (minlevels, 0.1, threshold, 0, 255, false)
\ .ConvertToYV12 ()
\ .AddBorders (edges, edges, edges, edges)
\ .FastGaussBlur (blur)
\ .Crop (edges, edges, edges * -1, edges * -1)
\ .Tweak (sat = sat)
\ .Levels (0, 1.0, cont, 0, 255, false)
White = BlankClip (Mask).Invert ("Y")

MT_Merge (MT_lutxy (Mask
\ ,uexpr = " y 128 < x y * 128 /"
\ ,vexpr = " y 128 < x y * 128 /", U = 3, V = 3), White, luma = true
\ ,Merge (Tweak (cont = 0, sat = 0), Mask, mul))

}

Spline16Resize (1280, 720)

SoftBloom (radius = 128, min = 196,max=224, blur = 1
\ , minlevels = 0, threshold = 200, sat = 0.8, cont = 127, mul = 0.5) # smaller radius value wider blur, mul is bloom opacity, blur is set to 1, higher makes blur sharper (I keep it at 1 to prevent artifacts)

or

SGlow (radius = 12, min = 196,max=224, blur = 192
\ , minlevels = 0, threshold = 200, sat = 0.8, cont = 127, mul = 0.5)

http://i.imgur.com/ZgbuSEn.jpg

Lower width and height gives speedup of course, SimpleResize (720, 480) gets 30p on dual core pcs 1.6 ghz, faster cpus may get better results.

raffriff42
2nd September 2013, 14:53
Call SoftBloom & SGlow with random arguments!
A selection of cool-looking random SoftBloom settings (https://www.dropbox.com/sh/1q6trw0qadfr2kt/jD4EMfpIfn#/) (dropbox.com)
## SoftBloom: fuzz test input args
## just keep frame stepping, see if anything breaks ;)
## (also a neat way to explore different effects)
## warning this video may cause seizures - do not play in real time

return ScriptClip(C, "SoftBloom_Test(C)")

##################################
## SoftBloom: fuzz test input args
#
function SoftBloom_Test(clip C)
{
## random inputs
## (limits are set based on guesswork; please adjust if needed)
a_radius=Rand(C.Width/2)
a_minlevels=Rand(512)-255
a_min=Rand(254)
a_max=Rand(255)
a_threshold=Rand(255)
a_sat=Rand(400)/100.0
a_cont=Rand(255)
a_mul=Rand(400)/100.0

stat="SoftBloom_B(rad=" + String(a_radius) + ", minlvl=" + String(a_minlevels)
\ + ", min=" + String(a_min) + ", max=" + String(a_max) + ", thrsh=" + String(a_threshold)
\ + ", sat=" + String(a_sat) + ", cont=" + String(a_cont) + ", mul=" + String(a_mul)
\ + ")"
return C.SoftBloom_B(
\ radius=a_radius, minlevels=a_minlevels,
\ min=a_min, max=a_max, threshold=a_threshold,
\ sat=a_sat, cont=a_cont, mul=a_mul)
\ .SubTitle(stat)
}

##################################
## SoftBloom with constrained inputs and resizing
## original @ http://forum.doom9.org/showthread.php?p=1642381#post1642381
#
Function SoftBloom_B (clip Last, int "radius", int "minlevels"
\ , int "min", int "max", int "threshold", int "blur", float "sat", int "cont", float "mul") {

## (limits are set based on guesswork; please adjust if needed)
radius = Min(Max(2, Default (radius, 2)), Width / 2)
edges = (width / radius) + ((width / radius) % 2) #bigger radius smaller effect
threshold = Min(Max(16, Round (Default (threshold, 250) * 219 / 255.0) + 16), 255)
minlevels = Min(Max(-255, Default (minlevels, 0)), threshold-1)
min = Min(Max(threshold+1, Default (min, 254)), 254)
max = Min(Max(min+1, Default (max, min+1)), 255)
blur = Min(Max(0, Default (blur, 1)), 100)
sat = Min(Max(0.0, Default (sat, 0.5)), 4.0)
cont = Min(Max(16, Default (cont, 127)), 255)
mul = Min(Max(0.0, Float(Default (mul, 0.25))), 4.0)

old_wid = Width
old_hgt = height
new_wid = width / edges
new_hgt = height / edges
new_wid = Min(Max(64, new_wid), old_wid / 2)
new_hgt = Min(Max(64, new_hgt), old_hgt / 2)
new_wid = new_wid + new_wid % 2
new_hgt = new_hgt + new_hgt % 2

Mask = ConvertToRGB32 ().RGBLevelsG (min, 1.0, max, 0, 255)
\ .Levels (minlevels, 0.1, threshold, 0, 255, false)
\ .ConvertToYV12 ()
\ .GaussResize (new_wid, new_hgt, p = blur)
\ .BilinearResize (old_wid, old_hgt)
\ .Tweak (sat = sat)
\ .Levels (0, 1.0, cont, 0, 255, false)
White = BlankClip (Mask).Invert ("Y")

MT_Merge (MT_lutxy (Mask
\ ,uexpr = " y 128 < x y * 128 /"
\ ,vexpr = " y 128 < x y * 128 /", U = 3, V = 3), White, luma = true
\ ,Merge (Tweak (cont = 0, sat = 0), Mask, mul))
}

## SGlow: fuzz test input args
## warning this video may cause seizures - do not play in real time

return ScriptClip(C, "SGlow_Test(C)")

##################################
## SGlow: fuzz test input args
## note original SGlow seems to accept below random inputs OK
#
function SGlow_Test(clip C)
{
## random inputs
## (limits are set based on guesswork; please adjust if needed)
a_radius=Rand(C.Width/2)
a_minlevels=Rand(512)-255
a_min=Rand(254)
a_max=Rand(255)
a_threshold=Rand(255)
a_sat=Rand(400)/100.0
a_cont=Rand(255)
a_mul=Rand(400)/100.0
a_blur=Rand(180)

stat="SGlow(rad=" + String(a_radius) + ", minlvl=" + String(a_minlevels)
\ + ", min=" + String(a_min) + ", max=" + String(a_max) + ", thrsh=" + String(a_threshold)
\ + ", blur=" + String(a_blur) + ", sat=" + String(a_sat) + ", cont=" + String(a_cont)
\ + ", mul=" + String(a_mul)
\ + ")"
return C.SGlow(
\ radius=a_radius, minlevels=a_minlevels,
\ min=a_min, max=a_max, threshold=a_threshold,
\ blur=a_blur, sat=a_sat, cont=a_cont, mul=a_mul)
\ .SubTitle(stat)
}

##################################
## SGlow with constrained inputs
## original @ http://forum.doom9.org/showthread.php?p=1642381#post1642381
#
Function SGlow_B (clip Last, int "radius", int "minlevels"
\ , int "min", int "max", int "threshold", int "blur", float "sat", int "cont", float "mul") {

## (limits are set based on guesswork; please adjust if needed)
radius = Min(Max(2, Default (radius, 5)), Width / 2)
edges = (radius % 4) == 0 ? radius : radius + 4 - (radius % 4)
threshold = Min(Max(16, Round (Default (threshold, 250) * 219 / 255.0) + 16), 255)
minlevels = Min(Max(-255, Default (minlevels, 0)), threshold-1)
min = Min(Max(threshold+1, Default (min, 254)), 254)
max = Min(Max(min+1, Default (max, min+1)), 255)
blur = Min(Max(0, Default (blur, 96)), 180)
sat = Min(Max(0.0, Float(Default (sat, 0.5))), 4.0)
cont = Min(Max(16, Default (cont, 127)), 255)
mul = Min(Max(0.0, Float(Default (mul, 0.25))), 4.0)

Mask = ConvertToRGB32 ().RGBLevelsG (min, 1.0, max, 0, 255)
\ .Levels (minlevels, 0.1, threshold, 0, 255, false)
\ .ConvertToYV12 ()
\ .AddBorders (edges, edges, edges, edges)
\ .FastGaussBlur (blur)
\ .Crop (edges, edges, edges * -1, edges * -1)
\ .Tweak (sat = sat)
\ .Levels (0, 1.0, cont, 0, 255, false)
White = BlankClip (Mask).Invert ("Y")

MT_Merge (MT_lutxy (Mask
\ ,uexpr = " y 128 < x y * 128 /"
\ ,vexpr = " y 128 < x y * 128 /", U = 3, V = 3), White, luma = true
\ ,Merge (Tweak (cont = 0, sat = 0), Mask, mul))
}

MJLives12
2nd September 2013, 17:51
:thanks:

MJLives12
2nd September 2013, 21:11
Merge to gaussresize and FastGausBlur, it manages the blur strength, makes it lighter or less chunky. It works fine after I unticked "return ScriptClip(C, "SoftBloom_Test(C)")", I get an "I don't know what C means" error.

## SoftBloom: fuzz test input args
## just keep frame stepping, see if anything breaks ;)
## (also a neat way to explore different effects)
## warning this video may cause seizures - do not play in real time

#return ScriptClip(C, "SoftBloom_Test(C)")

##################################
## SoftBloom: fuzz test input args
#
function SoftBloom_Test(clip C)
{
## random inputs
## (limits are set based on guesswork; please adjust if needed)
a_radius=Rand(C.Width/2)
a_minlevels=Rand(512)-255
a_min=Rand(254)
a_max=Rand(255)
a_threshold=Rand(255)
a_sat=Rand(400)/100.0
a_cont=Rand(255)
a_mul=Rand(400)/100.0

stat="SoftBloom_B(rad=" + String(a_radius) + ", minlvl=" + String(a_minlevels)
\ + ", min=" + String(a_min) + ", max=" + String(a_max) + ", thrsh=" + String(a_threshold)
\ + ", sat=" + String(a_sat) + ", cont=" + String(a_cont) + ", mul=" + String(a_mul)
\ + ")"
return C.SoftBloom_B(
\ radius=a_radius, minlevels=a_minlevels,
\ min=a_min, max=a_max, threshold=a_threshold,
\ sat=a_sat, cont=a_cont, mul=a_mul)
\ .SubTitle(stat)
}

##################################
## SoftBloom with constrained inputs and resizing
## original @ http://forum.doom9.org/showthread.php?p=1642381#post1642381
#
Function SoftBloom_B (clip Last, int "radius", int "minlevels"
\ , int "min", int "max", int "threshold", int "blur", float "sat", int "cont", float "mul") {

## (limits are set based on guesswork; please adjust if needed)
radius = Min(Max(2, Default (radius, 2)), Width / 2)
edges = (width / radius) + ((width / radius) % 2) #bigger radius smaller effect
threshold = Min(Max(16, Round (Default (threshold, 250) * 219 / 255.0) + 16), 255)
minlevels = Min(Max(-255, Default (minlevels, 0)), threshold-1)
min = Min(Max(threshold+1, Default (min, 254)), 254)
max = Min(Max(min+1, Default (max, min+1)), 255)
blur = Min(Max(0, Default (blur, 1)), 100)
sat = Min(Max(0.0, Default (sat, 0.5)), 4.0)
cont = Min(Max(16, Default (cont, 127)), 255)
mul = Min(Max(0.0, Float(Default (mul, 0.25))), 4.0)

old_wid = Width
old_hgt = height
new_wid = width / edges
new_hgt = height / edges
new_wid = Min(Max(64, new_wid), old_wid / 2)
new_hgt = Min(Max(64, new_hgt), old_hgt / 2)
new_wid = new_wid + new_wid % 2
new_hgt = new_hgt + new_hgt % 2

Mask = Merge (Tweak (cont = 0, sat = 0)
\ ,ConvertToRGB32 ().RGBLevelsG (min, 1.0, max, 0, 255)
\ .Levels (minlevels, 0.1, threshold, 0, 255, false)
\ .ConvertToYV12 ()
\ .GaussResize (new_wid, new_hgt, p = blur)
\ .BilinearResize (old_wid, old_hgt)
\ .Tweak (sat = sat)
\ .Levels (0, 1.0, cont, 0, 255, false), mul)
White = BlankClip (Mask).Invert ("Y")

MT_Merge (MT_lutxy (Mask
\ ,uexpr = " y 128 < x y * 128 /"
\ ,vexpr = " y 128 < x y * 128 /", U = 3, V = 3), White, luma = true
\ , Mask)
}

SGlow

## SGlow: fuzz test input args
## warning this video may cause seizures - do not play in real time

return ScriptClip(C, "SGlow_Test(C)")

##################################
## SGlow: fuzz test input args
## note original SGlow seems to accept below random inputs OK
#
function SGlow_Test(clip C)
{
## random inputs
## (limits are set based on guesswork; please adjust if needed)
a_radius=Rand(C.Width/2)
a_minlevels=Rand(512)-255
a_min=Rand(254)
a_max=Rand(255)
a_threshold=Rand(255)
a_sat=Rand(400)/100.0
a_cont=Rand(255)
a_mul=Rand(400)/100.0
a_blur=Rand(180)

stat="SGlow(rad=" + String(a_radius) + ", minlvl=" + String(a_minlevels)
\ + ", min=" + String(a_min) + ", max=" + String(a_max) + ", thrsh=" + String(a_threshold)
\ + ", blur=" + String(a_blur) + ", sat=" + String(a_sat) + ", cont=" + String(a_cont)
\ + ", mul=" + String(a_mul)
\ + ")"
return C.SGlow_B(
\ radius=a_radius, minlevels=a_minlevels,
\ min=a_min, max=a_max, threshold=a_threshold,
\ blur=a_blur, sat=a_sat, cont=a_cont, mul=a_mul)
\ .SubTitle(stat)
}

##################################
## SGlow with constrained inputs
## original @ http://forum.doom9.org/showthread.php?p=1642381#post1642381
#
Function SGlow_B (clip Last, int "radius", int "minlevels"
\ , int "min", int "max", int "threshold", int "blur", float "sat", int "cont", float "mul") {

## (limits are set based on guesswork; please adjust if needed)
radius = Min(Max(2, Default (radius, 5)), Width / 2)
edges = (radius % 4) == 0 ? radius : radius + 4 - (radius % 4)
threshold = Min(Max(16, Round (Default (threshold, 250) * 219 / 255.0) + 16), 255)
minlevels = Min(Max(-255, Default (minlevels, 0)), threshold-1)
min = Min(Max(threshold+1, Default (min, 254)), 254)
max = Min(Max(min+1, Default (max, min+1)), 255)
blur = Min(Max(0, Default (blur, 96)), 180)
sat = Min(Max(0.0, Float(Default (sat, 0.5))), 4.0)
cont = Min(Max(16, Default (cont, 127)), 255)
mul = Min(Max(0.0, Float(Default (mul, 0.25))), 4.0)

Mask = Merge (Tweak (cont = 0, sat = 0)
\ ,ConvertToRGB32 ().RGBLevelsG (min, 1.0, max, 0, 255)
\ .Levels (minlevels, 0.1, threshold, 0, 255, false)
\ .ConvertToYV12 ()
\ .AddBorders (edges, edges, edges, edges)
\ .FastGaussBlur (blur)
\ .Crop (edges, edges, edges * -1, edges * -1)
\ .Tweak (sat = sat)
\ .Levels (0, 1.0, cont, 0, 255, false), mul)
White = BlankClip (Mask).Invert ("Y")

MT_Merge (MT_lutxy (Mask
\ ,uexpr = " y 128 < x y * 128 /"
\ ,vexpr = " y 128 < x y * 128 /", U = 3, V = 3), White, luma = true, Mask)
}


SoftBloom_Test ()

http://i.imgur.com/EQ1bqND.png uv swapped (uncompressed image)


SoftBloom_B(radius = 292, minlevels = 161, min = 149, max = 101
\ , threshold = 83, sat = 2.95, cont = 92, mul = 1.0)

http://i.imgur.com/tr0Fz92.png

raffriff42
2nd September 2013, 23:33
>I get an "I don't know what C means" error.
Sorry, should have mentioned it - you need a line like: C=AviSource("some file.avi")
Or even:C=Last

P.S. Please use CODE tags.

MJLives12
3rd September 2013, 01:15
>I get an "I don't know what C means" error.
Sorry, should have mentioned it - you need a line like: C=AviSource("some file.avi")
Or even:C=Last

P.S. Please use CODE tags.

Okay works, thanks.

Gavino
3rd September 2013, 08:59
return ScriptClip(C, "SoftBloom_Test(C)")
Since the clip argument to ScriptClip becomes 'last' inside the run-time script, this is better written as:
return ScriptClip(C, "SoftBloom_Test()")
The original code will not work if C is a local variable inside a function (since C would be out of scope when the run-time script is evaluated).

raffriff42
3rd September 2013, 13:21
Thanks Gavino!

Can I ask for your help, please? This is probably related. I'd like to generate my random arguments, call the function, and at the same time write the function call to to a log file - something like this: global g_logpath = "D:\path\logfile.txt"
WriteFileStart("logfile.txt", """ "frameno" """, "Chr(9)", """ "args " """)
WriteFileEnd(C, g_logpath, """ "#end" """)

C = <something>
return ScriptClip(C, "SoftBloom_Test()")

function SoftBloom_Test(clip C)
{
## random inputs
a_radius=Rand(C.Width/2)
a_minlevels=Rand(512)-255
a_min=Rand(254)
a_max=Rand(255)
a_threshold=Rand(255)
a_sat=Rand(400)/100.0
a_cont=Rand(255)
a_mul=Rand(400)/100.0

/* the following should be a valid Avisynth statement */
stat="SoftBloom_B(radius=" + String(a_radius) + ", minlevels=" + String(a_minlevels)
\ + ", min=" + String(a_min) + ", max=" + String(a_max) + ", threshold=" + String(a_threshold)
\ + ", sat=" + String(a_sat) + ", cont=" + String(a_cont) + ", mul=" + String(a_mul)
\ + ")"

/* write frame number + tab char + statement to logfile...? */

return Eval(stat).ShowFrameNumber
}
This way you could create a video + matching logfile; jog through the video and when you find an effect you like, go to the appropriate line in the log file to find the function call that created that image.

StainlessS
3rd September 2013, 16:31
RaffRiff42,
This works but I dont really like the use of Global G_args (cant remember if there is an alternative way).


C=Avisource("D:\avs\test.avi")

global g_logpath = "D:\path\logfile.txt"
C=WriteFileStart(C,g_logpath, """ "frameno" """, "Chr(9)", """ "args " """,append=false)
C=WriteFileEnd(C, g_logpath, """ "#end" """)



## SoftBloom: fuzz test input args
## just keep frame stepping, see if anything breaks ;)
## (also a neat way to explore different effects)
## warning this video may cause seizures - do not play in real time

return ScriptClip(C, "SoftBloom_Test()")

##################################
## SoftBloom: fuzz test input args
#
function SoftBloom_Test(clip C) {
C
## random inputs
a_radius=Rand(Width/2)
a_minlevels=Rand(512)-255
a_min=Rand(254)
a_max=Rand(255)
a_threshold=Rand(255)
a_sat=Rand(400)/100.0
a_cont=Rand(255)
a_mul=Rand(400)/100.0

args="radius=" + String(a_radius,"%3.0f") + ", minlevels=" + String(a_minlevels,"% 4.0f")
\ + ", min=" + String(a_min,"%3.0f") + ", max=" + String(a_max,"%3.0f") + ", threshold=" + String(a_threshold,"%3.0f")
\ + ", sat=" + String(a_sat,"%3.3f") + ", cont=" + String(a_cont,"%3.0f") + ", mul=" + String(a_mul,"%3.3f")

/* the following should be a valid Avisynth statement */
stat="SoftBloom_B(" + args + ")"
RT_Debug("SoftBloom_B","["+string(current_frame)+"]",args,false)
# RT_TxtWriteFile(String(current_frame)+Chr(9)+args,g_logpath,Append=true)
/* write frame number + tab char + statement to logfile...? */
WriteFileStart(g_logpath,String(current_frame),"Chr(9)","args",append=True)

return Eval(stat).ShowFrameNumber
}

##################################
## SoftBloom with constrained inputs and resizing
## original @ http://forum.doom9.org/showthread.php?p=1642381#post1642381
#
Function SoftBloom_B (clip Last, int "radius", int "minlevels"
\ , int "min", int "max", int "threshold", int "blur", float "sat", int "cont", float "mul") {

## (limits are set based on guesswork; please adjust if needed)
radius = Min(Max(2, Default (radius, 2)), Width / 2)
edges = (width / radius) + ((width / radius) % 2) #bigger radius smaller effect
threshold = Min(Max(16, Round (Default (threshold, 250) * 219 / 255.0) + 16), 255)
minlevels = Min(Max(-255, Default (minlevels, 0)), threshold-1)
min = Min(Max(threshold+1, Default (min, 254)), 254)
max = Min(Max(min+1, Default (max, min+1)), 255)
blur = Min(Max(0, Default (blur, 1)), 100)
sat = Min(Max(0.0, Default (sat, 0.5)), 4.0)
cont = Min(Max(16, Default (cont, 127)), 255)
mul = Min(Max(0.0, Float(Default (mul, 0.25))), 4.0)

old_wid = Width
old_hgt = height
new_wid = width / edges
new_hgt = height / edges
new_wid = Min(Max(64, new_wid), old_wid / 2)
new_hgt = Min(Max(64, new_hgt), old_hgt / 2)
new_wid = new_wid + new_wid % 2
new_hgt = new_hgt + new_hgt % 2

Mask = ConvertToRGB32 ().RGBLevelsG (min, 1.0, max, 0, 255)
\ .Levels (minlevels, 0.1, threshold, 0, 255, false)
\ .ConvertToYV12 ()
\ .GaussResize (new_wid, new_hgt, p = blur)
\ .BilinearResize (old_wid, old_hgt)
\ .Tweak (sat = sat)
\ .Levels (0, 1.0, cont, 0, 255, false)
White = BlankClip (Mask).Invert ("Y")

MT_Merge (MT_lutxy (Mask
\ ,uexpr = " y 128 < x y * 128 /"
\ ,vexpr = " y 128 < x y * 128 /", U = 3, V = 3), White, luma = true
\ ,Merge (Tweak (cont = 0, sat = 0), Mask, mul))
}


function RGBlevelsG(clip clp,
\ int "input_low", float "gamma", int "input_high",
\ int "output_low", int "output_high", bool "show_function")
{

input_low = Default(input_low, 0)
gamma = Default(gamma, 1.0)
input_high = Default(input_high, 255)
output_low = Default(output_low, 0)
output_high = Default(output_high, 255)
show_function = Default(show_function, false)

wicked = gamma > 1.0
\ ? "x " +string(input_low)+ " - " +string(input_high)+ " " +string(input_low)+ " - / 1 " +string(gamma)+
\ " / ^ " +string(output_high)+ " " +string(output_low)+ " - * " +string(output_low)+ " + x * x 255 x - * + 255 /"
\ : "x " +string(input_low)+ " - " +string(input_high)+ " " +string(input_low)+ " - / 1 " +string(gamma)+
\ " / ^ " +string(output_high)+ " " +string(output_low)+ " - * " +string(output_low)+ " + 255 x - * x x * + 255 /"

return( show_function ? clp.subtitle(wicked) : clp.rgblut(rexpr = wicked, gexpr = wicked,bexpr = wicked, R = 3, G = 3, B = 3) )
}


Logfile

frameno args
0 radius= 41, minlevels=-220, min=238, max=235, threshold= 44, sat=1.240, cont= 3, mul=1.580
0 radius= 41, minlevels=-220, min=238, max=235, threshold= 44, sat=1.240, cont= 3, mul=1.580
1 radius=262, minlevels= 145, min=117, max= 95, threshold= 76, sat=0.270, cont= 16, mul=0.910
1 radius=262, minlevels= 145, min=117, max= 95, threshold= 76, sat=0.270, cont= 16, mul=0.910
2 radius=147, minlevels= -89, min= 1, max= 81, threshold= 6, sat=2.040, cont= 77, mul=1.530
3 radius=292, minlevels=-161, min=149, max=101, threshold= 83, sat=2.950, cont= 92, mul=1.260
4 radius=175, minlevels= 19, min= 91, max= 22, threshold=167, sat=2.990, cont=205, mul=2.940
5 radius=223, minlevels= 4, min= 80, max=243, threshold= 78, sat=2.640, cont= 96, mul=1.110
6 radius=129, minlevels= -43, min=147, max=104, threshold= 22, sat=3.570, cont=147, mul=0.590
7 radius=179, minlevels=-242, min= 97, max= 13, threshold= 76, sat=2.350, cont= 5, mul=2.420
8 radius=288, minlevels= 155, min=150, max= 17, threshold=139, sat=2.480, cont=161, mul=2.050
9 radius=226, minlevels=-182, min=240, max= 50, threshold=216, sat=3.010, cont=168, mul=3.480
#end


EDIT: Darn, we got frames 0 and 1 twice each :eek:
EDIT: But RT_Debug output is correct (if uncomment). :confused: (Something in other funcs is pulling in frames 0,1 twice each)

Debug

00000005 1.84072244 SoftBloom_B [0] radius= 41, minlevels=-220, min=238, max=235, threshold= 44, sat=1.240, cont= 3, mul=1.580
00000006 2.02774215 SoftBloom_B [1] radius=262, minlevels= 145, min=117, max= 95, threshold= 76, sat=0.270, cont= 16, mul=0.910
00000007 2.18231225 SoftBloom_B [2] radius=147, minlevels= -89, min= 1, max= 81, threshold= 6, sat=2.040, cont= 77, mul=1.530
00000008 2.33077383 SoftBloom_B [3] radius=292, minlevels=-161, min=149, max=101, threshold= 83, sat=2.950, cont= 92, mul=1.260
00000009 2.47816133 SoftBloom_B [4] radius=175, minlevels= 19, min= 91, max= 22, threshold=167, sat=2.990, cont=205, mul=2.940
00000010 2.62778354 SoftBloom_B [5] radius=223, minlevels= 4, min= 80, max=243, threshold= 78, sat=2.640, cont= 96, mul=1.110
00000011 2.77748704 SoftBloom_B [6] radius=129, minlevels= -43, min=147, max=104, threshold= 22, sat=3.570, cont=147, mul=0.590
00000012 2.92913008 SoftBloom_B [7] radius=179, minlevels=-242, min= 97, max= 13, threshold= 76, sat=2.350, cont= 5, mul=2.420
00000013 3.07594872 SoftBloom_B [8] radius=288, minlevels= 155, min=150, max= 17, threshold=139, sat=2.480, cont=161, mul=2.050
00000014 3.22120976 SoftBloom_B [9] radius=226, minlevels=-182, min=240, max= 50, threshold=216, sat=3.010, cont=168, mul=3.480


However, this works fine without the double frames 0 and 1 (G_args does not need to be Global but left as is)

##################################
## SoftBloom: fuzz test input args
#
function SoftBloom_Test(clip C) {
C
## random inputs
a_radius=Rand(Width/2)
a_minlevels=Rand(512)-255
a_min=Rand(254)
a_max=Rand(255)
a_threshold=Rand(255)
a_sat=Rand(400)/100.0
a_cont=Rand(255)
a_mul=Rand(400)/100.0

args="radius=" + String(a_radius,"%3.0f") + ", minlevels=" + String(a_minlevels,"% 4.0f")
\ + ", min=" + String(a_min,"%3.0f") + ", max=" + String(a_max,"%3.0f") + ", threshold=" + String(a_threshold,"%3.0f")
\ + ", sat=" + String(a_sat,"%3.3f") + ", cont=" + String(a_cont,"%3.0f") + ", mul=" + String(a_mul,"%3.3f")

/* the following should be a valid Avisynth statement */
stat="SoftBloom_B(" + args + ")"
RT_Debug("SoftBloom_B","["+string(current_frame)+"]",args,false)
RT_TxtWriteFile(String(current_frame)+Chr(9)+args,g_logpath,Append=true)
/* write frame number + tab char + statement to logfile...? */
# WriteFileStart(g_logpath,String(current_frame),"Chr(9)","args",append=True)

return Eval(stat).ShowFrameNumber
}


EDITED as per Gavino post
EDIT: Fixed Again :(