filterAerial
Description
filterAerial is a utility designed to process multiple 8-bit aerial image files (presumably representing intensity or depth data, potentially from Optech systems) and compute an average image. This average image can then be used to remove low-frequency noise, such as solar radiation effects, from individual aerial photographs.
The tool reads multiple input 8-bit image files, sums their pixel values, and then divides by the number of input files to get an average for each pixel.
Usage
filterAerial -out <outfile> <8bitfile(s)>
Arguments
| Option | Description |
|---|---|
-out <outfile> | Required. The path for the output averaged 8-bit image file. |
<8bitfile(s)> | Required. One or more paths to input 8-bit image files. All input files are assumed to have identical dimensions and JHC headers. |
How It Works
- Initialization: Initializes variables and an array
sum_matrix(1201x1601) to accumulate pixel sums. - Output File Creation: Creates the specified output file (
-out) for writing the averaged image. - Header Processing:
- Opens the first input 8-bit image file to read its JHC header (
head_in). - Copies
head_intohead_out(which will be the header for the output file). - Verifies that
head_in.data_typeis 1 (indicating an 8-bit file). - Allocates memory for
fout(output row buffer) andfsum(row sum buffer, thoughsum_matrixis used for 2D sums). - Writes
head_outto theoutfile.
- Opens the first input 8-bit image file to read its JHC header (
- Input File Iteration (Accumulate Pixel Sums): Loops through each input 8-bit image file:
- Opens the current input file.
- Reads its JHC header (
head_in) (ensuring consistency in case headers differ subtly between inputs, though dimensions are assumed identical). - Allocates memory for
fin(input row buffer). - Iterates through each row (
i) and column (j) of the image:- Reads a row of pixel data into
fin. - Adds the value of each pixel
*(fin + j)tosum_matrix[i][j].
- Reads a row of pixel data into
- Closes the current input file.
- Average Pixel Values and Write Output:
- Seeks to the data section of the
outfile(after the JHC header). - Iterates through each row (
i) and column (j) of the image:- Calculates the average pixel value
(unsigned char)(sum_matrix[i][j] / noin). - Writes this averaged pixel value to
fout. - After processing a row, writes
fouttooutfile.
- Calculates the average pixel value
- Seeks to the data section of the
- Cleanup: Closes the output file.
Output Files
<outfile>: An 8-bit JHC-format image file containing the averaged pixel values.
Dependencies
array.h: ForJHC_headerstructure.support.h: For general utility functions and error handling.
Notes
This technique is useful for removing systematic, low-frequency noise (such as uneven illumination) that is consistent across multiple images of the same area. The resulting average image can then be subtracted from individual images to produce a cleaner, destriped output. The tool assumes all input images have identical dimensions.