Calibrating A Video: A Procedure. by Roger Venable International Occultation Timing Association Getting Started 1. Record your occultation video in your usual way. 2. In the field at the time of the occultation event, make a darkfield video recording, and also make flatfield video recordings. It is usually best to make several flatfield recordings at different brightnesses. See note. 3. Get software: Limovie version 0920 or higher, Registax version 4.0 or higher, VirtualDub version 1.6.14 or higher, and AviSynth version 2.5 or higher. See note. 4. When you digitize or convert the data recording to an avi file, also digitize or convert the darkfield and flatfield recordings to avi files. 5. In VirtualDub, use the "levels" video filter to convert the luma 601 videos, with a brightness range of 16 to 235, to the pc range of 0 to 255. You must do this with the data videos, the darkfield video, and the flatfield videos. Run the dub for each of them, and save each as a new avi. See note. 6. Open the flatfield recordings in Limovie and study their brightnesses in the areas of the field of view containing the occultation star and any comparison stars that you may use. To do this, enlarge the background circle to its maxiumum of 25 pixels radius, and look at the "BKG/Frame" value in the lower left part of the interface. Compare this value among your flatfield recordings. You should use the flatfield video that is brightest without having saturation of pixels in the critical areas. (It doesn't matter if other areas of the flatfield are saturated.) Dealing With The Darkfield 7. Use Registax to make averages of the darkfield video. See note. 8. Open VirtualDub and open the jpg file you just created. (It will open.) Check the "levels" video filter to be sure that it is not being applied, because you just used it is step 5 and you don't want to use it again now. Then save the darkfield as an avi file. This creates a one-frame avi file of the darkfield. 9. Open the pc-range occultation event avi in Limovie, and measure it at multiple points, but avoiding hot pixels, emphasizing measurements in the areas of the field near the occultation star. This will enable you to estimate the range of brightness of the critical areas of the event avi. Make estimates of the *range* of brightness between the darkest and lightest pixels of the background illumination of the occultation video. To do this, set the aperture radius to zero, which causes it to include only one pixel, and run a number of brief measurement runs at different points. In the csv files so created, look for the 'Aperture' values, not the 'Measurement' values. 10. Using VirtualDub, open the occultation event avi. Set the "brightness/contrast" video filter by adjusting the brightness upward by moving the slider to the right. Each gradation on the slider's scale is 16 Limovie-value brightness points per pixel. Move it a distance corresponding approximately to 1/2 of the range of brightness that you ascertained in step 6, or perhaps slightly more than that amount. Then run the dub. Then save the resultant file as your new data avi file. See note. 11. Make an avs file that uses the overlay function of AviSynth to subtract the darkfield avi from the data avi. It should look like this: a = AVIsource("C:\path1\occultationevent.avi") b = AVIsource("C:\path2\oneframedarkfield.avi") overlay(a,b,mode="subtract",pc_range=true) See note. 12. Open this avs file with VirtualDub. Check the "brightness/contrast" filter to make sure it is not being applied, for you used it in step 10 and you don't want to use it again now. Then run the dub. Then save the resultant video as an avi file. This is your darkfield-adjusted event avi. Notice that the numbers of the inserted timing data are damaged by the darkfield subtraction. Do not delete the original event file, because you will need it for frame counts and timing data. Dealing With The Flatfield 13. Make an avs file to subtract the darkfield from the flatfield avi, similarly to what you did with the event avi. It should look like this: a = AVIsource("C:\path3\flatfield.avi") b = AVIsource("C:\path4\oneframedarkfield.avi") overlay(a,b,mode="subtract",pc_range=true) See note. 14. Open this avs file with VirtualDub, and run the dub. Then save it as your dark-adjusted flatfield avi file. 15. Use Registax to make averages of the new flatfield-with-dark-subtracted avi. This is done by loading it into Registax, clicking on the "Flat/Dark/Reference" menu and then clicking [pay attention now] "Create Darkframe". Do NOT click "Create Flatfield" because that is a mysterious and incompletely documented function. Registax will then stack and average the flatfield-with-dark-subtracted as though it were a darkfield. Save it as a jpg file that calls it a flatfield, not a darkfield. 16. In VirtualDub, open the flatfield one-frame jpg file, and save it as an avi. 17. Open Windows Paintbrush. There will be a blank image there, all white. Use the image attributes function to adjust the blank image's dimensions to match those of your avi's. This will probably be 720 pixels horizontally by 480 vertically. When you set it up that way, you will note that the horizontal pixels are numbered from 0 through 719, and the vertical from 0 through 479. Save this image as a jpg, with a name something like "allwhite.jpg". 18. Open the plain white jpg in VirtualDub, and then save it as an avi. This will create a one-frame avi that is plain white. 19. Open the one-frame flatfield avi file in Limovie, and measure it at multiple points, emphasizing measurements in the areas of the flatfield that correspond to the areas that contain the occultation star near the time of the event in the data video. First, make estimates of the *mean* brightness of the background. To do this, set the background outer radius at 25, and by setting the aperture radius to zero you will be able to set the background inner radius at 1. Then read the background value, called "BKG/Frame" in the lower left corner of the interface. Click around the critical areas of the field to get an idea of what the mean value is. Remember this mean brightness number. Let's call it 'm'. Then calculate (2m - 255)/16. Let's call that 'n.' It may be postive or negative. You will use this number in an operation in step 21. Second, leaving the aperture and background radius settings as they are, read the one-pixel aperture value at multiple points of this flatfield in the critical areas. This value is in the box labelled "Frame" at the very lower left corner of the interface. You need to add the "Frame" number to the BKG/Frame value to get the total brightness of the pixel. Click around the critical areas to ascertain the highest value you can find of such a pixel. Call that value (after adding the BKG/Frame value) 'p.' Calculate (255/p)*100. Let's call that 'q.' You will use this number, too, in an operation in step 21. 20. Make an avs file that manipulates the one-frame flatfield avi. Let 'a' be the flatfield avi, and let 'b' be the pure white one-frame avi. Here is the avs file: a = AVIsource("C:\path5\oneframeflatfield.avi") b = AVIsource("C:\path6\allwhite.avi") overlay(a,b,mode="exclusion",pc_range=true) See note. 21. Open this avs file in VirtualDub. Before you run the dub, add a video filter called 'brightness/contrast.' Adjust this filter's brightness slider leftward or rightward by a number of gradations equal to n (from step 19.) Negative n is to the left, positive to the right. (Each notch on the slider adjusts the entire file by 16 in brightness on the 0 to 255 scale. The resolution of this adjustment is 1.6, because there are 10 pixels of slider movement per notch. So, if n is 0.65, you will want to move the slider 0.65 x 10 pixels, or 7 pixels, to the right.) Leave the contrast slider at 100%. Then click "OK." Then, click on the 'brightness/contrast' filter a second time, so as to bring up a second instance of this filter, to run after the first instance. This time, set the brightness slider to normal (the middle position,) and move the contrast slider to q. (The contrast slider has a resolution of 6.25%. You should move it to the highest level you can that is *less than* q, so as not to exceed q.) Then click "OK" twice to return to the main interface. Then run the dub. Save the result as an avi file, called something like, 'AdjustedFlatfield.avi.' The new flatfield avi is a negative of the original dark-subtracted flatfield, with the same proportions of contrast in its dark and light areas, but with the contrast stretched to the maximum allowed in the 255 level grayscale. 22. Make another avs file, this one to apply the fully adjusted flatfield to the event avi by multiplication (not by division!) It should look like this: a = AVIsource("C:\path7\DarkAdjustedEvent.avi") b = AVIsource("C:\path8\FullyAdjustedOneFrameFlatfield.avi") overlay(a,b,mode="multiply",pc_range=true) 23. Open this avs file in VirtualDub. Be sure the "brightness/contrast" filter is not applied, because you applied it in step 21, and you don't want it here. Then run the dub. Then save the result as an avi. This is your fully calibrated event avi. Final Adjustment & Processing 24. The event avi so created will likely appear dark. To make the event more readily visible without damaging any brightness data, you can open VirtualDub and apply the "brightness/contrast" filter. Apply brightness changes alone to avoid affecting any relative proportions of brightness or noise. Apply contrast settings to enhance the visibility of a faint event while increasing noise by the same proportion. When you have adjusted the avi to your satisfaction, save it as an avi file. 25. Open the final avi in Limovie and measure the brightnesses of stars in the usual way. -- Roger Venable, November 2009