Video Photometry with Tangra - Algorithms and Acuracy

<< PREVIOUS   NEXT >>

Gamma Correction

As mentioned earlier gamma corrections exist in almost all video cameras and have to do with the playback of the video on a monitor. Here is the definition of 'gamma' from Poynton. C., [1]: A conventional CRT has a power-law response to voltage: luminance produced at the face of the display is approximately proportional to the applied voltage raised to the 2.5 power. The numerical value of the exponent of this power function is colloquially known as gamma. This nonlinearity must be compensated in order to achieve correct reproduction of luminance.

What this means is that gamma corrections are applied to the recorded signal in the video camera at the time of the recording, so when the video is played back on a CRT monitor it will look as close as possible to the original image because of the non linear luminance response of the monitor. Gamma corrections however exist in modern LCD and plasma monitors as well and in fact the relatively new high definition TV standard uses a gamma correction of 2.22. The LCD and TFT flat screen monitors also have a non linear response which may be different than this of the CRT monitor but they have been manufactured to correctly display a video recorded for decoding gamma of 2.2 - 2.5. The video camera applies a gamma correction by recording a different intensity from the detected intensity by using an encoding gamma:

I (recorded) = I (detected) EncodingGamma

The TV monitor has a non linear response and will display different intensity than the recorded intensity:

I (displayed) = I (recorded) DecodingGamma

Here DecodingGamma has a value of roughly 2.5 and this is a characteristic behind the physics of a CRT tube. In order to get I (displayed) = I (detected) one must use an EncodingGamma = 1 / DecodingGamma = 0.40. NTSC and PAL video cameras actually use a slightly different value of 0.45, which corresponds to the recommended decoding gamma of 2.22. It is even possible that some video cameras will use slightly different numbers. As already mentioned the high-definition standard (HDTV), which is defined by the international Rec. 709 standard, uses an encoding gamma of 0.45 above 2% input light intensity and uses no encoding gamma below 2% in order to preserve the quality at the darker end. This is necessary for the TV consumer's complete pleasure. A gamma correction that has the same value across the full range of output intensities (0-255) will have a finer input signal resolution for output values < 34 and coarser input resolution for output values > 140 (when compared to video with no gamma corrections). Because of the limited number of recorded values (256) the decoded darker side played on a monitor will more rarely be close to black and will be most of the time dark gray.

This works well for television, but does it affect low-light video cameras used for astronomy? The low-light security video cameras are designed to record video that is usually played in realtime on one of those mini CRT TVs, which you may also be using in your observations. Some cameras such as WAT-902H and WAT-902H3 use a fixed encoding gamma of 0.45 (as per the standard) and don't allow this value to be changed. Other cameras such as GSTAR (popular in Australia) use a default value of 0.45 but allow this value to be changed to 1.0 (no gamma) via the camera software. I couldn't find any information about what gamma is used by the PC164C-EX2 camera but it doesn't allow gamma to be changed. Finally some cameras more specifically designed for astronomy, such as the WAT-120N series and WAT-902 Ultimate, allow the gamma to be set by the user and offer values of 0.35, 0.45 and 1.00. The table below summarizes the information about gamma for some of the most used video cameras for astronomy:

Video Camera Gamma Can Change Gamma
WAT-902H 0.45 NO
WAT-902H3 0.45 NO
PC164C-EX2 (KPC-350BH) ?? NO
GSTAR 0.45 (default); 1.00 YES
WAT-902H Ultimate 0.35; 0.45; 1.00 YES
WAT-902H3 Ultimate 0.35; 0.45; 1.00 YES
WAT-120N 0.35; 0.45; 1.00 YES

The next logical question is: Can we detect and measure the gamma correction effects in our low-light video cameras? The purpose of the next test is to try to detect the effects of the gamma correction on the non linearity of the intensities and the deviation of the magnitude estimates.

In order to do this I measured a video of M7 recorded with WAT120N+ and Red + IR Block filter with a LO gamma of 0.45 (i.e. knowing that there is applied gamma). I measured between 100 and 170 frames and then derived an average intensity from all measured frames for the identified stars as previously described. In this case I didn't use an eye test and there is one star with a wrong magnitude evident on the plots. I checked this star later on and it indeed turned out to be much fainter on the video compared to its catalog magnitude. To exclude potentially bad measurements all stars that were identified in less than half of the measured frames (i.e. less than 80 frames) were excluded automatically by the software. I then created all combinations of star pairs without repetition and plotted each of the pairs. The value shown on the plot is the deviation from magnitudes derived from intensity with increasing magnitude difference. The X axis is the modulus of the magnitude difference between the stars and the Y axis is the deviations of the intensity derived magnitude difference from the actual magnitude difference: x = Abs(m1 - m2);    y = m1 - m2 - 2.5 * Log (I1/I2). You can click on the images to enlarge them.

     

Because the pair combinations are done randomly the number of pairs where the brighter star is first may be different than the number of pairs where the bright star is second. This is why the top and the bottom parts of the V-shaped curve may have different density. The V-shaped plot on the left represents the direct measurements and the plot on the right is the same video recorded with Gamma = LO, however this time the pixel values were corrected for gamma = 0.45 before the aperture photometry was done. It is evident that the gamma effects in the uncorrected video are present and if magnitude differences are derived from intensities the uncorrected gamma will cause a shift of around 0.25 mag per 1.0 mag difference.

It is also evident that correcting the pixels for gamma of 0.45 makes the intensities linear on the right image. This firstly shows that the effect on the left is indeed caused by gamma corrections applied by the video camera to the video record, and secondly that the used encoding gamma was indeed 0.45 because after the reverse correction for this value, the deviation becomes flat on the right image.

The two plots also demonstrate that the random error is quite large and has a value of ~0.4 mag for the majority of the pairs. More about the random error later in the article.

More Plots of a video recorded with Gamma = OFF (1.00) are also available that show what happens if we try to reverse correct for gamma of 0.45 when actually no gamma was used by the video camera. And finally the purple plot below represents the measurement of a HI gamma (value of 0.35) in WAT-120N+ and shows a deviation of 0.55 mag per 1 magnitude difference caused by the uncorrected gamma. There are again top and bottom wings of the V-shaped curve but the bottom wing contains much fewer star pairs than the top one and makes the plot look a little bit strange. The random error for this plot is ~0.7 mag for the majority of the pairs.



The good news about gamma correction effects is that they can be reversed as demonstrated here if their presence and the encoding gamma value are known. LiMovie (the most popular software for light curve reduction) offers an option to reverse the gamma corrections. The user has to enter the value of the encoding gamma (i.e. 0.45) and not the decoding gamma (i.e. not 2.22). Tangra (when released) will also offer ability to reverse the gamma correction of the original video.

Testing the Gamma Correction in PC164C-EX2

The next plots are from data recorded with PC164C-EX2 with no filter. Because the camera is non integrating I couldn't get deep enough with a Red + IR Block filters combination to get a sufficient number of stars, so I recorded and processed a video with no filter. The plot on the left is measured with no correction for gamma and the plot on the right is reverse corrected for gamma of 0.45. The two plots show that the PC164C-EX2 actually uses a gamma of 1.00! This comes as a surprise to me as this is a security camera not specifically designed for astronomy. This only shows that for those cameras that don't show the value of gamma in their specification we really need to test them to know for sure what gamma they are using. The raw datasheet can be downloaded here.

           

I noted two other observations: The FWHM of the stars in PC164C-EX2 was about 0.5 - 1 pixels bigger i.e. the stars were bigger. Also the standard deviation of the measurements is a few times higher compared to the standard deviation of the WAT-120N+ measurements which agrees with the much higher flickering on the screen which I noticed when I was recording in the same evening videos of M7 with the two cameras. However there seems to be a small difference in the random error when comparing a video with no filter recorded with PC164C-EX2 and video with R+IR Block filter recorded with WAT-120N+. The PC164C-EX2 video seems to show a slightly smaller random error. This may be due to different factors including the larger stars on the CCD chip allowing a finer resolution (?) or a spectral sensitivity.

Also to my surprise Frank Freestar8n measured independently the gamma of the same camera using a controlled light source and a microcontroller (http://www.astrogeeks.com/Bliss/OccultVideo/videogamma.html) and he found that the PC164C-EX2 camera he was using had a gamma of 0.45! Because of this results I did a second test of my second PC164C-EX2 camera on the next night and this time I tried all the 4 combinations of the switches on the back of the camera. However all the 4 videos still gave the same result i.e. the camera I was testing was using a gamma of 1.00. This is demonstrated by the uncorrected measurement on the left and the reverse corrected for gamma = 0.45 measurement on the right.

           

After the confirmation of my results with my two EX2 cameras we did a third test. This time Frank recorded the open clusters h and chi Persei and sent me the videos. I measured his videos using my method that showed a gamma of 1.00 for my PC164C-EX2 cameras. My tests indeed confirmed the results from Frank's independent testing that his EX2 camera had a gamma correction of 0.45, which is not what my two EX2 cameras had. The two plots below show the results and even that UCAC2 had only half of the visible stars at declination +57 the results are quite evident. The datasheet is available for download here. So if you are using a PC164C-EX2 camera (or another camera that doesn't give its gamma in the technical specifications) you need to test your camera to find out what gamma it is actually using. Also we need to be careful about a security camera that uses a software to produce a high sensitivity and doesn't tell in its technical specification what gamma it is using.

           

So, if intensity drops from video observations are used to derive stellar magnitude differences it is essensial to record the video camera (including the model) in the observation report and to reverse the gamma corrections before measuring the light curve when necessary. When the used video camera offers a number of different gamma correction values, the observer should be required to record and report the used gamma correction. If the used video camera doesn't allow the gamma correction to be changed and the specification of the camera doesn't mention the value of the gamma correction used then test should be carried out on per camera basis by the observer to determine the gamma correction of the camera.

Testing the Gamma Correction in WAT-902H Ultimate

And finally for completeness I also did tests with a WAT-902H Ultimate camera that allows gamma to be changed. The first plot is uncorrected measurements of a video recorded with gamma = OFF. The second plot is of a video recorded with gamma = LO and shows the measurements of the uncorrected pixels. And the third plot is of the second video (recorded with gamma = LO) but this time the pixels have been corrected for gamma = 0.45. The raw data can be downloaded here.

           

The three plots demonstrate that indeed WAT-902H Ultimate uses gamma of 1.00 and 0.45 as expected.

<< PREVIOUS   NEXT >>