This repository estimates porosity REV (Representative Elementary Volume) from a segmented 3D image using random cube sampling.
The script supports:
.rawvolumes (with dimensions frominput.txt).tif/.tiff3D stacks (dimensions read from file)
- Python 3.9+ recommended.
- Install dependencies:
- pip:
pip install numpy matplotlib seaborn tifffile imageio- conda:
conda create -n pororev python=3.10 -y
conda activate pororev
conda install -c conda-forge numpy matplotlib seaborn tifffile imageio -yPoroREV.py: main scriptinput.txt: user-editable configuration file
- Default config file:
python3 PoroREV.py- Custom config file path:
python3 PoroREV.py --config input.txt1) Phase labels
pore: pore label value in the segmented imagesolid: solid label value in the segmented image
Important behavior:
- The current code maps voxels equal to
solidto0(solid). - All other voxel values are mapped to
1(pore). poreandsolidmust be different values.
2) Input file
filename: input image path (.raw,.tif,.tiff)- Relative paths are resolved relative to the config file location.
3) RAW file settings (used only for .raw)
filesize_x,filesize_y,filesize_z: raw dimensions in voxelsdtype: raw voxel type (examples:uint8,uint16,int16,float32)
Note:
- For
.tif/.tiff, raw size fields anddtypeare ignored.
4) REV sampling settings
min_side: smallest sampled cube side length (voxel)step: cube side increment between samplessamples: random cubes per side lengthseed: random seed for reproducibility
5) Output settings
save_fig: output figure path (.png,.pdf, etc.)save_csv: output table path
6) Optional REV detection by CI
rev_ci_threshold(optional): CI half-width thresholdrev_consecutive: required consecutive side lengths below threshold
If rev_ci_threshold is commented out or missing, automatic REV-size detection is skipped.
1. Figure (save_fig):
- Mean porosity vs. cube size
- Shaded 95% confidence interval
2. CSV (save_csv) with columns:
cube_size_voxelmean_porositystd_porosityci95_halfwidthcv