glhist
Description
glhist is a utility designed for βChavez-like histogram equalizationβ on JCU GLORIA format files, particularly suited for EM-12 type data. This tool corrects for across-track variations in intensity, essentially destriping the imagery by normalizing pixel values based on statistical properties. It supports both a static equalization derived from the entire dataset and a more dynamic rolling average normalization for more localized corrections.
Usage
glhist [-invalid <value>] [-roll <size>] [-show_sections] [-v] [-normalize <value>] [-first <ping>] [-last <ping>] [-start <pixel>] [-finish <pixel>] <rawfile> <eqfile>
Arguments
| Option | Description | Default |
|---|---|---|
-invalid <value> | Specifies the pixel value that represents invalid data. These pixels are ignored in calculations. | 255 |
-roll <size> | Activates rolling average normalization. Specifies the number of pings to use for calculating the rolling average. | 0 (static equalization) |
-show_sections | Used with -roll, for debugging the sectioning and interpolation process. | (None) |
-v | Enable verbose output. | (None) |
-normalize <value> | Specifies a value to normalize the overall average intensity to. | 0.0 (calculated average) |
-first <ping> | Specifies the first ping (record) number to include in the statistical analysis. | 0 |
-last <ping> | Specifies the last ping (record) number to include in the statistical analysis. | no_recs (end of file) |
-start <pixel> | Specifies the starting across-track pixel index to include in calculations. | 0 |
-finish <pixel> | Specifies the ending across-track pixel index to include in calculations. | 1024 |
<rawfile> | Required. The input JCU GLORIA file. | Β |
<eqfile> | Required. The output JCU GLORIA file with histogram equalization applied. | Β |
How It Works
The tool operates in two primary modes: static equalization or rolling average normalization.
Static Equalization (Default, if -roll is not used):
- Calculate Average Profile:
- It iterates through the specified ping range (
-firstto-last) and pixel range (-startto-finish). - For each across-track pixel position
j, it calculatessum_data[j](sum of pixel values) andcount[j](number of valid pixels). sum_data[j]is then divided bycount[j]to get the average intensity profile across the swath.- An overall
averageintensity across the entire swath is also computed. This can be overridden by-normalize.
- It iterates through the specified ping range (
- Apply Equalization:
- It then re-reads the input file record by record.
- For each valid pixel
in_rec.stbd_data[j]:newvalue = (float)in_rec.stbd_data[j] - sum_data[j];(removes the average profile)newvalue = average + newvalue * Scale;(adds back the overall average, scaled).
- The
newvalueis clamped between 1.0 and 255.0. - The modified pixel is written to the output record.
Rolling Average Normalization (if -roll is used):
- Sectioning and Rolling Averages:
- The input file is divided into sections of
roll_sizepings. - For each section, it calculates
roll_sum_data[section][j](sum of pixels at positionjwithin the section) androll_avg[section](overall average intensity for the section).
- The input file is divided into sections of
- Interpolated Averages:
- When processing each ping
ifor output, it interpolates theinterp_avgandinterp_sum_datafrom theroll_avgandroll_sum_dataof the surrounding sections. This creates a dynamically changing reference profile.
- When processing each ping
- Apply Normalization:
- For each valid pixel
in_rec.stbd_data[j]:newvalue = (float)in_rec.stbd_data[j] - interp_sum_data;(removes the local average profile)newvalue = interp_avg + newvalue * Scale;(adds back the interpolated overall average, scaled).
- The
newvalueis clamped between 1.0 and 255.0. - The modified pixel is written to the output record.
- For each valid pixel