VideoHelp Forum




+ Reply to Thread
Results 1 to 7 of 7
  1. Member
    Join Date
    Jun 2007
    Location
    Canada
    Search Comp PM
    Colour Conversion problems with Avisynth

    Hi All,

    Hope I have the appropriate forum . . .

    Perplexed about all the information I have seen about colour spaces and colour conversion, I decided to do a couple of tests. Using Virtual Dub I captured two 640x480 interlaced clips using HuffYUV in YUY2 color space.

    Clip 1 was done with Extend luma black point and Extend luma white point both disabled. This is supposed to create a clip with a colour range of 0 to 255 for viewing on a PC. I named this clip VD-no.luma.avi

    Clip 2 was done with Extend luma black point and Extend luma white point both enabled: "Compresses the luminance range of an image so that "superwhite" levels from 0-15 are scaled to within the valid luminance range of 16-235, out of 0-255." This is supposed to create a clip with a color range of 16-235 for viewing on a TV set, i.e. DVD player. I named this clip VD-luma.avi

    To analyze these clips I used AvsP (a GUI for Avisynth):

    The first thing I did was to use ColorYUV(Analyze=True) which shows the Luma and Chroma values:

    This confirmed that the VD-no.luma.avi clip showed values of 0 (black) and 255 (white) and VD-luma.avi showed values of 16 (black) and 231 (white) - so far so good.

    The next thing I tried was ColorYUV(levels="PC->TV") on the VD-no.luma.avi clip. This is supposed to adjust a "PC" clip to a "TV" clip, i.e. change the values <16 to 16 and values >235 to 235 - in effect making the clip suitable for viewing on a TV - this function did not appear to do anything.

    Then I tried Levels(0, 1, 255, 16, 235, coring=false) on the VD-no.luma.avi clip - this is supposed to do the same thing as ColorYUV(levels="PC->TV") - this appeared to work:
    the lowest value is now 16 instead of 0 and the highest value is now 235 instead of 255:

    Levels(0, 1, 255, 16, 235, coring=false)
    used this with VD-no.luma.avi
    Luma Y / ChromaU / ChromaV
    Average 173.29 128.80 127.51
    Minimum 16 96 87
    Maximum 235 164 141
    Loose Minimum 17 122 121
    Loose Maximum 223 136 131

    compared to VD-no.luma.avi w/o Levels
    Luma Y / ChromaU / ChromaV
    Average 183.14 128.56 126.83
    Minimum 0 89 79
    Maximum 255 170 143
    Loose Minimum 1 120 119
    Loose Maximum 241 137 131

    Levels(0, 1, 255, 16, 235, coring=true)
    used this with VD-no.luma.avi
    Luma Y / ChromaU / ChromaV
    Average 173.41 128.80 127.51
    Minimum 30 96 87
    Maximum 218 164 141
    Loose Minimum 30 122 121
    Loose Maximum 218 136 131

    "Levels also changes the chroma of the clip."

    BTW - what does coring=true actually do - the avisynth info is unclear to me . . .

    Then I tried Limiter(16, 235, 16, 240) which is supposed to create a range of values from 16-235 (luma) and 16-240 (chroma) for viewing the clip on a TV - it appeared to do nothing at all. - and it appears that the values shown are incorrect . . .

    My Observations [possibly incorrect]
    If a person is using VirtualDub for captures and they want to view the clip on a TV set, i.e. DVD, MPEG-2, MPEG-4 they should enable both Extend luma black point and Extend luma white point.

    If a person has a clip that has a range from 0-255 it will not look OK on a TV set, the range has to be "remapped" to 16-235 - however this appears easier said than done - unless I am missing something here, ColorYUV(levels="PC->TV") and Limiter(16, 235, 16, 240) don't appear to do what they are supposed to do.

    Am I missing something here? Why does ColorYUV(levels="PC->TV") and Limiter(16, 235, 16, 240) appear to do nothing . . . and as noted on Avisynth.org: "Levels also changes the chroma of the clip."

    P.S. I do have some jpeg screen captures that demonstrate these points but I don't know how to post them . . .

    TIA
    Quote Quote  
  2. I recommend you use the VideoScope() filter to view the effects of ColorYUV() and Limiter(). It shows the luminance values graphically:



    Limiter() truncates values below 16 and above 235. So a sequence of pixels with luminance:
    0, 8, 16, 24, 32... 232, 240, 248, 255

    After Limiter(16, 235, 0, 240) would look like:
    16, 16, 16, 24, 32... 232, 235, 235, 235

    After Levels(0, 1, 255, 16, 235, coring=false) the range is compressed rather than truncated. Approximately:
    16, 23, 30, 37, 44... 214, 221, 228, 235

    Coring is similar to Limter(). If, after the ColorYUV() adjustment, and with coring=true, any pixels fall outside the 16-235 range they are truncated the same as Limiter(16, 235, 0, 240).

    To include images in your post use the "browse" button below the editing window to locate a file. When you "submit" the file will be included. If you don't include the image token in your text it will automatically be appended to the end of the post. You can then edit your post and move the image where you want it.
    Quote Quote  
  3. Member
    Join Date
    Jun 2007
    Location
    Canada
    Search Comp PM
    Thanks jagabo

    I just downloaded vscope_25_dll_20040516.zip - I'll check it out tomorrow

    BTW, I found that one of my problems was that "Coloryuv does not apply any image correction when you use analyze=true - it analyzes and returns the uncorrected image." [from sh0dan - AviSynth Developer doom9.org]

    I appreciate your explanation of Limiter and Levels - seems to me that Limiter would be the preferred way to go - what do you think?

    Also, when I compare:

    ffmpegSource("F:\VD-no.luma.avi") to

    to
    ffmpegSource("F:\VD-no.luma.avi")
    Limiter()

    Visually, I see no change at all.

    Finally, if you had a clip that ranged from 0 to 255 and you wanted to encode it for viewing on a TV set what avisynth tool would you use?

    TIA
    Quote Quote  
  4. Member
    Join Date
    Dec 2007
    Location
    Netherlands
    Search Comp PM
    I just found this thread with the search and have a question about this:

    If I have a video with a luma range of 0-255, and if I want to feed it into an MPEG2 encoder like HCEnc, would it be a good idea to clip the luma to 16-235 first, using ColorYUV(levels="PC->TV")?
    Quote Quote  
  5. Originally Posted by Bergen
    If I have a video with a luma range of 0-255, and if I want to feed it into an MPEG2 encoder like HCEnc, would it be a good idea to clip the luma to 16-235 first, using ColorYUV(levels="PC->TV")?
    Note that ColorYUV(levels="PC->TV") doesn't clip (clipping implies everything below 16 becomes 16, everything above 235 becomes 235, and everything else stays the same) it reduces the range (something Y' = 16 + Y * 0.86). To clip you want to use ColorYUV(opt="coring") or Limiter().

    Whether you want to use ColorYUV(levels="PC->TV") or ColorYUV(opt="coring") depends on whether you want the reduction in contrast that the former gives. It's OK if your video has a little content outside the 16-235 range. One of the reasons the spec calls for 16-235 is to have a little headroom for overshoot.
    Quote Quote  
  6. Member
    Join Date
    Dec 2010
    Location
    quebec
    Search Comp PM
    wrong thread sorry
    Image Attached Files
    Quote Quote  
  7. Member
    Join Date
    Jul 2009
    Location
    Spain
    Search Comp PM
    I know this is an ancient thread, but since smartel has accidentally brought it to life again, it's worth correcting a
    possible misunderstanding.

    Originally Posted by wiseant View Post
    VD-no.luma.avi w/o Levels
    Minimum 0 ...
    Maximum 255 ...

    Levels(0, 1, 255, 16, 235, coring=true)
    used this with VD-no.luma.avi
    Minimum 30 ...
    Maximum 218 ...

    BTW - what does coring=true actually do - the avisynth info is unclear to me . . .
    Originally Posted by jagabo View Post
    Coring is similar to Limter(). If, after the ColorYUV() adjustment, and with coring=true, any pixels fall outside the 16-235 range they are truncated the same as Limiter(16, 235, 0, 240).
    There seems to be a confusion here between Levels(coring=true) and ColorYUV(opt="coring").
    The latter acts like Limiter, but Levels(coring=true) behaves differently.
    First input luma is pre-scaled from [16, 235] to [0, 255], then the levels conversion is performed using the supplied parameters, and finally the output is scaled back from [0, 255] to [16, 235].

    This explains why, using Levels(0, 1, 255, 16, 235, coring=true), the OP's [0, 255] input clip ended up as [30, 218] instead of [16, 235]. Pixels originally in [0, 16] were all converted to 0 by the 'pre-scaling', then to 16 by the Levels parameters, and finally to 30 by the 'post-scaling'. Similarly anything in [235, 255] was converted first to 255, then to 235, and finally to 218.
    Quote Quote  



Similar Threads

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