glfill
Description
glfill is a utility designed to fill in invalid data (typically pixels with a value of 255) or anomalously low-level data within JCU GLORIA format files. This is particularly useful for data types like EM-12 multibeam, where data dropouts or weak returns can create gaps or stripes. The tool employs interpolation techniques based on neighboring pixels and optionally utilizes a running average of intensities to identify and correct low-level data.
Usage
glfill [-invalid <value>] [-replace] [-lower_level <value>] [-throwout] [-level_below_average <value>] <rawfile> <fillfile>
Arguments
| Option | Description | Default |
|---|---|---|
-invalid <value> | Specifies the pixel value that represents invalid data. | 255 |
-replace | If specified, when filling a pixel, it will be replaced by the value of the pixel from the previous record (one record back) at the same across-track position. Otherwise, it uses a two-record average. | (None) |
-lower_level <value> | Specifies a pixel intensity threshold. Pixels below this level are also considered invalid and candidates for filling, especially when -throwout is used. | 0 |
-throwout | If specified, all pixels below -lower_level are immediately set to invalid (255) before the main filling process. | (None) |
-level_below_average <value> | If specified, this value is used to dynamically calculate lower_level based on a running average of ping intensities. Pixels below average - level_below_average are considered invalid. | 0 |
<rawfile> | Required. The input JCU GLORIA file containing raw data to be filled. | Β |
<fillfile> | Required. The output JCU GLORIA file with invalid data filled. | Β |
How It Works
- Load Image Data: The entire input GLORIA file (
rawfile) is loaded into memory as a 2D array (image) ofunsigned char, representing the pixel intensities for each record. - Initial Low-Level Data Handling (
-throwout,-level_below_average):- If
-throwoutis used, any pixel in the loadedimagethat is below the initiallower_level(or 0 if not specified) is immediately set toinvalid(255). - If
-level_below_averageis used, the tool calculates a running average (average) of valid pixel intensities for each ping. Then, a 10-point filtered average (filtav) is computed. Thelower_levelis then dynamically set tofiltav[i] - level_below_averagefor each pingi.
- If
- Filling Logic (Main Loop): The tool then iterates through the
imagearray (excluding the first and last two records for boundary conditions):- It looks for βinvalidβ pixels, defined as either the
-invalidvalue or values below the dynamically updatedlower_level(if-level_below_averageis active). - A pixel
(i, j)is considered for filling ifimage[i][j],image[i][j+1], andimage[i][j+2]are all βinvalidβ (this seems like a specific pattern detection for stripes). - Interpolation Rules:
- Vertical Interpolation: If the pixel above (
i-1, j) and below (i+1, j) are both valid, and-replaceis not used, the current pixel(i, j)is replaced by the average ofimage[i-1][j]andimage[i+1][j]. - Replacement (
-replace): If-replaceis used, the pixel is replaced by the value ofimage[i-1][j]. - Extended Vertical Interpolation: If direct neighbors are not both valid, it tries to use pixels two records away (
i-1, jandi+2, j) or (i+1, jandi-2, j), applying a weighted average.
- Vertical Interpolation: If the pixel above (
- It looks for βinvalidβ pixels, defined as either the
- Write Output File: After processing and filling, the modified
imagedata is copied back intogloria_recstructures and written to thefillfile.