Log in

View Full Version : Gradual Gamma


Ditto666
4th November 2010, 01:36
I'm encoding a relatively dark video but it has bright scenes as well. Simply increasing the gamma improves on the blacks but basically, it progressively looks worse and worse the lighter whatever colors are. Is there any filter that can gradually and smoothly decrease the application of whatever gamma increase I'd set, starting from the darkest (16)? Thanks.

Ditto666
5th November 2010, 07:27
I wouldn't know exactly how, but can't it simply be done with a "for loop" where it adds in a certain increment the range in which it's checking and subtracts by x value from the original increase in gamma? I'm pretty certain it should already exist, aside from likely people needing something similar before. Thanks again :D

LaTo
7th November 2010, 08:58
Yes, or you can apply the conversion only on the darker pixels: see SmoothLevels(Lmode=X) or SmoothCurve() (http://forum.doom9.org/showthread.php?t=154971).

Ditto666
7th November 2010, 09:34
Yes, or you can apply the conversion only on the darker pixels: see SmoothLevels(Lmode=X) or SmoothCurve() (http://forum.doom9.org/showthread.php?t=154971).

One problem, I wouldn't know how to write this for loop. I was thinking on doing the conversion on only the darker pixels initially but then on frames that have a gradual transition from dark to lighter, they would have a sharp change all of the sudden at the point where I marked the brightness not to have any more effect, wouldn't they?

LaTo
7th November 2010, 09:37
You can do a soft transition instead of a hard one, so no sharp change in this case.

A sample would be useful if you want help.

Ditto666
7th November 2010, 10:55
You can do a soft transition instead of a hard one, so no sharp change in this case.

A sample would be useful if you want help.

Sorry, you mean a sample of the video with further explanation as to what I want like as an example or you mean a sample of my code in relation?

LaTo
7th November 2010, 14:25
Sorry, you mean a sample of the video with further explanation as to what I want like as an example or you mean a sample of my code in relation?

A sample of the video. (50mb is enough)

Didée
7th November 2010, 15:43
YlevelsG / YlevelsS / YlevelsC. Just that the scripts (mine) posted in this forum operate wrong. The corresponding filters in the "levels" section of ffdshow are correct.

But yes, you can do the very same with LaTo's SmoothCurve.

Ditto666
7th November 2010, 22:43
A sample of the video. (50mb is enough)
http://www.mediafire.com/?a5iof6cy5hqhscr
Look how dark this is 0.0

It's even in the wrong aspect ratio, or rather, the image is slightly stretched out.
YlevelsG / YlevelsS / YlevelsC. Just that the scripts (mine) posted in this forum operate wrong. The corresponding filters in the "levels" section of ffdshow are correct.

But yes, you can do the very same with LaTo's SmoothCurve.
I feel a bit intimidated to ask just cause of the huge gap in knowledge that I know exists between you and I, lol, but umm, you think you'd be able to show me the script for doing this if I wanted to do say ColorYUV(gamma_y=30) at the darkest levels, gradually weakening as getting to the top? A straight line through would be fine but what would be amazing if there's a way of doing it as follows...

http://i7.photobucket.com/albums/y274/Typhoon859/GammaCurve.png

Didée
7th November 2010, 23:41
(You would be amazed how much I do not know.) :D

gamma=30 of ColorYUV is rather weak, that corresponds to a levels() gamma factor of 1.11.

I'd just use SmoothCurve. Suggestion for getting started:

o = last
dark_up = o.SmoothCurve(Ycurve="0-0;16-16;24-28;40-44;235-235;255-255")
interleave(o,dark_up)
Idea is to use a kind-of linear boost for the darks, and spread the rest almost linear up to original whitepoint.

Ditto666
8th November 2010, 02:08
(You would be amazed how much I do not know.) :D

gamma=30 of ColorYUV is rather weak, that corresponds to a levels() gamma factor of 1.11.

I'd just use SmoothCurve. Suggestion for getting started:

o = last
dark_up = o.SmoothCurve(Ycurve="0-0;16-16;24-28;40-44;235-235;255-255")
interleave(o,dark_up)
Idea is to use a kind-of linear boost for the darks, and spread the rest almost linear up to original whitepoint.

Hmm.. Well that did cross my mind to do it like this but that's the manual method. I didn't like the choppiness of it. It's less a curve than it is connecting a few dots.

I would want to set (and actually did) the gamma higher, but the problem with it is that it destroys anything fully black. That's easy to tell even because I have an LED local-dimming HDTV and when I set it above 30, it significantly lowers the brightness at which the TV would fully dim on a completely black background. If it can be done like that curve, then I can set it higher. 30 is just what I'm using now.

LaTo
8th November 2010, 08:35
Hmm.. Well that did cross my mind to do it like this but that's the manual method. I didn't like the choppiness of it. It's less a curve than it is connecting a few dots.

I would want to set (and actually did) the gamma higher, but the problem with it is that it destroys anything fully black. That's easy to tell even because I have an LED local-dimming HDTV and when I set it above 30, it significantly lowers the brightness at which the TV would fully dim on a completely black background. If it can be done like that curve, then I can set it higher. 30 is just what I'm using now.

If you want more easy:
SmoothLevels(gamma=1.4,Ecenter=64,DarkSTR=80,BrightSTR=800,Lmode=1,protect=16) # Lmode=1 is to activate the limiting // protect=16 is to protect fully black parts
It should do the job, but the best for specific adjustments is a manual curve.

Ditto666
8th November 2010, 09:17
If you want more easy:
SmoothLevels(gamma=1.4,Ecenter=64,DarkSTR=80,BrightSTR=800,Lmode=1,protect=16) # Lmode=1 is to activate the limiting // protect=16 is to protect fully black parts
It should do the job, but the best for specific adjustments is a manual curve.

Awesome, thanks! I'll definitely check all these recommendations out!