View Full Version : BlindDeHalo() - removal of Edge Enhancement artefacts
Didée
7th April 2004, 14:04
Hello folks,
once more I did a little scripting, and came up with a procedure that seems quite usable to remove those ugly bright and dark halos from edge enhancement.
One important warning beforehand:
Be careful when using other functions of MaskTools before this script,
or when calling it before iiP() !!!
The MaskTools currently are a little tricky to use - I'll explain this further below.
First, the script:
# BlindDeHalo - v0.1
#
# This script removes the light & dark halos from too strong "Edge Enhancement"
# Adaption of the parameters has to be done manually for each source, the function is not adaptive.
#
# Needed Plugins: MaskTools.dll >= 1.4.15
# undot.dll
#
function BlindDeHalo( clip clp, int "strength", int "radius_x", int "radius_y", float "darkamount", string "mode", float "maskblur", bool "fullframe" )
{
strength = default( strength, 80)
radius_x = default( radius_x, 2)
radius_y = default( radius_y, 2)
darkamount = default( darkamount,1.0)
mode = default( mode, "soft")
maskblur = default( maskblur, 1.0)
fullframe = default( fullframe, false)
modus = mode=="hard" ? "hardlight" : "softlight"
ox = clp.width
oy = clp.height
rx = sqrt(radius_x)
ry = sqrt(radius_y)
clp
edge=Dedgemask(0,255,0,255,"6 10 6 10 -64 10 6 10 6",setdivisor=true,divisor=64).levels(2,0.5,6,0,255,false).undot#.coloryuv(analyze=true)#
blur1 = bicubicresize(int((ox/rx)/4 +.5)*4,int((oy/ry)/4 +.5 )*4,-1.0,1.0).lanczosresize(ox,oy)
blur2 = bicubicresize(int((ox/rx)/4 +.5)*4,int((oy/ry)/4 +.5 )*4, 1.0,0.0).lanczosresize(ox,oy)
diff = YV12subtract(blur1,blur2)
overlay(diff,diff,mode="hardlight").levels(0,1.0,255,88,168,false)
darkamount == 1.0 ? NOP : overlay(last,last.levels(0,1.0,128,int(128-128*darkamount),128,false),mode="lighten")
overlay(last,last.levels(0,1.0,255,128+strength,128-strength,false)) # levels reversed: no more "invert" in below overlay()
overlay(clp,last.greyscale.blur(maskblur),mode=modus)
fullframe ? NOP : MaskedMerge(clp,last,edge.deflate.expand.blur(1.58).inflate,useMMX=true)
return(last)
}
#
The most basic usage is as simple as: BlindDeHalo()
However, there are several parameters to adjust the filtering, and you definetly want to setup those parameters manually for each source.
Basically, the following is what is going on:
- The script does not reckognize any halos in the source! It simply looks for hard edges, and reduces the contrast in their neighborhood.
- A gaussian blurred (well, sort of that) version of the clip is subtracted from a sharpened version. This delivers a mask that is suited for the given purpose.
- Then, the source clip is "Softlighted" by this mask, et voilà ...
Parameter description
strength [int]
The overall strength of contrast reduction around hard edges. Default is 80, usuable range is 0 - 128.
radius_x, radius_y [int] [int]
This is [similar to] the radius of a gaussian blur. These radii must be adjusted to match the "thickness" of the halos in your source. Default is 2, usable range is from 2 to about 5.
Note: A radius of 1 disables the processing in the corresponding direction. E.g. for VHS-caps, setting radius_y=1 and radius_x=3|4|5 should be the right thing. (Didn't test this myself.)
darkamount [float]
With this parameter, the removing of dark halos can be reduced. A value of 1.0 will treat both bright and dark halos equally, 0.5 will process dark halos with only half the strength, 0.0 will disable the processing of dark halos.
Explanation: Theroretically, bright & dark haloing should be always equal. But I encountered some sources where the bright halos seemed to be much stronger than the dark ones, and so I implemented this parameter.
Moreover, generally bright halos are more distracting than dark ones. So it might be a good idea to process the dark ones a little weaker, to retain more overall contrast in the clip.
Default is 1.0 however, as this gives the fastest processing speed ;)
mode [string]
This can be either "soft" or "hard", and simply decides wether to use 'softlight' or 'hardlight' in the final 'overlay()' command.
Default is "soft". You might try "hard" along with some lower values for "strength" - dunno if this may turn out useful somewhere.
maskblur [float]
This simply tells how strong the lightmask will be blurred. Stronger blurring will keep a little more sharpness in the clip, but will reduce the halo removal a little.
Default is 1.0, range is 0.0 - 1.58. Play and see for yourself.
fullframe [bool]
This is mainly a bug-workaround for a specific strangeness in the current MaskTools.
"false" is (or should be) the best setting regarding IQ. But if set to false, the YV12LUT command from MaskTools will work *no more* after calling BlindDeHalo! This is poison for e.g. iiP() ...
Set it to "true" if you need YV12LUT() after calling BlindDeHalo(), or if you're going to use it as pre-processor for iiP. (I will integrate it in the near future into iiP, anyway).
IMHO, this function can be set up to be way more effective against halos than e.g. using unfilter(-,-) -- better removal of halos, less damage to fine details and overall sharpness.
However, my testing so far was not very extensive: Your experiences, suggestions and flames are welcome.
(BTW, this script is *fast*, compared to Didée's usual standard: a 16:9 704*432 frame gets processed at ~10 fps on my XP1800.)
Have fun
- Didée
Zarxrax
7th April 2004, 14:15
Awesome work! I never found unfilter terribly effective against halos, so its very nice to see another option.
DarkNite
8th April 2004, 10:41
Thank you for including the darkamount parameter. That was a really nice touch followed by an all too true explanation.
I look forward to seeing BlindDeHalo's features included in iiP. Not that it wasn't good enough already. :D
Soulhunter
8th April 2004, 22:02
Thx! ;]
Mug Funky
9th April 2004, 11:29
nice stuff. i've got to eat before i fall over (yeah... i use the computer while standing :confused: ), but i will check out on some DV footage, and maybe later with r4 Akira (or did i lend that to someone?) which is very good apart from being obviously sharpened.
digitize
9th April 2004, 18:55
Perhaps this is just me being an idiot, not sure. I have masktools 1.4.2 (b/c i have an athlon xp), yet I get an error because it doesn't recognize Dedgemask, any idea.
Manao
9th April 2004, 23:48
Yep : get the latest version of the masktools :
http://www.geocities.com/manao47/Filters/
digitize
10th April 2004, 14:26
Yep I read the required version incorrectly (read it as 1.4.1.5, rather than 1.4.15) thanks for posting the link.
Decimal versioning is much more logical, just look at mfToon :D.
kilg0r3
10th April 2004, 16:04
I know this a lame question ... How are the speeds compared to an unfiltered encode?
Didée
10th April 2004, 19:24
kilg0r3:
Bad boy, you are ;) -- I could swear to have read this question already before, but a few posts further above ;) /*me waves finger*/
Well, what holds you back from playing 1000 frames once with, once without BlindDeHalo, and compare for yourself?
But okay ... let me put it this way: it's roughly 3.5 times slower than Convolution3D_YV12.
Was that helpful in any way now? :D
You won't expect realtime performance from a script that uses
- 4 resizers
- a subtract operation
- an EdgeMask
- 3~5 different overlay()'s
won't you.
- Didée
DeepDVD
17th August 2004, 03:51
WOW Didée!
Nice work.
In a team with your newest iiP-version (i know, it's not projected to fix animes ;) but it bring me back some details of my old VHS-anime that no filter could do as good before!)
and
mf's Toon-Function (that had force me to seek for a solution for his coronamask-haloing :angry: ... somebody have a try bringing him back on his scratchboard programming out his errors ;))
I get a very good version out of my VHS-Rip-DivX ...
I hope, the preversion of mf's correction ( not a new version :devil: ) will be gold soon... let's hope all together :D
so far
Didée
17th August 2004, 08:49
Originally posted by DeepDVD
the preversion of mf's
Hihi ... I know I should read "pre-version", but somehow I'm forced to read "perversion". Language is a funny thing.
Think of LimitedSharpen() (http://forum.doom9.org/showthread.php?s=&postid=532809#post532809), though. Sometimes, on some sources, I prefer it over iiP, or even use it as pre- or postproc for it (with softer iiP settings). Depends on circumstances, as usual.
- Didée
FlimsyFeet
10th December 2004, 12:32
So... and this is probably a lame question...
Is it better to crank up the sharpness at the source, and capture oversharp, then use BlindDeHalo() to remove the edge enhancement, or is it better to capture a bit softer to begin with then use LimitedSharpen() afterwards?
It's something I plan to test out for myself I just wondered what the opinions of the experts were.
Socio
10th December 2004, 13:54
Awesome Didee!
So I understand the correct use, it would be better to run this after IIP if you are using it but before LimitedSharpen if you using it?
Didée
10th December 2004, 16:00
Ooops ... I found something on my HD:
function BlindDeHalo2( clip clp, float "rx", float "ry", int "strength", bool "interlaced" )
{
rx = default( rx, 3.00 )
ry = default( ry, 3.00 )
strength = default( strength, 125 )
interlaced = default( interlaced, false )
function m4(float x) {return(x<16?16:int(round(x/4.0))*4)}
i = interlaced==false ? clp : clp.separatefields()
oxi=i.width
oyi=i.height
mm2=yv12lutxy(i.expand().blur(.8).expand(),i.inpand.blur(.8).inpand(),yexpr="x y - 2 *")
RR=string((rx+ry)/2.0)
ST=string(float(strength)/100.0)
sm1= i.bicubicresize(m4(oxi/rx),m4(oyi/ry)).bicubicresize(oxi,oyi,1.0,.0)
sm1d=yv12lutxy(i,sm1,yexpr="x y - 18 "+ST+" / "+RR+" / / 128 +")
sm1d=overlay(sm1d,sm1d,mode="hardlight")
clean=yv12lutxy(i,sm1d,yexpr="x y 128 - -").mergechroma(i)
clean1=maskedmerge(i,clean,mm2.expand.blur(1.58).expand .levels(32,1.0,255,0,208,false))
interlaced?clean1.weave():clean1
return last
}
rx,ry [float] - the [assumed] radius at which the EE formerly was done
strength [int] - hmh, I forgot what this is for ;) - but I remember it should be between 0 and 200
interlaced [bool] - either for interlaced sources, or for progressive ones where the EE was applied on a field-basis, not on a frame-basis
A setting of (2.0,2.0,100) will do almost no harm even to a source that doesn't have any EE.
A setting of (3.25,3.25,150) should let vanish even very strong EE that was formerly applied at a radius of 3.
Don't forget the MaskTools v1.5.5 (http://manao4.free.fr/MaskTools-v1.5.5.dll), in case anyone doesn't have them yet ...
Synthetic example:
http://img83.exs.cx/img83/7900/bdhbefore0rp.jpg
http://img83.exs.cx/img83/5599/bdhafter5ev.jpg
http://img83.exs.cx/img83/1403/bdhoriginal0jw.jpg
Socio
10th December 2004, 18:57
Very Cool!
You would simply call it is like this correct?
BlindDeHalo2(2.0,2.0,100)
Going to test this out later today!
Soulhunter
10th December 2004, 19:03
Nice!
Bye
Socio
11th December 2004, 00:19
I tried to test the first one and got a script error;
"MaskedMerge does not have a named argument "Use MMX""
I am using Masktools 1.5.5 so I am not sure what is causing it.
Second version seems to be working, doing a test run now.
Edit: I removed the "useMMX=true" from the first script and it seems to be working, running a test now.
Chainmax
11th December 2004, 00:21
Soulhunter: maybe BlindDeHalo2(3.25,3.25,150) will spare me of having to use exorcist on that crappy video I sent you a while ago :).
Soulhunter
11th December 2004, 14:47
Originally posted by Chainmax
Soulhunter: maybe BlindDeHalo2(3.25,3.25,150) will spare me of having to use exorcist on that crappy video I sent you a while ago :).
Just try it... ;)
Guess it blows all halos away !?!
Bye
dbzgundam
11th December 2004, 21:05
Just... Wow.
It eliminated all the halos on all of my EE'ed discs (That I tested), and even helped TV rips of anime! :eek:
Soulhunter
13th December 2004, 00:33
Yeah, its like... magic !!!
BlindDeHalo2(3,3,200).LimitedSharpen()
http://img32.exs.cx/img32/2658/magic0my.png
Bye
Didée
13th December 2004, 03:30
:) :)
But don't you think that's the story's end: christmas is still to come ... ;)
Wilbert
13th December 2004, 17:20
@Soulhunter,
Such a nice girl :) Why do you blur her so much with the result that you can hardly seen her face anymore?
Kagura
13th December 2004, 20:00
*snickers*
Blurring something so badly that you have to call a sharpener to recover details? That doesn't sound like good filtering. Maybe you should try toning down the strength of dehalo.
Off topic: Limitedsharpen is best as smode = 1
Soulhunter
13th December 2004, 20:27
@ Wilbert
Well, its was only a "remove all the halos" test...
Guess BlindDeHalo2(3,3,150) would be already enough !?!
Take a closer look @ the source, imo it looks already very blurry...
The sharpness is mainly "virtual" and caused by the edge-enhancement !!!
Originally posted by Kagura
Blurring something so badly that you have to call a sharpener to recover details? That doesn't sound like good filtering. Maybe you should try toning down the strength of dehalo.
Nah, this sounds like -> BlindDeHalo2 does the opposite of LimitedSharpen... :sly:
BlindDeHalo2 removes halos, but LimitedSharpen sharpens without producing halos !!!
Bye
Chainmax
13th December 2004, 23:44
Wow, the last picture looks so much more natural than the first one :eek:. Was that really just BDH2 and LS at work? :eek: :eek:
P.S: there is too much smoothing going on though, it's especially noticeable in the necklace (or whatever that thing around her neck is called).
Socio
14th December 2004, 00:03
Soulhunter
You should try that pic again with the fist BlindDeHalo Didee posted I like that one little better does not seem blur or soften near as much.
ObiKenobi
14th December 2004, 01:51
Your new version is quite nice. I use it in conjunction with HQDering, which seems to get rid of some of the dark halos that BlindDeHalo misses, and I get quite nice results.
Source:
http://img72.exs.cx/img72/446/Original.png
HQDering(255) & BlindDeHalo2(2.5,2.5,100)
http://img72.exs.cx/img72/3908/HQDeringBlindDeHalo.png
Soulhunter
14th December 2004, 03:26
@ Wilbert, Kagura, Chainmax, Socio...
Source
http://img96.exs.cx/img96/4816/01source2yr.png
Source + EE
http://img96.exs.cx/img96/5357/01ee9cq.png
Source + EE + BlindDeHalo2
http://img96.exs.cx/img96/9468/01blinddehalo2331409or.png
Bye
Kagura
14th December 2004, 05:32
Now that's more like it. =P
Corran
14th December 2004, 05:37
Except now her eyelids are pink. :P
Soulhunter
14th December 2004, 06:10
Originally posted by Corran
Except now her eyelids are pink. :P
Mainly coz BlindDeHalo2 dont processes the chroma, but the sharpening does... ;)
http://img123.exs.cx/img123/3608/source9zw.pnghttp://img123.exs.cx/img123/8431/sharp0bp.png
Bye
Didée
14th December 2004, 10:25
Soulhunter:
Thanks for holding up :)
Next time I need a varlet to rage against some windmills, I'll call ya ... :D
BTW, poor Jeanette shows _severe_ bad'n ugly oversharpening, and there's not too much left hiding behind the artefacts... Is that an "original" source, or did you add some enhancement manually?
Wilbert, Kagura:
You should give a 2nd thought on the topic. Know the story about the mathematician that inspected the two only barber shops in a small village, found one shop dirty&ugly with the barber's hair terribly dressed, the other shop bright & clean with the barber having his hair in perfect shape, and then went to the ugly shop to get his hair done ... ? ;)
I fully understand your reactions: "Okay, halos might be gone - but it looks so unimpressing afterwards, has so little contrast..." - and IMO that's exactly how it has to be: First remove the "wrong" sharpening, but keep what's behind the artefacts. Then (eventually) go on and make a better enhancement than the original one.
To find a (too short) explanation about what's the actual problem and what's my opinion about it, as well as an example of what BlindDH2 basically is trying to achieve, please look here (http://mf.onthanet.nl/forum/index.php/topic,133.msg1207.html#msg1207) (Morpheus' pictures are the deal).
To convince yourself, make this little experiment:
a = anysource()
b = a.UnsharpMask(127,3,0)
c = b.BlindDeHalo2(3.1,3.1,110) # around these values ... fork a little around
a = a.subtitle("orig")
b = b.subtitle("enhanced")
c = c.subtitle("BlindDeHalo2")
interleave(a,b,c,a)
Soulhunter
14th December 2004, 18:54
Originally posted by Didée
BTW, poor Jeanette shows _severe_ bad'n ugly oversharpening, and there's not too much left hiding behind the artefacts... Is that an "original" source, or did you add some enhancement manually?
I enhanced the halos with some "slight" sharpening !!!
Unfortunately some of my tv channels really look like this... :(
But thats mainly caused by the very bad analog signal I receive !!!
Bye
Kagura
14th December 2004, 19:31
Didée, I wasn't insulting blinddehalo. Rather, I merely thought that Soulhunter used too strong values in reducing halos on his first two pics.
SirCanealot
17th December 2004, 20:17
Has anyone got any suggested settings or advice for using this on anime?
I can get it to remove SOME of the halos, but it does as much damage to random high-contrast parts of the picture as it does EE removal.
Thanks all.
I'll post some screenies and what settings I'm trying if anyone wants - I'm really having little luck with anime and this :/
State of Mind
17th December 2004, 21:41
Can someone give me a direct download link for this filter, please? I wish to test it on some DV footage.
Soulhunter
17th December 2004, 21:55
Originally posted by State of Mind
Can someone give me a direct download link for this filter, please?
Its a function... (http://forum.doom9.org/showthread.php?s=&threadid=74003#post579853) ;)
Save it as avs n' import it in ya scripts !!!
Bye
dvwannab
17th December 2004, 22:09
Originally posted by State of Mind
Can someone give me a direct download link for this filter, please? I wish to test it on some DV footage.
Hi State of Mind!! Glad you took my advice and come over here. These guys are fantastic arent they? This is place to play with, test and learn avisynth. I am gonna be testing this new filter also.
Good luck. To use BlindHalo2, you have to copy the code (link above) and paste into wordpad and save as blindhalo2.avs. Then use import command. Ex.
Loadplugin("C:\avisynth\filters\xxxx.dll")
Import("C:\avisynth\filters\blindhalo2.avs")
Also need MaskTools 1.5.5.
State of Mind
18th December 2004, 02:33
To use BlindHalo2, you have to copy the code (link above) and paste into wordpad and save as blindhalo2.avs. Then use import command. Ex.
What link?
Socio
18th December 2004, 03:43
Originally posted by SirCanealot
Has anyone got any suggested settings or advice for using this on anime?
I can get it to remove SOME of the halos, but it does as much damage to random high-contrast parts of the picture as it does EE removal.
Thanks all.
Try the first BlindDeHalo Didee posted, top page #1 instead of BlindDeHalo2.
ObiKenobi
18th December 2004, 04:48
Originally posted by State of Mind
What link?
Soulhunter's post at the bottom of the first page.
Soulhunter
18th December 2004, 18:35
Originally posted by ObiKenobi
Soulhunter's post at the bottom of the first page.
Bottom of 2nd page... ;)
EDIT: At least with the default "Posts per Thread" settings !!!
Bye
ObiKenobi
18th December 2004, 23:10
Originally posted by Soulhunter
Bottom of 2nd page... ;)
Bye
Well for me it's the first page. :p
Soulhunter
19th December 2004, 00:02
Originally posted by ObiKenobi
Well for me it's the first page. :p
Ok, Ive edited my last post... ;)
Bye
Blue_MiSfit
29th December 2004, 08:40
Awesome script didee! Works extremely well on the film "Human Stain" that displays horrendous edge enhancement haloing.
BlindDeHalo(2,2,100)
Preserves sharpness much better than
UnFilter(-20,-20)
Well done, though it took me awhile to get the proper versions of the BlindDeHalo / MaskTools in order :) Speed isn't bad at all, 6-10fps on my A64 @ 2.34GHz with a 960x480 (lanczos4resized) encode in the firstpass for xvid 1.1.
Very nice :)
~misfit
BlackMetal
21st January 2005, 10:28
Hi, I'm trying to use BlindDeHalo2, but I get the following error:
Script error: there is no function named "overlay"
I've tried with MaskTools 1.5.1, 1.5.5, 1.5.6 and -p4-5.
Does anyone know what's wrong?
Manao
21st January 2005, 10:31
It's not a filter of the masktools, but of avisynth. What is your avisynth version ?
BlackMetal
21st January 2005, 10:47
Originally posted by Manao
It's not a filter of the masktools, but of avisynth. What is your avisynth version ?
Yes, you were right. I had avisynth v2.5.2.0.
Now I tried with v2.5.5.0 and it worked.
Thanx! :)
Socio
21st January 2005, 14:59
Originally posted by Blue_MiSfit
Awesome script didee! Works extremely well on the film "Human Stain" that displays horrendous edge enhancement haloing.
BlindDeHalo(2,2,100)
Preserves sharpness much better than
UnFilter(-20,-20)
~misfit
Hey that gives me an idea;
Didee, what would happpen if you replace Unfilter in your IIP script with BlindDeHalo2?
Didée
21st January 2005, 16:35
Nothing spectacular would happen.
Remember that iiP offers two different methods for deringing: its "old" routine (called with positive "dering" values) - that's the one which is using "unfilter" -, and the "new method" (called with negative "dering" values), which most times works better in iiP's context.
BlindDH2() is effective against Halos, but doesn't do all too much about mosquito noise. The "new" deringing method of iiP is better suited as "general purpose" deringing filter, as it's designed to counteract both types of artefacting.
So ... if at all, then it's iiP's method that should be merged into BlindDeHalo(), not the other way round ;)
Drifting from topic, that's how LimitedSharpenEX() will be alike: It will clobber you over the head with ... possibilities :)
On the de-ringing/de-haloing side, you'll have a variety of choices - 2 or 3 main types of operation, each coming along with 2 or 3 sub-types of slightly different strengths or characteristics.
Then there will be an asymmetric sharpener available, especially for VHS processing, but perhaps also for aspect conversions 1:1 <--> anamorhic, back'n forth.
Not to mention that the LimitedSharpen principle will be extended by a detail crystality enhancer, an area adaptive contrast booster, and optional color enhancement. Also, some easy implementations of gauss/sharp-mixing will be in.
But there was something more, whatwasit, whatwasit ... ah yes, that little "noise-bypass-sharpening" functionality ... :)
As can be seen, a bunch of topics that arose in this forum in the last few weeks, have already been on my mind when I started the project last autumn ... "Didée, master of sluggish development" :(
(If only I'd find more time to work on it, again. The finishing state drags out like chewing gum, but I won't release some half-finished alpha-thingy of such complexity.)
Macanudo
21st January 2005, 16:43
Originally posted by Didée
Drifting from topic, that's how LimitedSharpenEX() will be alike: It will clobber you over the head with ... possibilities :)
On the de-ringing/de-haloing side, you'll have a variety of choices - 2 or 3 main types of operation, each coming along with 2 or 3 sub-types of slightly different strengths or characteristics.
Then there will be an asymmetric sharpener available, especially for VHS processing, but perhaps also for aspect conversions 1:1 <--> anamorhic, back'n forth.
Not to mention that the LimitedSharpen principle will be extended by a detail crystality enhancer, an area adaptive contrast booster, and optional color enhancement. Also, some easy implementations of gauss/sharp-mixing will be in.
But there was something more, whatwasit, whatwasit ... ah yes, that little "noise-bypass-sharpening" functionality ... :)
[/B]
Stop...You are making me drool...(insert picture of Homer Simpson staring at a box full of donuts)...LOL.
Socio
21st January 2005, 18:12
Originally posted by Macanudo
Stop...You are making me drool...(insert picture of Homer Simpson staring at a box full of donuts)...LOL.
I say lock Didee in a room til it's finished!
dvwannab
21st January 2005, 18:17
Originally posted by Didée
Nothing spectacular would happen.
Remember that iiP offers two different methods for deringing: its "old" routine (called with positive "dering" values) - that's the one which is using "unfilter" -, and the "new method" (called with negative "dering" values), which most times works better in iiP's context.
BlindDH2() is effective against Halos, but doesn't do all too much about mosquito noise. The "new" deringing method of iiP is better suited as "general purpose" deringing filter, as it's designed to counteract both types of artefacting.
So ... if at all, then it's iiP's method that should be merged into BlindDeHalo(), not the other way round ;)
Drifting from topic, that's how LimitedSharpenEX() will be alike: It will clobber you over the head with ... possibilities :)
On the de-ringing/de-haloing side, you'll have a variety of choices - 2 or 3 main types of operation, each coming along with 2 or 3 sub-types of slightly different strengths or characteristics.
Then there will be an asymmetric sharpener available, especially for VHS processing, but perhaps also for aspect conversions 1:1 <--> anamorhic, back'n forth.
Not to mention that the LimitedSharpen principle will be extended by a detail crystality enhancer, an area adaptive contrast booster, and optional color enhancement. Also, some easy implementations of gauss/sharp-mixing will be in.
But there was something more, whatwasit, whatwasit ... ah yes, that little "noise-bypass-sharpening" functionality ... :)
As can be seen, a bunch of topics that arose in this forum in the last few weeks, have already been on my mind when I started the project last autumn ... "Didée, master of sluggish development" :(
(If only I'd find more time to work on it, again. The finishing state drags out like chewing gum, but I won't release some half-finished alpha-thingy of such complexity.)
WOOOHOOOO baby!!!! Bring it on..........bring it on :D
ATM
5th February 2005, 00:45
Just wanna add that I love BlindDeHalo2 and can't wait for you to bring out LimitedSharpenEX.
These two shots are from Episode 10 of Trigun from the R2 DVDs
Source:
http://img222.exs.cx/img222/3231/source8lw.png
Filtered with BlindDeHalo2(2.5,2.5,160) & LimitedSharpen(ss_x=2.0,ss_y=2.0,Smode=3,strength=100):
http://img222.exs.cx/img222/1920/filtered8km.png
And the second example:
Source:
http://img222.exs.cx/img222/6365/source29ah.png
Filtered with BlindDeHalo2(2.5,2.5,160) & LimitedSharpen(ss_x=2.0,ss_y=2.0,Smode=3,strength=100):
http://img222.exs.cx/img222/1394/filtered21ck.png
dvwannab
20th February 2005, 00:50
ATM,
Nothing meant by my comments, but first I didnt see anything wrong with your source and the applied filters gave a washed-out look. Loss in contrast and saturation. Dont see how LS & Blind helped at all. Actually, they took away. May want to tweak your settings or just not do anything at all :D
KaiserS
20th February 2005, 02:18
Originally posted by dvwannab
ATM,
Nothing meant by my comments, but first I didnt see anything wrong with your source
You mean other then the strong EE haloes?
Originally posted by dvwannab
and the applied filters gave a washed-out look. Loss in contrast and saturation. Dont see how LS & Blind helped at all. Actually, they took away. May want to tweak your settings or just not do anything at all :D
They took away the EE and nothing else. Neither BlindDeHalo or LS have any effect on contrast or saturation, and those were the only filters applied. So I have no clue what you are referring to. The EE gives a perceived increase in contrast, but that is completely artificial (same way that it gives a perceived higher level of detail when in fact its just the opposite).
KaiserS
20th February 2005, 02:35
Here are the two histograms based on the 2nd screenshots.
*Removed pics see below*
There is a bit of difference in the luma channel but only at the outlying parts (due to the EE haloing being removed). In the color channels there is no real change at all. So I'm not sure how you can say there is washed out colors when the color channels haven't been changed to any noticeable extent.
Backwoods
20th February 2005, 02:50
I notice it too and argee with dvwannab.
KaiserS
20th February 2005, 02:51
And if you want it displayed out numerically here you go:
*Removed pics see below*
As this shows, there is no difference between the color channels at all. The only difference is in the luma channel, but like I said before this is only at the outlying part due to the EE removal.
KaiserS
20th February 2005, 02:53
Originally posted by Backwoods
I notice it too and argee with dvwannab.
Except as I've showed in 2 examples there is no change in the color channels, as BlindDeHalo and LS don't work on the chroma only luma, so this notion that the second is "washed-out" is completely untrue. The only difference between the pics is in the luma channel and only in the outlying parts where the EE was removed. I don't deny that he may percieve a difference, but in reality there isn't and the histograms and the output from ColorYUV show this.
I think you two may want to give this page: http://www.videophile.info/Guide_EE/Page_01.htm a look at.
Backwoods
20th February 2005, 03:17
After flipping the two images back and forth between each other, I see the differences more now. In the thread the source appears to be sharper and more vibrant of colours, but also it appears you did get rid of the EE at a cost of dimming the black lines.
KaiserS
20th February 2005, 05:03
Originally posted by Backwoods
In the thread the source appears to be sharper and more vibrant of colours, but also it appears you did get rid of the EE at a cost of dimming the black lines.
Of course it appears sharper thats what EE is used for but in reality it isn't really sharper, sharpness being defined by level of detail, it just gives the appearance of sharpness (look at the first example on the link I posted and it shows what I'm talking about). And yes, the thinning of the lines is a result of BlindDeHalo, but with something like FastLineDarken they can be darkened and thickened up. For me, I like the look of it with thinner lines then the thick ones, but that's just me. And since the color channels aren't being modified its impossible for one to look more vibrant then the other (if the chroma channels were being modified I could see where you are coming from but they are untouched).
If the source hadn't had any EE applied to it, it would have looked more like the 2nd pictures (minus the thinner lines).
KaiserS
20th February 2005, 05:52
Rather then working off the pngs provided by ATM, since I have to do a ConvertToYV12 to do the the analysis, and since I have the R2 DVDs as well so I'll just use my DVDs instead.
Source:
http://img195.exs.cx/img195/766/source9kt.png
Filtered with BlindDeHalo2(2.5,2.5,160) & LimitedSharpen(ss_x=2.0,ss_y=2.0,Smode=3,strength=100)
& FastLineDarken(strength=100):
http://img195.exs.cx/img195/73/source20xw.png
Notice how the color channels aren't being changed at all, as like I said before neither BlindDeHalo or LS work on the chroma channel, and the only difference in the loose min and max between the source and filtered is the upper end of the luma which is due to the bright halos being removed. So while you may think that the colors are different in one from the other they aren't otherwise there would be a difference between the color channels given by ColorYUV. :)
Backwoods
20th February 2005, 07:54
Yes I realize that after the first reply you mentioned. I stand corrected. In this case the EE worked, it fooled me into thinking it was sharper.
Your filtering does correct the image and the black lines seem to fit in more with the overall image but still looked bland. I've heard of FastLineDarken and was going to mention it in my post but I forgot the exact name of the filter (or is it script?). It really makes a difference to your final product. Whenever I watch anime and notice EE (didn't know it was EE) I figured it was how cells looked on the painted backgrounds while being photographed to film. Didn't know it was actually EE. With FastLineDarken, great results.
KaiserS
20th February 2005, 08:04
Originally posted by Backwoods
Yes I realize that after the first reply you mentioned. I stand corrected. In this case the EE worked, it fooled me into thinking it was sharper.
Yep and if you watch dvds like this on a normal interlaced set you might not even notice the EE. When watching these discs on a Hi-def 60" screen the haloing on these discs becomes quite noticeable and distracting. At some point when I get a dual layer burner I'm going to reauthor the discs using this filter chain which should make it a bit more pleasant to watch on the big screen tv. :)
dvwannab
22nd February 2005, 16:06
thanks for the detailed explanation KaiserS. I definitely see what you are talking about. Thanks for the educational lesson. Much appreciated. ;)
I assume the EE-effect is also present in broadcast TV mpeg2 captures as well? No?
Didée
9th March 2005, 15:11
To my own surprise, I had some free time yesterday evening. So here is BDH's third incarnation:
BlindDeHalo3
Basically, it does the same as the 2nd version did. New are some tweaking possibilities (partly backported from BDH's initial version), an optional "postprocessing" mode, and ... better performance.
Feeding a cropped 720*432 DVD source, my Athlon XP1800 renders like this:
BDH2: ~10 fps
BDH3: ~25 fps (without PP)
I hope there are no objections against this minor performance increase :D
With PP activated, the performance gain is smaller: ~13 fps in above example. Also, I'm not yet really satisfied with the PP mode. But it may come handy in its current state already, and I don't want to keep that speedy version back from you, just because of that.
Let's start with parameters and explanations. The function comes at the end, as usual.
Full function call with default values:
BlindDeHalo3( rx=3.0, ry=3.0, strength=125,
\ lodamp=0.0, hidamp=0.0, sharpness=0.0, tweaker=0.0,
\ PPmode=0, PPlimit=0, interlaced=false)
Parameter description
rx, ry [float]
The radii to use for the [quasi-] gaussian blur, on which the halo removal is based..
strength
The overall strength of the halo removal effect.
lodamp, hidamp [float] (range: 0.0 ~ ??? / try 4.0 as a start)
With these two values, one can reduce the basic effect on areas that would change only little anyway (lodamp), and/or on areas that would change very much (hidamp).
lodamp does a reasonable job in keeping more detail in affected areas.
hidamp is intended to keep rather small areas that are very bright or very dark from getting processed too strong. Works OK on sources that contain only weak haloing - for sources with strong oversharpening, it should not be used, mostly.
(Usage has zero impact on speed.)
sharpness [float] (range: 0.0 ~ 1.58)
By setting this bigger than 0.0, the affected areas will come out with better sharpness. However, strength must be chosen somewhat bigger as well, then, to get the same effect than without.
(This is the same as initial version's "maskblur" option.)
tweaker [float] (range: 0.0 ~ 1.0)
May be used to get a stronger effect, seperately from altering "strenght".
(Also in accordance to initial version's working methodology. I had no better idea for naming this parameter.)
interlaced
As formerly, this is intended for sources that were originally interlaced, but then made progressive by deinterlacing. It aims in particular at clips that made their way through Restore24.
[b]PPmode [int]
When set to "1" or "2", a second cleaning operation after the basic halo removal is done. This deals for
a) removing/reducing those corona lines that sometimes are left over by BlindDeHalo
b) improving on mosquito noise, if some is present.
PPmode=1 uses a simple gaussian blur for post-cleaning. PPmode=2 uses a 3*3 average, with zero weigthing of the center pixel.
Also, PPmode can be "-1" or "-2". In this case, the main dehaloing step is completely discarded, and *only* the PP cleaning is done. This has less effect on halos, but can deal for sources containing more mosquito noise than halos.
PPlimit [int]
Can be used to make the PP routine change no pixel by more than [PPlimit].
I'm not sure if this makes much sense in this context. However the option is there - you never know what it might be good for.
Comments & tips
Well, I just fiddled it together and checked that everything is working ... there's not very much practical experience yet I can share with you, about the new stuff. However:
- All that PP stuff isn't yet optimized. But it's difficult to make that part noticeably smarter without an aching slowdown, I fear. Try it, share your opinions. Make suggestions.
- Regarding "strength" & "sharpness" & "tweaker"
These three behave somewhat [i]similar, but not the same.
A bigger value for "sharpness" is similar to reducing "strength". A bigger value for "tweaker" is similar to increasing "strength" value -- and vice versa for both.
Also the other way round: when increasing "sharpness", you probably have to increase "strength" a little as well, to get the same removal effect.
Usage of "sharpness" works in particular good when bigger radii (say, >2.5) are used for dehaloing. Usage of "tweaker" is more useful when working with sources containing thin, weak halos.
In the end, it comes down again to try&error ;)
- lodamp and hidamp
Technically, these two are the "n" constants in two scaling factors of the form "x/(x+n)", which are used when creating a LUT from the difference between input clip and its gaussian blurred version.
As described above, "lodamp" deals for better protection of areas where this difference is alredy small. Effectively, it preserves some more of weak detail in areas of high contrast. A value of 4.0 seems a good starting point. One can also try to use bigger values like 16.0 or so, along with a bigger "strength" value. By this, one can somewhat change the characteristics of "what-is-processed-how-strongly" (if I can say so).
"hidamp" tries to do the opposite: protect small detail that is very bright or very dark from being toned down too much. But its usability is much more restricted: it seems to work OK when the actual halos of the source are rather weak, and/or when not too small radii are used - in this case, the protection of very prominent detail works out, mostly.
In case the source contains strong haloing, is's better to not use "hidamp" at all: in this case, the halos itself would be considerd to be "prominent detail" and be protected ... no go.
I think this is close to a "final" version of BlindDeHalo (without a number in the name ;) )
The function script is attached to this post, and will show up upon approval. For reference, the script is posted below.
Have fun!
Didée
9th March 2005, 15:12
Here's the script:
function BlindDeHalo3( clip clp, float "rx", float "ry", int "strength",
\ float "lodamp", float "hidamp", float "sharpness", float "tweaker",
\ int "PPmode", int "PPlimit", bool "interlaced")
{
rx = default( rx, 3.0 )
ry = default( ry, 3.0 )
strength = default( strength, 125 )
lodamp = default( lodamp, 0.0 )
hidamp = default( hidamp, 0.0 )
sharpness = default( sharpness, 0.0 )
tweaker = default( tweaker, 0.0 )
PPmode = default( PPmode, 0 )
PPlimit = default( PPlimit, 0 )
interlaced = default( interlaced, false )
sharpness = (sharpness>1.58) ? 1.58 : sharpness
tweaker = (tweaker > 1.00) ? 1.00 : tweaker
strength = float(strength)*(1.0+sharpness*0.25)
RR = string((rx+ry)/2.0)
ST = string(float(strength)/100.0)
LD = string(lodamp)
HD = string(pow(hidamp,2))
TWK0 = "x y - 12 "+ST+" / "+RR+" / /"
TWK = "x y - 12 "+ST+" / "+RR+" / / abs"
TWK_HLIGHT = "x y = 128 "+TWK+" 128 "+TWK+" - "+TWK+" 128 / * + "+TWK0+" "+TWK+" "+LD+" + / * "
\ + "128 "+TWK+" - 20 / 2 ^ 128 "+TWK+" - 20 / 2 ^ "+HD+" + / * 128 + ?"
i = (interlaced==false) ? clp : clp.separatefields()
oxi = i.width
oyi = i.height
sm = i.bicubicresize(m4(oxi/rx),m4(oyi/ry))
mm = yv12lutxy(sm.expand,sm.inpand,"x y - 4 *").expand.deflate.blur(1.58).bicubicresize(oxi,oyi,1.0,.0)
sm = sm.bicubicresize(oxi,oyi,1.0,.0)
smd = yv12lutxy(i.sharpen(tweaker),sm,TWK_HLIGHT)
smd = (sharpness==0.0) ? smd : smd.blur(sharpness)
clean = yv12lutxy(i,smd,yexpr="x y 128 - -").mergechroma(i)
clean = maskedmerge(i,clean,mm)
LL = string(PPlimit)
LIM = "x "+LL+" + y < x "+LL+" + x "+LL+" - y > x "+LL+" - y ? ?"
small = (PPmode>0) ? clean.bicubicresize(m4(oxi/2.125),m4(oyi/2.125))
\ : i .bicubicresize(m4(oxi/2.125),m4(oyi/2.125))
ex1 = small.expand.blur(.5)
in1 = small.inpand.blur(.5)
hull = logic( yv12lutxy( ex1.expand.blur(1), ex1, "x y - 1 1 / * 1.0 ^ 1 - 4 *" )
\ ,yv12lutxy( in1, in1.inpand.blur(1), "x y - 1 1 / * 1.0 ^ 1 - 4 *" )
\ ,"max", U=-128, V=-128)
\ .bicubicresize(oxi,oyi,1.0,.0)
postclean = (PPmode== 1) ? maskedmerge(clean,small.bicubicresize(oxi,oyi,1.0,.0),hull)
\ : (PPmode== 2) ? maskedmerge(clean,clean.DEdgeMask(0,255,0,255,"2 3 2 3 0 3 2 3 2"),hull)
\ : (PPmode==-1) ? maskedmerge(i,small.bicubicresize(oxi,oyi,1.0,.0),hull)
\ : (PPmode==-2) ? maskedmerge(i,i.DEdgeMask(0,255,0,255,"2 3 2 3 0 3 2 3 2"),hull)
\ : clean
postclean = (PPlimit==0) ? postclean
\ : yv12lutxy(clean,postclean,LIM,U=2,V=2)
(PPmode==0) ? clean : postclean
interlaced ? weave() : last
return( last )
}
#---------------------------------------------------------
function m4(float x) {return(x<16?16:int(round(x/4.0))*4)}
COREiP
9th March 2005, 20:23
I'm getting an error:
Script error: there is no function named "yv12lutxy"
(BlindDeHalo3.avs, line 32)
Didée
9th March 2005, 23:44
Could be your PC being ill. Try some medicine (http://manao4.free.fr/MaskTools-v1.5.6.zip).
ArabianSwan
10th March 2005, 01:03
Originally posted by COREiP
I'm getting an error:
Script error: there is no function named "yv12lutxy"
(BlindDeHalo3.avs, line 32)
you need the new masktool ..
COREiP
10th March 2005, 01:27
I'm using MaskTools 1.4.16 is there a newer version?
Backwoods
10th March 2005, 01:29
Originally posted by COREiP
I'm using MaskTools 1.4.16 is there a newer version?
2 posts above your's.
COREiP
10th March 2005, 01:48
lol thnx guys. Keep up the good work Didée the script is great :) :)
Mr. Brown
21st March 2006, 15:39
could anyone make a masktools 2 version of BDH3 thanks
Chainmax
21st March 2006, 18:58
You should try DeHalo_Alpha, which is made by Didée too. It's miles ahead of BDH3, and there's a masktools v2.x version.
Mr. Brown
21st March 2006, 19:25
You should try DeHalo_Alpha, which is made by Didée too. It's miles ahead of BDH3, and there's a masktools v2.x version.
i normally use dehalo_alpha (mt2 version)
but in some cases i need bdh3 for postprocessing
example:
DeGrainMedian(limitY=5,limitUV=5,mode=3)
den = last
dh = Dehalo_Alpha(rx=3.0,ry=3.0).BlindDehalo3(PPmode=-1,PPlimit=4)
edges = dh.removegrain(12,-1).prewitt(multiplier=2.5)
\ .mt_expand().mt_inflate().mt_inflate().removegrain(12,-1).mt_expand()
mt_merge(den,dh,edges)
that's why i a faster BDH3 would help me
Chainmax
21st March 2006, 19:58
In my opinion, BDH3 oversmooths the picture and kills small details, even when only using its PP mode. If DeHalo_Alpha doesn't solve it, the only semi-viable option I can think of is HQDering, of which a Masktools v2.x version was made a short while ago, but it might cause jaggyness.
Didée
22nd March 2006, 13:19
could anyone make a masktools 2 version of BDH3 thanks
Here: BlindDehalo3_MT2 (http://home.arcor.de/dhanselmann/_stuff/BlindDeHalo3_MT2.zip)
- changed for MaskTools v2 (mt_masktools.dll required)
- replaced some things with RemoveGrain-modes (RemoveGrain.dll newer than v0.9 required)
- fixed some oddities
- new PPmode (3 and -3): shouldn't blur, but still remove mosquitos and leftover halo borders
Could need some more testing, was done in a hurry. ;)
Mr. Brown
22nd March 2006, 20:32
@ Didée
thanks for updating bdh3()
i made a test with the dehaloing that you suggested me in german doom9 forum and the new ppmode's looks very good (bye bye halos and come never back even with seesaw :D)
wOxxOm
11th January 2008, 17:21
I need an advice on how to remove very grossly offset halos on Nicolodeon's Avatar movie DVD like these pictures 2,3,4 here: http://forum.doom9.org/showthread.php?p=1084550#post1084550 (quite large frame span!)
It seems that I have to tweak some parameter *inside* BHD, which would that be, please?
gigantibyte
5th February 2008, 07:05
Thank you very much for BlindDehalo3_MT2! I've heard many great things about the great Didée. I see why now. The function worked wonders on my video source.
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.