From: will@celia.UUCP (Will McCown)
Newsgroups: rec.video.production
Subject: Re: SMTPE color bar values
Date: 15 Sep 92 16:48:26 GMT
Reply-To: celia!will@usc.edu (Will McCown)
Organization: Rhythm & Hues, Inc., Hollywood

In article <4058@vidiot.UUCP> brown@vidiot.UUCP (Vidiot) writes:
>In article <1992Sep10.230648.14045@ictv.com> barry@ictv.com (Barry Lustig)
>writes:
><
><Does anybody have the RGB color values for the colors in the SMTPE
><color bars?  I'm trying to put together an image and want to make sure
><that I do it right.
>
>I think this was answered once before and I know something is a little 
>different than what I am going to say here.
>
>The main problem is that you are talking about apples and oranges.  The SMPTE
>color bars are used in broadcast television.  RGB values aren't, at least not
>exactly.

< description of smpte bars in composite NTSC deleted>

The so-called "SMPTE bars" are based upon the earlier EIA standard RS-189-A.

RS-189-A standard explicitly states that the values of the bars correspond 
to saturated colors transmitted at 75% of full amplitude.  This refers
to the "gamma corrected" red, green, and blue signals before encoding.

The SMPTE standard (ECR 1-1978) adds to the RS-189-A the thin band of
color bars useful for setting chroma gain and phase.  It also adds the 
"black set" bars for setting black level.

The I and Q bars at the bottom of the SMPTE bars cannot be represented in
RGB (they would require negative values).  However an acceptable replacement
can be generated by adding an offset to the R, G, and B values.  Likewise
the - 4 ire bar in the pluge bars cannot be generated however the +4 ire
section is still useful.

Here is a c code fragment from a program which generates pseudo-SMPTE bars.

/* this codes presumes that the image has been filled with black */
/* the globals width and height are set to the size of the screen in
   pixel */

void rectfs(x1, y1, x2, y2)
/* fill rectangle with current color */
{
/* code deleted */
}

void matrix(float R, float G, float B);
/* sets current color to the value of R, G, B */
{
/* code deleted */
}

/*write out bar n where n ranges from 0-(top-1), writes top/bot of linebuf*/
void putbar(short n, short top, short bot, short yy1, short yy2)
{
    rectfs((width*n*top/bot),yy1,(width*(n+1)*top/bot),yy2);
}
    
void smptebar()
{
/* bottom lines */
    yy1 = 0;
    yy2 = (short)((float)height*0.25);

/* i, y, q bars are 5/28's of the window wide */
/* -i bar */
    matrix(-0.2067+0.2067,0.058811+0.2067,0.23892+0.2067);
    putbar(0,5,28, yy1, yy2);

/* white bar */
    matrix(1.0,1.0,1.0);
    putbar(1,5,28, yy1, yy2);

/* q bar */
    matrix(0.1347+0.2067,-0.14011+0.2067,0.36865+0.2067);
    putbar(2,5,28, yy1, yy2);

/* pluge bar */
    matrix(0.043,0.043,0.043);
    putbar(15,1,21, yy1, yy2);

/* calculate the middle smpte bars, there are 39 lines of these */
    yy1 = yy2+1;
    yy2 = yy2+(short)((float)height*0.08);

/* blue bar */
    matrix(0.0,0.0,0.75);
    putbar(0,1,7, yy1, yy2);
/* magenta bar */
    matrix(0.75,0.0,0.75);
    putbar(2,1,7, yy1, yy2);
/* cyan bar */
    matrix(0.0,0.75,0.75);
    putbar(4,1,7, yy1, yy2);
/* gray bar */
    matrix(0.75,0.75,0.75);
    putbar(6,1,7, yy1, yy2);

/* calculate upper smpte bars, there are 325 lines of these */
    yy1 = yy2+1;
    yy2 = height-1;

/* gray bar, 0.75 of all three colors */
    matrix(0.75,0.75,0.75);
    putbar(0,1,7, yy1, yy2);
/* yellow bar */
    matrix(0.75,0.75,0.0);
    putbar(1,1,7, yy1, yy2);
/* cyan bar */
    matrix(0.0,0.75,0.75);
    putbar(2,1,7, yy1, yy2);
/* green bar */
    matrix(0.0,0.75,0.0);
    putbar(3,1,7, yy1, yy2);
/* magenta bar */
    matrix(0.75,0.0,0.75);
    putbar(4,1,7, yy1, yy2);
/* red bar */
    matrix(0.75,0.0,0.0);
    putbar(5,1,7, yy1, yy2);
/* blue bar */
    matrix(0.0,0.0,0.75);
    putbar(6,1,7, yy1, yy2);
}

All of this also assumes that no further translation of the RGB values
occurs before the signal is output, in particular on SGI systems you
need to set gamma to 1.  Also it assumes the whatever encoder is attached
will map the value 0 into the 7.5 ire setup level and 1 into 100 ire.  This
is the case for most computer workstation -> encoder setups but not
necessarily all.

-- 

Will McCown, Rhythm & Hues, Inc., Hollywood CA. (213) 851-6500
INTERNET: celia!will@usc.edu     or willmc@alumni.caltech.edu