Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. Domains: forum.doom9.org / forum.doom9.net / forum.doom9.se |
|
|
#1 | Link | |
|
Registered User
Join Date: Nov 2009
Posts: 2,375
|
Personal ColorCorrection filter
Since I saw Didee's mt_lut codes for color correction I have been using it very nicely. But I wanted to give it an easier look by out calling variables so it looks neat in my scripts and my friend can easily understands it too.
I came up with this but the screen renders green, so I would like to know if Im doing something wrong? Quote:
EDIT2: wrong concept ignore it.
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread Last edited by Dogway; 4th March 2010 at 11:45. |
|
|
|
|
|
|
#3 | Link |
|
Registered User
Join Date: Nov 2009
Posts: 2,375
|
Now that you say that, I remember questioning the same thing. I will try to remove that or implement this into Ylevels, so I can make a one filter stop for color correction. Thank you
Edit: Maybe now is OK? I just adapted contrast into the Ylevels code.
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread Last edited by Dogway; 2nd March 2010 at 14:37. |
|
|
|
|
|
#5 | Link |
|
Registered User
Join Date: Nov 2009
Posts: 2,375
|
I was making it for myself but yes, more speed, better quality preservation, and all-in-one.
It's a mix between this: http://forum.doom9.org/showthread.ph...70#post1375870 and this: http://forum.doom9.org/showthread.ph...465#post525465
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread |
|
|
|
|
|
#6 | Link |
|
Registered User
Join Date: Apr 2002
Location: Germany
Posts: 5,407
|
How comes the "Better quality preservation"? Is mt_lut by some magic calculating more precisely than levels() or ColorYUV() are calculating?
The script could be a little optimised. If the parameters are chosen so that no change is to be done to a plane, then it's faster to just copy that plane. Your current script always processes all planes, even if nothing is to be done. Code:
cont = default(conty, 1.0) satu = default(contuv, 1.0) mtUV = (satu==1.0) ? 2 : 3 mtY = (a==0&&b==255&&c==0&&d==255&&gamma==1.0&&cont==1.0) ? 2 : 3 luma="x 128 - "+string(cont)+" * 128 + "+string(a)+" - "+string(b)+" "+string(a)+" - / 1 "+string(gamma)+" / ^ "+string(d)+" "+string(c)+" - * "+string(c)+" +" chroma="x 128 - "+string(satu)+" * 128 +" return(clp.mt_lut(yexpr = luma, uexpr= chroma, vexpr=chroma, Y=mtY,U=mtUV,V=mtUV)) the output to [50,200] ("strict boundary" principle), or if you expect it to just do nothing ("control point" principle).
__________________
- We´re at the beginning of the end of mankind´s childhood - My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!) |
|
|
|
|
|
#7 | Link |
|
Registered User
Join Date: Nov 2009
Posts: 2,375
|
Yep, I looked for info on Y U and V on mt_lut, but didnt find, well I found but I didnt quite understand it. I also wanted to do some conditional for speed, but I was unsure about if it would gain speed or not having to prior check if a parameter had changed.
Anyway, it surely preserves quality when you compute something as a whole. If you process tweak, coloryuv, and then yleves, (as I was doing before) it leads to degradation, most noticeable on gradients. But thanks for the input I have learnt a lot from your codes. Right now it doesnt clamp, so I think it's a good signal.
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread |
|
|
|
|
|
#8 | Link |
|
Registered User
Join Date: Apr 2002
Location: Germany
Posts: 5,407
|
I'm not convinced. Shortly, if you know what kind of manipulation you want to achieve, then you'll do it with a "minimalistic" appliance of Levels/Tweak/ColorYUV, i.e. with a combination that processes any given plane only *one* time. If done so, then the result is precise, and you can *not* get any more precision with mt_lut.
Also, your actual formula still is malformed, due to the implementation of "conty". Gamma function is expected to work on the full gamut range, and only on positive values. With the way you implemented conty, you may blow the input out of the range that gamma is supposed to work on (or can work on). The basic range is 0-255. Gamma curve range is 0-255. When your formula is called with e.g. conty=2.0, then you first blow the range [0,255] to [-128,384], then you proceed with gamma working on [0,255] range. That's definetly not correct, and the (possible) negative values even will cause some sort of internal exception in MaskTools (depending on the host application it may go by unnoticed, or the application even may catch it and bug you.) You see, cigars aren't that easy to get. ![]() (But mind you, Ylevels isn't fully correct either...)
__________________
- We´re at the beginning of the end of mankind´s childhood - My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!) |
|
|
|
|
|
#9 | Link |
|
Registered User
Join Date: Nov 2009
Posts: 2,375
|
Of course of course, the intention is just to make things easier, Im not saying those filters dont work, or work bad. I was just trying to arrange the principal features of those into one filter so you never touch a plane more than once. Something, easy, compact, and still fast. Nothing magical there. Im aware of Ylevels not being correct also, reading thru the thread. I only use Ylevels because it doesnt mess with UV.
I know what you mean, Im not a programmer, but I like using things to make better things, and open to learn, thats why I post, otherwise I would just stick to my placebo filter. Anyways I know what I was getting into, but it makes me wonder if its just not possible to integrate contrast into levels as one-shot. Neither Photoshop has it. Debate time ![]() Also I then mistook on the 0,255 thing, I thought they were working as clamp indicators, not a working range thus putting everything in its place after the gamma,contrast operation. I mean in Photoshop you can do levels on float point images.
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread Last edited by Dogway; 3rd March 2010 at 16:13. |
|
|
|
|
|
#10 | Link |
|
Registered User
Join Date: Apr 2002
Location: Germany
Posts: 5,407
|
Well ... speaking frankly, the separate contrast thingy doesn't make too much sense inside of a levels command, anyway. Contrast adjustment is a subset of what levels can do. Whatever you're going to do, you can do it with the plain levels parameters alone, without even bringing contrast into the game.
E.g.: given that no rounding issues come in the way (which I didn't check), then YUVlevels(64,1.0,192,0,256,conty=0.5) is exactly a no-op. Does that make sense? Is it obvious that it's a NOP? Or, vice versa, YUVlevels(0,1.0,255,0,255,conty=2.0) is identical to YUVlevels(64,1.0,192,0,256) --or-- YUVlevels(0,1.0,255,-128,382) Whichever way you turn it, the contrast parameter simply is not needed. As a standalone command, contrast is an "easy" adjustment. But when packed together with levels into an all-in-one-thingy, then it can easily create more confusion than clarity. (IMHO, at least.) Get me right - if a complicated matter can be made easier, then I'm all for it. But, when things are simplificated so much that it's not quite clear anymore what is going on, then it was too much simplification.
__________________
- We´re at the beginning of the end of mankind´s childhood - My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!) Last edited by Didée; 3rd March 2010 at 19:08. |
|
|
|
|
|
#11 | Link |
|
Registered User
Join Date: Nov 2009
Posts: 2,375
|
Then we have different concepts of what contrast is, and that code (for conty) is wrong, me thinks. For me contrast expands from the center, like a gamma for both sides of the spectrum from 128, and never clipping values (theorically). And levels just remaps the dynamic range clipping from sides.
It would be hard to explain what Im trying to say if I dont show some examples. raw ![]() contrast ![]() levels ![]() Like in this example; its full range, it has 0 and 255 values, how would you enhace contrast here without clipping those near 0 and near 255 values with levels?
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread Last edited by Dogway; 3rd March 2010 at 20:35. |
|
|
|
|
|
#12 | Link |
|
Registered User
Join Date: Apr 2002
Location: Germany
Posts: 5,407
|
> Then we have different concepts of what contrast is,
The concept for contrast is easy: it's the difference between dark and bright. How to modify the contrast, that's the tricky question. ![]() > and that code (for conty) is wrong, me thinks. "Wrong" or "right" don't really apply, because of the different possible ways of modifying it. However, if you were aiming for contrast expansion without clipping, then yes, then your code is wrong. You need a much looooonger lut expression for that. ![]() Contrast expansion without clipping is not too hard, you would do a (more or less) gamma-style adjustment for the "positive" and "negative" half, relative to a given center point. (BTW, you can find a similar lut expression in SeeSaw, where something like that is done to a 128-centered difference mask.) ![]() - And "center point" is exactly the next problematic thing. At first glance, it seems somewhat obvious to use 128 as center point. (Or 126, when operating in [16,235] TV levels). But wait, there's a problem .... imagine the common example of a very dark scene in a movie. Say, the scene is using only a small luma range , like 16-32. Now when you try to do contrast "enhancement" in relation to center=128, then ... you have a problem. Either you lose the scene due to clipping, or you don't enhance the contrast at all. Depending on the formula used to avoid clipping, you even might reduce the effective contrast. ![]() It's a tricky thing, really. One step in the wished direction is to use a variable center point, e.g. make the center=[average luma of frame]. Thats's better, but still rises problems, e.g. when several small bands in the overall histogram are populated. (Basically like the example frame you posted, though that one still is far from a worst-case scenario). The next step is to work with local averages and local centerpoints. An approach that makes sense, but then the problem is how to define what "local" exactly is, resp. where one locality ends and the next locality starts, and what to do with the transition areas, andsoforthandsoon.... See, we started with contrast, and now we're almost at HDR (high dynamic range). Which leads to the already existing HDRAGC plugin. (Which in itself does some nice things, but isn't fully error-free either. And is closed source, if I'm not mistaken.) Yeah, contrast basically is an easy concept. But modifying it is not quite as easy.
__________________
- We´re at the beginning of the end of mankind´s childhood - My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!) |
|
|
|
|
|
#13 | Link |
|
Registered User
Join Date: Nov 2009
Posts: 2,375
|
So actually theres a "point" on implementing contrast in a levels filter, thats the reason in photoshop the filter is called "brightness and contrast" so you can "set" your center point. Although in this case I felt preferable to set that center point with the remaping abilities of gamma in levels.
Obviously there will be banding, what doesnt create it! If you start with a scene of 16-32 range theres not much you can do, clip black to 16, white to 32, and gamma to 24? if thats what you pretend your image to be. I agree levels has a strong contrast component. And if I think the image originally had pure blacks and whites the first thing I will do is to remap levels. But beyond that, like in the example above, I would only use contrast. For me contrast starts where levels ends, meaning that its not an usual parameter you would use, but in certain scenarios can be very useful. Actually after the histogram play, out of curiosity tried to copy it with curves, and it does it with an S kind of curve. So yes, only with curves you can do levels and contrast at the same time, but its actually guessing work with the graph, and Im not very fond on drawing curves with the mouse. In this graph I show you the concept, the green line shows a normal only contrast case. In the red I wanted to show how everything can be mixed up, gamma is offseted from diagonal center (gamma), and along the diagonal line too (center point), contB (should) mantain a porcentual offset (the contrast value) with gamma, same with contW, and I did a bit of clipB. The aparent condition is just that contB and contW need to mantain in the center of clip and gamma. ![]() Now even so this is easily prone to clipping, if you play with the curves you will see. But Im sure you will get the same clipping if you extrapolate the same data onto two filter layers, call it Photoshop or avisynth, but with the benefit of causing less banding artifacts. Dont you think? Anyways, this is me wondering the why's of things. I will leave that naive idea of YUVlevels, and stick to the old usual way. Just a cuestion, does ColorYUV, HDRAGC or any other filter do the contrast as I understand it? or do they rely on the levels formula? EDIT: ok now it is tested; internal "colorYUV" is just the same as levels, ylevels or the like, and the contrast in Tweak is just no-sense (it works like a clipW). I fear there's no real contrast filter in avisynth... what a shock!
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread Last edited by Dogway; 5th March 2010 at 13:01. |
|
|
|
|
|
#14 | Link |
|
Registered User
Join Date: Apr 2006
Posts: 299
|
How about these?:
http://avisynth.org/mediawiki/SGradation http://forum.doom9.org/showthread.ph...890#post605890 Then there's Smoothlevels which is very flexible thanks to the Lmode and DarkSTR/BrightSTR settings and does a good job avoiding banding and other artefacts. |
|
|
|
|
|
#15 | Link |
|
Registered User
Join Date: Nov 2009
Posts: 2,375
|
Nailed it. Thank you
SGradation is what I was looking for, although its lacking some of the listed functions. But it does contrast anyway, so no complain : D
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread Last edited by Dogway; 6th March 2010 at 05:47. |
|
|
|
|
|
#16 | Link |
|
Registered User
Join Date: May 2009
Location: Hungary
Posts: 79
|
I think you should take a look on this filter:
http://expsat.sourceforge.net/ If I understand correctly, this is what you're looking for.
|
|
|
|
|
|
#17 | Link |
|
Registered User
Join Date: Nov 2009
Posts: 2,375
|
That is a very powerful filter! Its very neat the preview and all, but can you confirm whether it can clip black values? I think something is wrong in pre_l, post_l
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread |
|
|
|
|
|
#20 | Link |
|
Registered User
Join Date: Nov 2009
Posts: 2,375
|
Use Gicocu, it seems Ylevels model, which this little turn around script is based on, is not correct at all.
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread |
|
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|