VideoHelp Forum
+ Reply to Thread
Page 1 of 2
1 2 LastLast
Results 1 to 30 of 38
Thread
  1. Tweak has failed miserably, the colors were so dull. I'd try Levels but I'm unclear how to exactly work it. In Vdub my settings are -32 brightness and +96 contrast. How do I import that into Levels?
    Quote Quote  
  2. It's tough to equate VirtualDub's brightness/contrast filter and AviSynth's levels() filter. The color differences are probably because VirtualDub was working in RGB, whereas AviSynth was working in YUV. Colors get much more saturated when you stretch levels a lot in RGB. If you use stretch the brightness and contrast in AviSynth you'll have to pump up the saturation too. If you used Tweak(bright=-32, cont=1.96) try adding sat=1.96.
    Last edited by jagabo; 22nd Apr 2012 at 12:11.
    Quote Quote  
  3. Okay so how much saturation must I pump up? Is there a simple formula? Should I use Tweak or Levels?
    Quote Quote  
  4. Originally Posted by Mephesto View Post
    Okay so how much saturation must I pump up? Is there a simple formula? Should I use Tweak or Levels?
    Since Tweak is the only one of the two you mentioned that can adjust the saturation, then the answer (to me anyway) is fairly obvious.

    I don't really know that there's any sort of a formula to get the saturation back after adjusting the brightness and contrast, especially as radically as you're doing. I just raise it until it looks good to me again.
    Last edited by manono; 22nd Apr 2012 at 14:17.
    Quote Quote  
  5. Sorry I didn't see the edit in your last post. So I add the same number of sat as for cont? Got it.

    My original question is still how to replicate the Vdub results. The closest I got was with cont 1.35 which looks okay if you ignore the many darker colors that look gamma'd up. How exactly does the contrast feature work in Tweak? I can't find a correlation between the functions.
    Quote Quote  
  6. Yeah, sorry, I edited to add the second paragraph after completing and posting the first.

    You'll have to wait for Gavino or jagabo or pdr to try and answer your question as I never do those things in VDub to begin with.
    The closest I got was with cont 1.35 which looks okay if you ignore the many darker colors that look gamma'd up.
    I don't trust my eyes to tell me it's OK. You should be using histograms or AviSynth scripts to tell you if the levels/brightness/contrast are OK.
    Quote Quote  
  7. I don't trust my eyes to tell me it's OK.
    My purpose is to perfectly or near-perfectly replicate the Vdub results and my eyes only need tell one thing: whether or not the Avisynth result visually matches, which it doesn't. The whites are matched but the blacks are too bright.

    You should be using histograms or AviSynth scripts to tell you if the levels/brightness/contrast are OK.
    I do with the Vdub brightness/contrast filter with features a GUI with a preview and a histogram. :P
    Quote Quote  
  8. You have a GUI with preview, histogram, waveform in AVSPMod.

    As jagabo stated, RGB contrast adjustment are different than YUV contrast. Also there are different implementations of "contrast" - some function from a center point, some from the top of waveform, some from the bottom. It's the "contrast center" point . Basically what I'm saying is there is not necessarily some linear equation that you can use to convert them

    You can "eyeball" it, but you cannot do this properly without seeing monitoring histograms, waveforms
    Quote Quote  
  9. The brightness and contrast settings in VirtualDub are percent based. So -32 brightness in VirtualDub is equivalent to about Tweak(bright=-82), ie, multiply by -32 by 2.56. I don't know how you're getting +96% contrast in VirtualDub. The Brightness/Contrast filter's Contrast setting moves in large increments and the closest I can get is 193 percent or 200 percent. 193 would be Tweak(cont=1.93). If you pump up the saturation by the same amount Tweak(sat=1.93) you'll get close to the colors in VirtualDub. But they won't be exact because the two are working in different color spaces (RGB in VirtualDub, YUV in AviSynth).
    Quote Quote  
  10. jagabo, I am using brightness/contrast/gamma for Vdub, which is the second filter after the one which only features brightness and contrast. It is not percent based, the lowest value is -200 and highest +200. -32 brightness reduces pixel values by exactly 32, not by 32%. Doing -32 in Tweak is noticeable darker than Vdub, -82 makes a mess.
    Quote Quote  
  11. I don't have that filter. But you may have a case where the order of the operations is important. Ie, whether the brightness is subtracted before multiplying for the contrast, or after. Ie

    Code:
    P' = (P + B) * C
    
    vs.
    
    P' = P * C + B
    Where P is the pixel's current value, B is the brightness, and C is the contrast.

    Or you just have to figure out exactly what the contrast setting in the filter does. In Tweak() the contrast setting multiplies the pixel's luma value by the number specified. In the filter you're using, it's obviously not multiplying by 96. It's probably something like multiplying by 96 then dividing by 256. You can't force the order of the operations within Tweak() but you can call it twice, first to change the contrast, then the brightness, or vice versa.

    And again, the filters work in different color spaces (RGB vs YUV). In RGB the brightness ranges from 0 to 256, in YUV the luma ranges from 16 to 235. So you'll have to account for that too.

    Unless you download the source for the two filters and compare operations you won't be able to work this out mathematically. You'll just have to experiment. I would use levels chart so you can easily see how values are changed. A tool like CSamp will come in very handy. A HuffYUV levels chart attached.
    Image Attached Files
    Last edited by jagabo; 23rd Apr 2012 at 07:17.
    Quote Quote  
  12. Member
    Join Date
    Jul 2009
    Location
    Spain
    Search Comp PM
    Originally Posted by jagabo View Post
    you may have a case where the order of the operations is important. Ie, whether the brightness is subtracted before multiplying for the contrast, or after. Ie
    Code:
    P' = (P + B) * C
    
    vs.
    
    P' = P * C + B
    Where P is the pixel's current value, B is the brightness, and C is the contrast.
    As far as Tweak is concerned, it's effectively the latter.
    More precisely, taking into account the [16,235] range of YUV, the luma pixels are changed according to this formula:
    P' = 16 + (P-16)*C + B

    Chroma pixels (U and V) are affected by sat as follows:
    P' = 128 + (P-128)*sat
    (This assumes hue=0 (default), otherwise effect on chroma is more complicated.)
    Quote Quote  
  13. You also have to be careful if you call Tweak() twice. Any pixels which fall outside the Y=16-235 range (0-255 if coring=false) will be clamped in the first call. So the exact same operations performed by a single Tweak, or two sequential tweaks, may not return the exact same results.
    Quote Quote  
  14. Thanks for the intelligent responses, people. Unfortunately, I'll have to get back to this thread tomorrow or another time because I'm not in a good ******* mood right now and it just happened to be about 40C hell on this very day out of all days, and if I punch one more key on this keyboard I'll surely become the Uncle Scoob of the month and piss everyone off.

    brb... I really need some air.
    Quote Quote  
  15. Originally Posted by jagabo View Post
    I don't have that filter. But you may have a case where the order of the operations is important. Ie, whether the brightness is subtracted before multiplying for the contrast, or after.
    lol, damn. I downloaded this filter so long ago that I forgot it was external. I even managed to find it (holy shit I can't believe Firefox kept this link purple for the last 5 years) http://www.infognition.com/cgi/getfilter?id=44&a=mirror

    And no, I load this filter twice so I can set brightness and contrast seperately.

    Or you just have to figure out exactly what the contrast setting in the filter does. In Tweak() the contrast setting multiplies the pixel's luma value by the number specified. In the filter you're using, it's obviously not multiplying by 96. It's probably something like multiplying by 96 then dividing by 256. You can't force the order of the operations within Tweak() but you can call it twice, first to change the contrast, then the brightness, or vice versa.

    And again, the filters work in different color spaces (RGB vs YUV). In RGB the brightness ranges from 0 to 256, in YUV the luma ranges from 16 to 235. So you'll have to account for that too.

    Unless you download the source for the two filters and compare operations you won't be able to work this out mathematically. You'll just have to experiment. I would use levels chart so you can easily see how values are changed. A tool like CSamp will come in very handy. A HuffYUV levels chart attached.
    I experimented with that levels chart you gave. +96 contrast with the Vdub filter turned 185 gray to 255, 186 to 254. 1.37 contrast in Levels avisynth filter did the same. -32 in Vdub darkened exactly by 32 pixels, but for some reason the avisynth filter darkened by 37. Why?
    Quote Quote  
  16. Originally Posted by Mephesto View Post
    -32 in Vdub darkened exactly by 32 pixels, but for some reason the avisynth filter darkened by 37. Why?
    Because VirtualDub works in 0-255 RGB, AviSynth in 16-235 YUV. 32 units of Y ~= 37 units of RGB.

    37 ~= 32 * 256 / (235-15).
    Last edited by jagabo; 26th Apr 2012 at 17:55.
    Quote Quote  
  17. I see. Then that would mean 27.5 to really darken by 32. What about for the contrast?

    P.S. When I said I was using Levels() I meant Tweak(), I had a bit of a derp moment there.
    Quote Quote  
  18. Member
    Join Date
    Jul 2009
    Location
    Spain
    Search Comp PM
    Originally Posted by Mephesto View Post
    Then that would mean 27.5 to really darken by 32. What about for the contrast?
    Since Tweak(cont=C) multiplies the difference from the 'black point' by C (see post #12), it will also multiply RGB levels of a greyscale clip by that same factor.
    Quote Quote  
  19. No I meant if he found a correlation and thus a formula between the contrast functions of the Vdub and Tweak script. We got the brightness function out of the way, which is good.
    Quote Quote  
  20. Post 12 gives the equation used in Tweak(), Y' = 16 + (Y-16)*C (ignoring the B component). In the brightess/contrast/gamma filter it's obviously RGB' = RGB * (C+256)/256.
    Last edited by jagabo; 27th Apr 2012 at 13:41.
    Quote Quote  
  21. I am so glad I found this thread - learned quite a bit.

    Turns out I am also trying to translate the brightness/contrast from vdub to avs. However, in my case, I am just using the built in "brightness/contrast" filter for vdub and not any external filter.

    My brightness and contrast values in vdub are -55 and 17 or more precisely:
    Code:
    VirtualDub.video.filters.Add("brightness/contrast");
    VirtualDub.video.filters.instance[0].Config(-55,17);
    Based on all the discussion above, I have arrived at "-47" in YUV/avs to be equivalent of "-55" in RGB/vdub - correct? Need help figuring out equivalent contrast and saturation for YUV.

    I am also trying to translate built-in "levels" numbers from vdub to avs:

    Code:
    VirtualDub.video.filters.Add("levels");
    VirtualDub.video.filters.instance[1].Config(0x0000,0x8E26,0x00BB658F,0x0000,0xFFFF, 0);
    "google" suggests that I can use the same numbers from "vdub" levels [0,0.732,142,0,255] into avs "levels" true?
    Quote Quote  
  22. Originally Posted by sreemv View Post
    "google" suggests that I can use the same numbers from "vdub" levels [0,0.732,142,0,255] into avs "levels" true?
    Only for RGB. From the AviSynth docs:
    I decided I could at least make this filter compatible with VirtualDub's when the clip is RGB. In that case you should be able to take the numbers from VirtualDub's Levels dialog and pass them as parameters to the Levels filter and get the same results.
    Quote Quote  
  23. Originally Posted by jagabo View Post
    Only for RGB. From the AviSynth docs:
    I decided I could at least make this filter compatible with VirtualDub's when the clip is RGB. In that case you should be able to take the numbers from VirtualDub's Levels dialog and pass them as parameters to the Levels filter and get the same results.
    Ouch! Hmm....so, how could I translate the numbers to YUV ....help?
    Quote Quote  
  24. Whoa, I forgot about this thread. Thanks jagabo and everyone who got me thru this. I always sucked so bad at math that it took me a while to get this:
    Post 12 gives the equation used in Tweak(), Y' = 16 + (Y-16)*C (ignoring the B component). In the brightess/contrast/gamma filter it's obviously RGB' = RGB * (C+256)/256.
    How did you figure out the method the Vdub filter used? Is this how Contrast generally works? I always thought increasing contrast meant widening the pixel differences, making blacks blacker and whites whiter. Both this Vdub and Tweak contrast formula actually make dark blacks a bit brighter.

    sreemv, the Vdub filters work on RGB clips only so you would have to add ConverttoRGB() in avisynth to make it work, but converting the colorspace is lossy and is best avoided. You're also using a different Vdub filter from mine which is % based so -47 is actually equivalent to -120 in your filter, not -55. Try -21.

    I suggest you download the same filter I use, as it has a histogram and can adjust gamma as well. Percent-based tools are rough.
    Quote Quote  
  25. Originally Posted by Mephesto View Post
    sreemv, the Vdub filters work on RGB clips only so you would have to add ConverttoRGB() in avisynth to make it work, but converting the colorspace is lossy and is best avoided. You're also using a different Vdub filter from mine which is % based so -47 is actually equivalent to -120 in your filter, not -55. Try -21.

    I suggest you download the same filter I use, as it has a histogram and can adjust gamma as well. Percent-based tools are rough.
    I tried converttorgb() and tried tweaking with ALL the sliders in "Avsp" for levels & tweak - nothing I could do in avs to match the result exactly as I get in Vdub period!! Vdub just beats it outright!!

    Now, I want to try loadvirtualdubplugin() route - any help with the built in Vdub filters such as brightness/contrast and levels would be much appreciated. I can find the ".vdf" files for external Vdub plugins and load them in avs but cant find these built in plugins.

    All this because exporting uncompressed RGB from vdub is writing a 800GB file each time which I then compress to x264. I am also trying external encoder option from vdub which is not working at the moment.
    Quote Quote  
  26. You should do brightness and contrast adjustments separately. Tweak can mirror your Vdub results with 99% accuracy, you just gotta figure out how to translate the numbers. Since we've already figured out how to do it for the filter I use, you should use it too if you wanna get your problem over with. Your tweak script should look something like this:

    Code:
    tweak(bright=-20)
    tweak(cont=1.35, sat=1.35)
    Saturation must be the same number as the contrast.
    Last edited by Mephesto; 31st May 2012 at 00:32.
    Quote Quote  
  27. Originally Posted by Mephesto View Post
    You should do brightness and contrast adjustments separately. Tweak can mirror your Vdub results with 99% accuracy, you just gotta figure out how to translate the numbers. Since we've already figured out how to do it for the filter I use, you should use it too if you wanna get your problem over with. Your tweak script should look something like this:

    Code:
    tweak(bright=-20)
    tweak(cont=1.35, sat=1.35)
    Saturation must be the same number as the contrast.
    Appreciate input - No offense but its just got worse

    Suddenly, I am in so love with vdub and filters - just wish I could do everything there!
    Quote Quote  
  28. Originally Posted by Mephesto View Post
    Is this how Contrast generally works? I always thought increasing contrast meant widening the pixel differences, making blacks blacker and whites whiter. Both this Vdub and Tweak contrast formula actually make dark blacks a bit brighter.
    That's not how they work in "regular" programs. Usually it's what you said: blacks blacker, whites whiter. There is a "contrast center" which is usually at the middle, but you can adjust it in some programs



    sreemv, the Vdub filters work on RGB clips only so you would have to add ConverttoRGB() in avisynth to make it work, but converting the colorspace is lossy and is best avoided. You're also using a different Vdub filter from mine which is % based so -47 is actually equivalent to -120 in your filter, not -55. Try -21.
    Not entirely true - some vdub filters can work in YUV. Also you can use vdub's video=>color depth options to stay in YV12. If you have "show image formats checked" vdub will indicate which colorspace you are in, and which the filter is working in. Brightness/contrast can work in YUV

    You can use colortools and simultaneously make adjustments in vdub to monitor how the filter is affecting the histogram

    Similarly you can use avspmod if you are using an avs script with histogram() for Y' waveform, and there are RGB histogram functions as well

    Vdub's contrast doesn't seem to work like other color correcting tools, and neither does avisynth tweak() for contrast
    Quote Quote  
  29. Originally Posted by sreemv View Post

    Appreciate input - No offense but its just got worse

    Suddenly, I am in so love with vdub and filters - just wish I could do everything there!

    Provide some more information on the source format, what colorspace you are using (checkmark the show image formats box, in the video=>filters dialog box)

    You should be able to get very very close with avisynth filters
    Quote Quote  
  30. Originally Posted by sreemv View Post
    Now, I want to try loadvirtualdubplugin() route - any help with the built in Vdub filters such as brightness/contrast and levels would be much appreciated. I can find the ".vdf" files for external Vdub plugins and load them in avs but cant find these built in plugins.

    All this because exporting uncompressed RGB from vdub is writing a 800GB file each time which I then compress to x264. I am also trying external encoder option from vdub which is not working at the moment.
    If you are only using brightness/contrast filter, you can stay in YUV in vdub

    You can use x264vfw in vdub, you don't need external encoder (Unless you want aac audio). x264vfw can output mp4, mkv if you use the commandline box

    Another option is to use vdub as a frameserver if you don't want large intermediate files (but it only frameserves RGB, not YUV)
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!