Log in

View Full Version : Too dark to enjoy ...


The SphereX
31st October 2012, 15:40
Hi folks !!!

For different reasons, I still don't quite understand until today, a lot of cinema movies got much too dark black levels :confused:. Often the lighter parts of the color spectrum are well balanced, but on the other hand the darker colors are too dark, suffering from detail loss :mad:. Normally I use ffdshows gamma correction in such cases, but unfortunately it always affects the whole color spectrum. I'm not able to only light up the darker colors, leaving the rest totally untouched. But that's exactly what I want to do! Just like you're able to process only a specific frequency band with an appropriate EQ.

I've tried out lots of Avisynth plugins (within ffdshow) to get the effect ... without success. The last one I found very promising was "SmoothAdjust". I'm sure you can do a lot of magic with it, way more than I need to do, but I didn't manage to use it properly for the problem outlined above. I still can't believe, that it's not possible to only modify a specific color range. It can't be that difficult, can it? I'm sure, you only have to know "what buttons to push". So hopefully someone can help me finding them ;).

Greetz,
The SphereX

Mini-Me
31st October 2012, 22:37
Hi folks !!!

For different reasons, I still don't quite understand until today, a lot of cinema movies got much too dark black levels :confused:. Often the lighter parts of the color spectrum are well balanced, but on the other hand the darker colors are too dark, suffering from detail loss :mad:. Normally I use ffdshows gamma correction in such cases, but unfortunately it always affects the whole color spectrum. I'm not able to only light up the darker colors, leaving the rest totally untouched. But that's exactly what I want to do! Just like you're able to process only a specific frequency band with an appropriate EQ.

I've tried out lots of Avisynth plugins (within ffdshow) to get the effect ... without success. The last one I found very promising was "SmoothAdjust". I'm sure you can do a lot of magic with it, way more than I need to do, but I didn't manage to use it properly for the problem outlined above. I still can't believe, that it's not possible to only modify a specific color range. It can't be that difficult, can it? I'm sure, you only have to know "what buttons to push". So hopefully someone can help me finding them ;).

Greetz,
The SphereX


There are probably parameters to SmoothAdjust that allow you to do something like this, but there's another way too: Try blending your original clip back into your gamma-adjusted clip using a mask. You can create the mask from the original or adjusted clip's brightness levels, such that brighter areas use the original clip and darker areas use the gamma-adjusted clip. For instance:

orig = Avisource("whatever.avi")
bright = orig.Levels(0, 1.2, 255, 0, 255, coring = False, dither = True) # Or SmoothLevels/SmoothAdjust

linearmask = orig
quadraticmask = orig.mt_lut("x x * 255 /")
quadraticmask2 = orig.mt_lut("x x *")
quadraticmask3 = mt_lutxy(orig, bright, "x y *")

linearblend = mt_merge(bright, orig, linearmask, u = 3, v = 3, luma = True)
quadraticblend = mt_merge(bright, orig, quadraticmask, u = 3, v = 3, luma = True)
quadraticblend2 = mt_merge(bright, orig, quadraticmask2, u = 3, v = 3, luma = True)
quadraticblend3 = mt_merge(bright, orig, quadraticmask3, u = 3, v = 3, luma = True)

# Returned in roughly increasing order of brightness I think (haven't tried...just imagining)
return Interleave(orig, quadraticblend3, quadraticblend2, linearblend, quadraticblend, bright).ConvertToYV16.Histogram(mode = "levels")


If none of those give you exactly the curve you want, you can experiment with mt_lut and mt_lutxy to create masks from arbitrary one or two-variable mathematical functions (in Polish notation) of your input. If you're not familiar with them, you can find the documentation here:
http://manao4.free.fr/mt_masktools.html

Didée
1st November 2012, 00:03
When it comes to gradation, mask-merging is the poorest of all possibilities, as it maximises the probability of banding.

In any case, you can't adjust "only a small part" of the histogram and leave everything else untouched. If you make the dark parts brighter, then the adjusted pixels occupy a tonal range that is already used by other pixels from the start. Hence, in order to keep different shades being different (instead of becoming the same), it is necessary to spread the adjustment over a wider part of the histogram.

However, the general strategy to gain mostly the very dark parts, and keep the brighter parts as unaffected as possible, is of course valid. Just a matter of taste.

Example for keeping the [16;235] range:
SmoothCurve(Ycurve="0-0;16-16;17-17;20-24;26-32;64-66;200-202;235-235;255-255")

Example for going to [0;255] range: (set ffdshow to convert to RGB, using 0-255 "fullrange")
SmoothCurve(Ycurve="0-0;16-0;17-2;20-8;26-16;64-56;200-210;235-255;255-255")

Something like that. Or maybe different. The numbers are straight from the guts, I'm too tired to try. *zzzzzz*

But there are also sources where the dark parts are too dark because someone used a coring filter too aggressively. In that case you can make the darks brighter, but you won't get any detail --
"If the black swamp is flat, then it is flat."

Mini-Me
1st November 2012, 00:45
Hrm...Didee has a point. Go with his solution: By using SmoothCurve, you can create an arbitrary curve and dither/smooth in the same step before quantizing back to 8 bits. With my previous solution, the merge step directly merges between two 8-bit clips with an 8-bit lookup table, which introduces banding (I actually forgot the dither parameter for Levels too, but just fixed that). It would work right if you had undithered 16-bit clips and used a lookup table with interpolation, then dithered back to 8 bits as a final step...but lookup tables don't take 16-bit inputs or interpolate, so meh. :p

The SphereX
1st November 2012, 13:22
That's it guys! SmoothCurve actually did the magic for what I was looking for :D. I've already fiddled around with this part of SmoothAdjust, too, but didn't get the right values to do the trick. So thank you again for pointing me the right direction :).

The only thing that's now still left for me to manage, is to find a way of controlling the SmoothCurve values in realtime with my HTPC remote control. Otherwise the whole thing would be quite useless. It's no problem at all to control any of ffdshows own parameters while a movie is playing. But the Avisynth section is of course a bit different to handle. Well, I'll see ...

Greetz,
The SphereX