+ Post New Thread
Results 1 to 11 of 11
  1. #1
    Junior Member level 1
    Points: 219, Level: 2

    Join Date
    Jul 2012
    Location
    Finland
    Posts
    16
    Helped
    1 / 1
    Points
    219
    Level
    2

    Decoding color from digitized NTSC component video signal

    Help from experienced digital signal processing specialists is needed! I recently did a nice hack where I digitized a composite video signal from Raspberry Pi using a USB oscilloscope, and decoded it to a B/W video in computer:

    http://codeandlife.com/2012/07/31/re...ith-picoscope/

    I just recently got a better scope, and was able to increase the capture quality much further - with a larger buffer, I can get as much as 4000-8000 samples per scanline (250-500 MSps sampling rate), resulting in very usable B/W "composite video console" on PC:

    https://dl.dropbox.com/u/1404053/ps3000.png

    Now I'd really like to add colors. The problem is, my maths studies are from 10 years ago, and I haven't made much progress today. The scanline signal looks like this:

    http://codeandlife.com/wp-content/up...m-1024x268.png

    There's a reference 3.579545 MHz color burst (~8 cycles) in the beginning of a scanline, and what then follows is luminance data, overlaid with color data that is added to luminance by modulating two 3.579545 MHz carrier waves 90 degrees apart (I have understood that their superposition creates a single sine wave varying in phase and amplitude).

    However, I'm not sure how to decode (separate and normalize) the luminance and two color components from the single waveform. Creating digital filters with FFT + iFFT is one option (don't know much about that either), but I was thinking, might there be some shortcut around this? I can successfully "tune" a sine wave digitally to the same phase as the reference colorburst, but so far I haven't figured out how to use that synced sine wave to extract the "resonant" color data digitally.

    The solution wouldn't need to be very accurate, even 10-20 accurate color vectors over the scanline would suffice for my purposes. :) Any ideas and pointers would be welcome!
    Code and Life

  2. #2
    Advanced Member level 3
    Points: 7,552, Level: 20
    milind.a.kulkarni's Avatar
    Join Date
    Oct 2011
    Location
    Bangalore
    Posts
    923
    Helped
    213 / 213
    Points
    7,552
    Level
    20
    Blog Entries
    1

    Re: Decoding color from digitized NTSC component video signal

    In my view the video signal that you mentioned comes broadly in the categories called as CVBS which in another word called as "Composite video" ....these video signal most of the time are uses QAM( quadrature amplitude modulation techniques ) refer the link below-

    http://www.intersil.com/content/dam/...n96/an9644.pdf

    so what you need to do is either have some chip to do this duty and there are various CVBS decoder available in the market for you ...refer

    https://www.google.co.in/search?q=cv...w=1366&bih=606




    Good Luck
    Hope the post will be helpful to you....
    "Sharing is the best way of Learning"


    1 members found this post helpful.

    •   Alt20th August 2012, 13:49

      advertising

        
       

  3. #3
    Junior Member level 1
    Points: 219, Level: 2

    Join Date
    Jul 2012
    Location
    Finland
    Posts
    16
    Helped
    1 / 1
    Points
    219
    Level
    2

    Re: Decoding color from digitized NTSC component video signal

    Quote Originally Posted by milind.a.kulkarni View Post
    In my view the video signal that you mentioned comes broadly in the categories called as CVBS which in another word called as "Composite video" ....these video signal most of the time are uses QAM( quadrature amplitude modulation techniques ) refer the link below
    Thanks for the link, it was quite informative! Maybe implementing a high pass filter would be one option to get rudimentary color signal out, or even a trap filter, using fourier transformations.

    Quote Originally Posted by milind.a.kulkarni View Post
    so what you need to do is either have some chip to do this duty and there are various CVBS decoder available in the market for you
    I'm going for a full SW based approach if at all possible, without any external components - just plug the component video cable to the scope and decode everything in software (since analog components can do it with the same signal, it must be possible digitally also). Preferably, I'd also write the decoding algorithms myself, but using external FFT/iFFT libraries to implement digital filters is not ruled out.

    If I would be able to separate the color band from the signal using software, does anyone know how the color information could be decoded from that signal using software?
    Code and Life



  4. #4
    Advanced Member level 3
    Points: 7,552, Level: 20
    milind.a.kulkarni's Avatar
    Join Date
    Oct 2011
    Location
    Bangalore
    Posts
    923
    Helped
    213 / 213
    Points
    7,552
    Level
    20
    Blog Entries
    1

    Re: Decoding color from digitized NTSC component video signal

    ok, let me understand what you want to do but CVBS signal comes in analog form now what you are saying is you have digitize it and kept in the format like a file or files on PC that is what you want to do.... In that case you need to write QAM demodulator with lot of signal based conditions ....or how you are connecting the signal to PC ( I am assuming you want to use the software on the PC)....

    with regards,
    milind
    Hope the post will be helpful to you....
    "Sharing is the best way of Learning"



  5. #5
    Junior Member level 1
    Points: 219, Level: 2

    Join Date
    Jul 2012
    Location
    Finland
    Posts
    16
    Helped
    1 / 1
    Points
    219
    Level
    2

    Re: Decoding color from digitized NTSC component video signal

    Quote Originally Posted by milind.a.kulkarni View Post
    ok, let me understand what you want to do but CVBS signal comes in analog form now what you are saying is you have digitize it and kept in the format like a file or files on PC that is what you want to do.... In that case you need to write QAM demodulator with lot of signal based conditions ....or how you are connecting the signal to PC ( I am assuming you want to use the software on the PC).
    Yes, I'm digitizing it with a Picoscope 3206B which basically gives me the signal as C array of short values, over 1 million samples taken every 2ms (or 4, 8, 16...). I am already recognizing sync pulses and drawing scanlines using luminousity information, but would also like to add rough color info decoded from the 2000-4000 sample scanlines.

    I've already calculated a 3.5... MHz reference sine wave which I sync to signal color burst (in the beginning of every scanline) with least squares algorithm, but am unsure how to use that to extract color subcarrier phase and amplitude in different points of the scanline, because that is mixed with the luma value. Crude way might be to calculate theoretical peak (max, min) locations and use just those points to estimate color subcarrier amplitude, but I guess someone with better knowledge of digital signal processing might have tips on techniques that could be employed.

    The topic is quite complex, as it requires knowledge of both QAM and purely digital signal processing - my maths courses 10 years ago just brushed these subjects. But I'm interested in learning so even rough theoretical pointers are appreciated.
    Code and Life



    •   Alt21st August 2012, 10:41

      advertising

        
       

  6. #6
    Advanced Member level 3
    Points: 7,552, Level: 20
    milind.a.kulkarni's Avatar
    Join Date
    Oct 2011
    Location
    Bangalore
    Posts
    923
    Helped
    213 / 213
    Points
    7,552
    Level
    20
    Blog Entries
    1

    Re: Decoding color from digitized NTSC component video signal

    Now way to look at this problem will be like this .....first this information that you capture represents one frame of the video( I mean single Image of the video) with color content....Now target problem is you have sample data in the form of sequence and you need to get the two dimensional signal out of it with at lest three dimension ( R G B values of it) ......Now you will need first information is resolution of video ( My geuss here will be you are mostly dealing with 480i or 576i) to start with I am not sure how to extract this information from CVBS signal but you need to refer analog television document and the how to decode the pixel information using this luma and croma values..... I think this will be our problem sentence...

    refer this -

    http://www.google.co.in/url?sa=t&rct...5mDgLVRnDGhiwQ

    http://www.maxim-ic.com/app-notes/index.mvp/id/1184

    It is very complex problem but very very interesting for me too.....so share your progress on the forum so I will also able to learn for you...and we will be able to get the frame information from it....I am also working on it.... let sink up tomorrow...need to finish today some assignment for company

    Good Luck
    Last edited by milind.a.kulkarni; 21st August 2012 at 12:01.
    Hope the post will be helpful to you....
    "Sharing is the best way of Learning"



  7. #7
    Junior Member level 1
    Points: 219, Level: 2

    Join Date
    Jul 2012
    Location
    Finland
    Posts
    16
    Helped
    1 / 1
    Points
    219
    Level
    2

    Re: Decoding color from digitized NTSC component video signal

    Yes, the information you linked is about where I am now. NTSC that I'm decoding consists of 525 scanlines, which form two fields of about ~242 horizontal lines each, interlaced to form a single image. The component video signal does not have a horizontal resolution, instead one can think of it as a continuous luminance signal, upon which the chrominance signal is modulated. My program has a digitized version of this signal with about 2000 samples. If I just interpret this as luminance, I get a quite nice B/W image, but getting the chroma out from digital signal is hard.

    Unfortunately, all information in the net is concerned with analog separation of luminance and chrominance info, using analog filters, phase and amplitude detectors and whatnot. I have so far encountered no sources which would explain how to create trap filters or phase/amplitude detectors digitally. The data is there, but the methods to extract it are not.

    My initial attempt based on the assumption that if we have locally fairly static luminance level L, over which is overlaid a chrominance signal C using a sine wave, so the total signal would be:

    L + C * sin(x / wavelen * 2 * Pi)

    If we multiply the above signal with in-phase reference sin(x / wavelen * 2* Pi) and integrate by x through the section [0, wavelen] and assume luminance is fairly constant, we get:

    integrate( L * sin(x/wavelen * 2 * Pi) + C * sin^2 (x/wavelen * 2 * Pi), {x, 0, wavelen} ) = C * wavelen / 2

    Thus I could get C out of the wave. This would even work over any interval with length wavelen. However, for some reason that just generated pure rubbish - maybe I should not run the algo for every point using interval [x-wavelen/2, x+wavelen/2], but take full periods instead. Or something. Problem is, that even the above is a large simplification, as both the phase and amplitude of the color carrier are modulated (or, maybe there's just two sine waves 90 degrees apart, I have not visualized if these two conceptualizations are actually the same).
    Code and Life



  8. #8
    Junior Member level 1
    Points: 219, Level: 2

    Join Date
    Jul 2012
    Location
    Finland
    Posts
    16
    Helped
    1 / 1
    Points
    219
    Level
    2

    Re: Decoding color from digitized NTSC component video signal

    Ooh, I think I found something interesting along these topics from Wikipedia, namely the digital filter article:

    http://en.wikipedia.org/wiki/Digital_filter

    Especially useful seem to be pseudo code implementations for low-pass and high-pass filters that work with discrete digitization:

    http://en.wikipedia.org/wiki/Low-pas...me_realization
    http://en.wikipedia.org/wiki/High-pa...me_realization

    I think I'll try to implement these next week to see if I could separate the luminance and chrominance information, or at least make the color data more susceptible for interpretation. :)
    Code and Life



    •   Alt26th August 2012, 19:57

      advertising

        
       

  9. #9
    Super Moderator
    Points: 227,372, Level: 100
    Awards:
    1st Helpful Member

    Join Date
    Jan 2008
    Location
    Bochum, Germany
    Posts
    39,180
    Helped
    11970 / 11970
    Points
    227,372
    Level
    100

    Re: Decoding color from digitized NTSC component video signal

    I don't think that you should use an integrator for color signal demodulation. Just multiply the composite signal with the qudrature carriers and low-pass filter the product according to the color signal band width.


    1 members found this post helpful.

  10. #10
    Junior Member level 1
    Points: 219, Level: 2

    Join Date
    Jul 2012
    Location
    Finland
    Posts
    16
    Helped
    1 / 1
    Points
    219
    Level
    2

    Re: Decoding color from digitized NTSC component video signal

    Quote Originally Posted by FvM View Post
    I don't think that you should use an integrator for color signal demodulation. Just multiply the composite signal with the qudrature carriers and low-pass filter the product according to the color signal band width.
    Thank you. This gave me the confidence to continue along my original "simple" path. The crucial bit of information was this:

    http://en.wikipedia.org/wiki/Quadrat...ion#Analog_QAM

    Basically the above section just tells why the multiplication with carrier works as you said it would. Discrete low-pass filtering didn't work very well with the simplistic method suggested in the Wikipedia article, so I re-implemented my running average method and it actually worked just fine - it turned out that my original code only had two separate critical bugs.

    After getting the two color curves out, the rest was simply a YUV -> RGB conversion. For some reason, the Raspberry Pi NTSC output mode did not use YIQ color space, but the YUV from PAL. Strange. Here's the end result:

    https://dl.dropbox.com/u/1404053/composite_color.jpg

    Luminance data would still need to be cleaned from chrominance interference, but I think I'll leave that for another day. I'll let you know when I have a blog post with details ready on this one. :)
    Code and Life



  11. #11
    Junior Member level 1
    Points: 219, Level: 2

    Join Date
    Jul 2012
    Location
    Finland
    Posts
    16
    Helped
    1 / 1
    Points
    219
    Level
    2

    Re: Decoding color from digitized NTSC component video signal

    I've just posted a Youtube video of the color decoder. The source code for the project is also published under GPL. Both available here:

    http://codeandlife.com/2012/09/12/co...coscope-3206b/

    Technical details to be added as soon as I get nice illustrations done on the techniques used. :)
    Code and Life



--[[ ]]--