Reads 3D image data from single/multi-directory TIFFs or file sequences. Performs parallel, chunked reading directly into AMReX iMultiFab.
More...
|
| int | bitsPerSample () const |
| | Get bits per sample (e.g., 8, 16, 32). Requires metadata to be read.
|
| amrex::Box | box () const |
| | Returns the index space Box covering the entire image domain [0, w-1]x[0, h-1]x[0, d-1].
|
| int | depth () const |
| | Get depth (Z-dimension) in pixels/voxels. Requires metadata to be read.
|
| uint16_t | getFillOrder () const |
| | Get TIFF FillOrder tag value (e.g., 1=MSB->LSB, 2=LSB->MSB). Requires metadata to be read.
|
| int | height () const |
| | Get height (Y-dimension) in pixels/voxels. Requires metadata to be read.
|
| bool | isRead () const |
| | Check if metadata has been successfully read and broadcast.
|
| TiffReader & | operator= (const TiffReader &)=delete |
| TiffReader & | operator= (TiffReader &&)=default |
| bool | readFile (const std::string &filename) |
| | Reads metadata from a single (potentially multi-directory) TIFF file.
|
| bool | readFileSequence (const std::string &base_pattern, int num_files, int start_index=0, int digits=1, const std::string &suffix=".tif") |
| | Reads metadata from the first file of a TIFF sequence.
|
| int | sampleFormat () const |
| | Get sample format (e.g., SAMPLEFORMAT_UINT, SAMPLEFORMAT_INT, SAMPLEFORMAT_IEEEFP from tiff.h). Requires metadata to be read.
|
| int | samplesPerPixel () const |
| | Get samples per pixel (e.g., 1 for grayscale, 3 for RGB). Requires metadata to be read.
|
| void | threshold (double raw_threshold, amrex::iMultiFab &mf) const |
| | Reads data chunk-by-chunk into an iMultiFab based on thresholding (output 1/0).
|
| void | threshold (double raw_threshold, int value_if_true, int value_if_false, amrex::iMultiFab &mf) const |
| | Reads data chunk-by-chunk into an iMultiFab based on thresholding with custom output values.
|
| | TiffReader () |
| | Default constructor. Creates an empty reader. Use readFile() or readFileSequence().
|
| | TiffReader (const std::string &base_pattern, int num_files, int start_index=0, int digits=1, const std::string &suffix=".tif") |
| | Constructs a TiffReader, reads metadata from the first file of a sequence.
|
| | TiffReader (const std::string &filename) |
| | Constructs a TiffReader, reads metadata from a single (potentially multi-directory) TIFF file.
|
| | TiffReader (const TiffReader &)=delete |
| | TiffReader (TiffReader &&)=default |
| int | width () const |
| | Get width (X-dimension) in pixels/voxels. Requires metadata to be read.
|
| virtual | ~TiffReader ()=default |
| | Virtual default destructor.
|
Reads 3D image data from single/multi-directory TIFFs or file sequences. Performs parallel, chunked reading directly into AMReX iMultiFab.
This class uses libtiff to read TIFF files (single stack files or sequences representing Z-slices). It is designed for parallel environments (MPI+OpenMP) and large datasets that may exceed single-node memory.
Metadata (dimensions, data type) is read first by rank 0 and broadcast. Data reading is performed by the threshold methods, driven by the distribution of the target iMultiFab. Each MPI rank reads only the necessary strips or tiles for its owned boxes directly from the file(s). Supports Striped and Tiled TIFF formats.
- Warning
- Assumes serial libtiff calls internally. While reading is distributed across ranks via MFIter, concurrent libtiff calls from different threads within a rank to the SAME file handle might require a thread-safe libtiff build or external locking (current implementation uses per-thread handles for sequences, avoiding this issue there).
-
Assumes PLANARCONFIG_CONTIG. Multi-sample data is read, but only the first sample is used during thresholding.
-
Copy operations disabled.
| bool OpenImpala::TiffReader::readFile |
( |
const std::string & | filename | ) |
|
Reads metadata from a single (potentially multi-directory) TIFF file.
Clears existing metadata. Rank 0 opens file, reads dimensions/type, validates, determines depth, and broadcasts info to all ranks. Does NOT read pixel data.
- Parameters
-
| filename | Path to the TIFF file. |
- Returns
- true on success (metadata broadcast), false otherwise. Aborts on critical errors.
| bool OpenImpala::TiffReader::readFileSequence |
( |
const std::string & | base_pattern, |
|
|
int | num_files, |
|
|
int | start_index = 0, |
|
|
int | digits = 1, |
|
|
const std::string & | suffix = ".tif" ) |
Reads metadata from the first file of a TIFF sequence.
Clears existing metadata. Rank 0 opens first file, reads dimensions/type, validates, sets depth from num_files, and broadcasts info (including sequence params) to all ranks. Does NOT read pixel data.
- Parameters
-
| base_pattern | Base filename pattern (e.g., "path/slice_"). |
| num_files | Total number of files in the sequence (determines Z dimension). |
| start_index | The starting number for the sequence (e.g., 0 or 1). |
| digits | The number of digits used for the sequence number padding (e.g., 4 for "0001"). |
| suffix | File extension including dot (e.g., ".tif"). |
- Returns
- true on success (metadata broadcast), false otherwise. Aborts on critical errors.