View Full Version : Dehaze filter ?
Donokami
2nd June 2018, 17:56
Hello,
I'm currently working on a private project with an anime which has kind of weird light halo, a haze.
I would like to remove it, has I did with Adobe Lightroom using the dehaze function like this:
https://i.imgur.com/IUWjS1K.jpg
Yes, it still doesn't look very well as the colors were not changed and would need less saturation. But to start I really need to remove this haze, but I didn't found any solution with Avisynth. Any idea?
Thanks.
fAy01
2nd June 2018, 19:19
For halos you can use: http://avisynth.nl/index.php/FineDehalo
I'm not so sure about your dehaze. It does more damage than good as the colors seem over-contrasted or w/e is going on with colors.
StainlessS
2nd June 2018, 20:44
You could try AutoLevels() or AutoAdjust() :- http://avisynth.nl/index.php/Autolevels#Levels_and_Chroma
or if you like, maybe try script func AutoContrast:- http://forum.doom9.org/showthread.php?p=1757661#post1757661
EDIT: Just remove the
GScript("""
...
""")
stuff if using Avs+
EDIT: I've modded linked AutoContrast() script to cope with/without avs+ (GScript needed if not avs+).
FranceBB
3rd June 2018, 05:02
Never heard of "dehaze". Looking at the pictures, it simply looks like someone screwed up levels.
If you really want to correct that, you can use Levels or ColorYUV. If you wanna de-saturate, just use "tweak".
One important thing: don't set Levels using your eyes, use a videoscope instead.
Histogram is gonna be fine: TurnRight.Histogram.TurnLeft
There are two brown bars at the very bottom and at the very top.
The graph shows levels between 0 and 255 (Full Range - brown) and the black in the middle is 16-235 (Tv Range).
To properly adjust the black level check a scene that contains something you are 100% sure it's black.
Once you found the right scene, check if the graph touches the very beginning of the bottom boundary.
If it does, then black level is fine. If it does not, adjust Levels/ColorYUV/Tweak values 'till it does.
The same applies to whites.
Once you set it on a scene, check if it's constant for the whole video. If it is, then you are done and you can encode.
Also make sure that the graph doesn't exceed the brown boundaries.
If you are using Avisynth+, you can also use TekScopes that is included in AvisynthPlusUtilities, which is called "VideoTek" in normal Avisynth.
Example Histogram: 1 (https://i.imgur.com/sDeBlJX.jpg) - 2 (https://i.imgur.com/dIr9iXX.jpg)
Example VideoTek: 1 (https://i.imgur.com/1nibpGS.png) - 2 (https://i.imgur.com/kTyW5ds.png)
StainlessS
3rd June 2018, 10:52
simply looks like someone screwed up levels.
Agreed.
Autocontrast() does a single scan of clip noting Luma Min and Max of Samples frames (Default 40) (RGB converted to LumaY using Matrix)
and then sets to user chosen range (PCLevels, default False), calling Levels().
Also Levels() makes adjustment to chroma sat to avoid color shift when Chroma=true (default, restores original chroma if Chroma=false [with color shift]).
AutoContrast() also has other knobs to twiddle.
Basically does as FranceBB suggests above.
AutoLevels() and AutoAdjust() scan every frame of clip and make adjustments during filter processing, AutoContrast() with single Samples frames scan and Levels (using a single Lut for entire clip) is faster.
AutoContrast should really be used on clip where similar-ish exposure across entire clip, else maybe try AutoLevels or AutoAdjust.
EDIT:
eg where 720x576 clip, 40 Sample frames, and assuming 256 expected levels of luma then 720*576*40/256 = ~64800
expected samples per luma level, if that aint enough for you then increase Samples arg (0= all Frames Sampled, longish timeout before process).
40 Samples takes a fraction of a second (in most cases) before FrameServing starts.
# Set Samples as Percentage of FrameCount
Perc = 2.0 # 2.0 Percent
MinSamples = 40 # Minimum Number of Samples
Samples = Max(Round(Perc * FrameCount / 100.0),MinSamples)
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.