View Full Version : Levels luminosity problem(anime)
DarkT
4th February 2008, 15:05
Mostly, the levels line Levels(16, 1, 235, 0, 255, coring=false) does reall good for the colors and all, but there is a problem with already light/dark scenes - the already light scenes get super-exposured, and the already dark scenes get super-darkened.
Here's a small extract from a typical script:
ReplaceFramesSimple(Tweak(sat=1.00, cont=0.97, bright=3), mappings="[4391 4464] [4532 4568] [6882 6977] [7236 7399] [10588 10744] [12301 12338] [12450 13004] [29055 29294] [34062 34098] [34126 34206] [34596 34641] [36198 36430]")
Levels(16, 1, 235, 0, 255, coring=false)
Would it be possible to somehow automatically detect post-levels too-dark/too-light scenes and then apply a "tweak" on those automatically? I tried HDRAGC, and for movies it works really REALLY nice - BUT - for anime it tends to create "ringing"(banding?)...
I have seen scripts by didee called Ylevels and such, do those address this issue?
Thanks,
DiTi.
Edit:
I created the same thread here:
http://forum.doom9.org/showthread.php?t=131021
So if it's not allowed, I suppose it should be deleted, I just figured maybe time passed and people would by now have a better way of handling this issue...
As per MSU's filters... I'd rather avoid a color conversion to rgb32...
Jawed
4th February 2008, 16:41
It looks like you want to convert your clip to PC Levels, first reducing contrast slightly.
You should be able to achieve the same with:
Tweak(bright=-13, cont=1.129, coring=false, sat=1.13)
The banding (posterisation) you're getting is a fact of life. You'll make it worse if you use two lines in your script to modify the tonal range of your picture, so one line is best. I've settled on Tweak for my own use because it can be used to change just luminosity, whereas Levels changes saturation at the same time. I added sat=1.13 to produce a visually similar increase in saturation to that produced by your two lines.
You can reduce the visual impact of banding by adding some dither afterwards:
gradfunkmirror()
If the clip isn't clean any noise might be helping to hide some of the banding that's in there already. But the change to PC Levels nullifies the hiding effect of the noise, so you get a double whammy.
Anime is about the worst-case scenario for banding I expect - I'm an Anime noob, though, so have tiny experience with it.
Jawed
Jawed
4th February 2008, 19:17
Tweak(bright=-13, cont=1.129, coring=false, sat=1.13)
Those numbers don't seem to work out as close as I was thinking they would - the contrast has a different shape to it. Worse, on a brief test on a bit of anime I have lying around, I think your two lines produce less banding. So much for that.
So try just adding gradfunkmirror().
My normal approach is to perform some denoising in the middle:
Tweak()
Denoise()
gradfunkmirror()
The denoising "smoothes out" the banding. Denoising is quite a big step to take if you don't already do so. I use MVDegrain3.
http://www.cupidity.f9.co.uk/DarkT.zip
Jawed
IanB
6th February 2008, 01:50
Note:- Tweak(bright=, cont=) and Levels are very closely related. It is only the UI (arithmetic expression) that is different.
Tweak (simplified) expresses like this :-map[i] = i*cont + bright;
Levels (simplified) expresses like this :-map[i] = out_min + (i - in_min) * (out_max - out_min) / (in_max - in_min);
Although the Levels expression looks complicated it is still a simple Y=mX+c expression. With a little mathemagic you can easily convert one to the other.
Jawed
6th February 2008, 02:33
Note:- Tweak(bright=, cont=) and Levels are very closely related. It is only the UI (arithmetic expression) that is different.
Levels adjusts saturation while Tweak doesn't. It's similar to how in Photoshop using Levels is like adjusting a picture in RGB mode while Tweak is like adjusting the picture in Lab mode.
http://avisynth.org/mediawiki/Levels
Also, as far as I can tell, Tweak is (i+Bright)*Cont.
Jawed
Guest
6th February 2008, 02:56
Also, as far as I can tell, Tweak is (i+Bright)*Cont. My original Tweak filter, from which the Avisynth code is derived, is i*cont + bright.
Jawed
6th February 2008, 03:52
My original Tweak filter, from which the Avisynth code is derived, is i*cont + bright.
I think that's how ColorYUV works... :eek:
Jawed
IanB
6th February 2008, 13:20
const int maxY = coring ? 235 : 255;
const int minY = coring ? 16 : 0;
for (int i = 0; i < 256; i++)
{
/* brightness and contrast */
int y = int((i - 16)*_cont + _bright + 16.5);
map[i] = min(max(y,minY),maxY);
}
Jawed
6th February 2008, 13:31
Thanks, that explains why my line:
Tweak(bright=-16, cont=1.164, coring=false)
works to convert 16-235 to 0-255, "being a special case".
Jawed
IanB
6th February 2008, 21:27
Levels(16, 1, 235, 0, 255, False)
map[i] = out_min + (i - in_min) * (out_max - out_min) / (in_max - in_min);
map[i] = 0 + (i - 16) * (255 - 0) / (235 - 16)
map[i] = (16-16) + (i - 16) * 1.1643
FlimsyFeet
7th February 2008, 13:32
As far as I can tell, are you trying to increase "dynamic range" without clipping the bright or dark areas?
My YLevels mod ("FlimsYLevels") may help. (see http://forum.doom9.org/showthread.php?t=79898). Just make sure you set correct contrast and brightness beforehand.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.