To: MSI/NIS Science Team

From: Mike Caplinger (mc@msss.com), Mike Malin (malin@msss.com)

Subject: Autoexposure Algorithm for MSI

Date: 24 January 1995

Introduction

This memorandum describes a proposed algorithm for an autoexposure (AE) mode for the NEAR MSI. Since the instrument has no gain or offset states, the only exposure-related parameter to be set is the shutter duration for each image.

One operational attribute of the MSI should be kept in mind during any discussion of autoexposure: the MSI can only acquire images at a maximum rate of one per second. In AE mode, each "science" image (i.e., an acquisition to be downlinked to Earth) must be preceded by a "test" image, used to compute the exposure time of the science image. This reduces the frame rate from one per second to one every two seconds. If this reduction in acquisition rate is a problem, an alternative might be to use a single test image to control the exposure of multiple science images, if it can be assumed that scene brightness will not change rapidly from exposure to exposure.

Another operational attribute of importance is the distribution of image acquisitions through different spectral filters. Since the optimum exposure time differs from filter to filter, the AE implementation must either store a different exposure value for test images to be acquired through each filter, or it must be able to compute any difference between the baseline exposure value and one to be used with each specific filter. For the purposes of this discussion, it is assumed that these exposure values are contained in a table in the instrument that can, in principle, be modified by ground uplink.

The test image exposure value is extremely important, and is likely to vary with mission phase, geometry, and the surface characteristics of the target. It must be selected to insure that the detector's full-well capacity is not exceeded, which may be tricky given the large range in illumination conditions that is likely to be encountered at Eros.

Description of Autoexposure Operation

The autoexposure scenario begins with selection of the AE exposure value based on filter position, mission phase, etc., as described above. The AE value is intentionally underexposed to insure that the entire histogram is contained within the 4096 values of the MSI A/D converter. Figure 1 illustrates how one such image might appear.

GIF = 102 KBytes

Figure 1: Simulated MSI Image: Galileo press release image of Ida, processed to reduce image brightness and amplify histogram

As the test image is being clocked off the detector, a 128-element histogram is accumulated by shifting each DN value by 5 bits and incrementing that slot in the histogram. After the detector has been completely read out and the histogram gathered, it is scanned from highest to lowest DN until the number of pixels exceeds a fixed percentage of the total number of pixels in the image. The DN of that slot in the histogram is assumed to be the highest value to be exposed "without saturating." The exposure of the image is adjusted by linear scaling to place this value at 4095 or, alternatively, at some other selectable value. The percentage of saturation allowed and the DN value of "saturation" are settable parameters.


Figure 2: Histogram of image shown in Figure 1

For example, suppose that a "saturation" value of 0.2% is selected. Twelve bins of the histogram around the maximum value might have the following values:

bin	  41   42   43   44   46   47   48   49   50   51   52   53
value	1000  500  250  100   50   25   13    0    0    0    0    0

or, converted to percentages of the total number of pixels (244x537),

bin	  41   42   43   44   46   47   48   49   50   51   52   53
%	1.31 0.38 0.19 0.08 0.04 0.02 0.01    0    0    0    0    0

The AE algorithm starts at the high end of the table and sums until the total percentage exceeds 0.2%. The running sum is

bin       53   52   51   50   49   48   47   46   45   44
cum%	   0    0    0    0    0 0.01 0.03 0.07 0.15 0.34

The percentage is exceeded at slot 44, corresponding to DNs in the range 1405 to 1438. The ratio of the low end of that DN range to the maximum DN (Max DN / 1405) is the value by which the test exposure time must be multiplied to set the science acquisition exposure. If the maximum DN is 4095 ("full-well"), this value would be (4095/1405), or 2.91. As an alternative example, assume a "saturation" value of 3850 DN was selected (to allow some "headroom" before reaching true saturation). In this case, the new exposure value would be (3850/1405) = 2.74 X the test exposure value. Figure 3 shows the result of applying this algorithm to an example image, and Figure 4 shows the resulting histogram. Note that the binning in this example is somewhat different from that described in the text, and that the figures are illustrative only.


GIF = 170 KBytes

Figure 3: Image from Figure 1 contrast stretched using AE algorithm


Figure 4: Histogram of Figure 3

This algorithm fails if the test image is overexposed (i.e., if the highest slot in the histogram exceeds the percentage of saturation allowed.) For this reason and as noted above, the test image exposure time should be selected to underexpose the image, thus minimizing the likelihood of encountering this failure mode. Should this mode be encountered, the AE procedure could have a pre-set fall-back exposure value (e.g., 0.75X the test exposure value).

This scheme is relatively insensitive to spurious bright pixels, such as would be caused by radiation hits on the detector, bad pixels, or electronic noise. A smaller histogram could potentially be used if memory is tight. Similarly, only a sub-set or fraction of the image's pixels could be summed into the histogram if CPU cycles are tight.