VideoHelp Forum
+ Reply to Thread
Results 1 to 8 of 8
Thread
  1. Member
    Join Date
    Apr 2023
    Location
    United Kingdom
    Search PM
    Hello all,

    I need to make an explanation of color difference signals in YUV.

    I'm sure you can do this simply in AviSynth but I'm struggling to work it out, I want to just extract Y (so essentially mono) which is easy enough but can you just generate the Chroma portion as output by AviSynth?

    It doesn't have to be astonishingly accurate, it's only for visual conceptualization.

    Thanks,
    Ben
    Quote Quote  
  2. Member Skiller's Avatar
    Join Date
    Oct 2013
    Location
    Germany
    Search PM
    UtoY()
    and
    VtoY()
    return just the chroma channel (either U or V).
    Quote Quote  
  3. Member
    Join Date
    Apr 2023
    Location
    United Kingdom
    Search PM
    Great thank you, maybe my question is malformed but you can extract a color representation? This shows the channel in mono (which is expected.)

    Something like the image here?

    https://upload.wikimedia.org/wikipedia/commons/2/29/Barn-yuv.png
    Quote Quote  
  4. Member Skiller's Avatar
    Join Date
    Oct 2013
    Location
    Germany
    Search PM
    Yes, that's easy.


    For U:

    Code:
    Y=Levels(0,1,255, 128,128, false)
    U=UtoY()
    V=Grayscale().VtoY()
    
    YToUV(U, V, Y)

    For V:

    Code:
    Y=Levels(0,1,255, 128,128, false)
    U=Grayscale().UtoY()
    V=VtoY()
    
    YToUV(U, V, Y)
    Quote Quote  
  5. Note first that you can't "see" U or V. Any way of visualizing them is in some way artificial. What Skiller is doing is displaying the U or V channel with the other channels mapped to 128 (medium grey for the luma, grey for the other chroma channel). Skiller's U and V channels don't look the same as the wikipedia image because the wikipedia image isn't showing U and V that way but some other convolution. A slight modification of Skiller's conversions (the end result is the same):

    Code:
    function ShowU(clip c)
    {
        Y=ColorYUV(c, cont_y=-256)
        U=UtoY(c)
        V=Y
    
        YToUV(U, V, Y)
    }
    
    function ShowV(clip c)
    {
        Y=ColorYUV(c, cont_y=-256)
        U=Y
        V=VtoY(c)
    
        YToUV(U, V, Y)
    }
    
    ImageSource("Barn-yuv.png", start=0, end=23, fps=23.976) 
    Crop(0, height/4*0, -0, height/4) # just the top part
    ConvertToYV24() # so Y, U, and V all have the same dimensions
    StackVertical(last, GreyScale().Subtitle("Y"), ShowU().Subtitle("U"), ShowV().Subtitle("V"))
    Image
    [Attachment 70983 - Click to enlarge]
    Quote Quote  
  6. Member Cornucopia's Avatar
    Join Date
    Oct 2001
    Location
    Deep in the Heart of Texas
    Search PM
    Nice one!
    Quote Quote  
  7. Member
    Join Date
    Apr 2023
    Location
    United Kingdom
    Search PM
    Thank you both, and @jagabo thank you for taking the time to help me with this.

    Totally understand with regards to it being artificial, I get that entirely but I was struggling to produce a concept for a non expert audience.

    Thanks again, that is very kind.

    Ben
    Quote Quote  
  8. I don't know exactly what the Wikipedia image is show as U and V but I worked out something that looks similar:

    Code:
    function ShowUAsBlueGreen(clip c)
    {
        c
        ShowU().Tweak(hue=-22).ColorYUV(off_u=22, off_v=-55)
         YtoUV(UtoY(), VtoY(), c.VtoY().ColorYUV(cont_y=-128, off_y=-40))
    }
    
    function ShowVAsRedYellow(clip c)
    {
        c
        Showv().Tweak(hue=10).ColorYUV(off_u=-55, off_v=10)
        YtoUV(UtoY(), VtoY(), c.UtoY().ColorYUV(cont_y=-212, off_y=-16))
    }
    Wikipedia image on the left, above functions on the lower right:

    Image
    [Attachment 71249 - Click to enlarge]
    Last edited by jagabo; 26th May 2023 at 19:08.
    Quote Quote  



Similar Threads

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