Application Scenarios
- Image Texture Analysis: Quantify image roughness and complexity
- Medical Image Analysis: Analyze tissue structure complexity
- Materials Science: Study fractal features of material surfaces
- Computer Vision: Image feature extraction and classification
- Geology: Terrain and landform complexity analysis
Usage Examples
Basic Usage
GPU Accelerated Version
Batch Processing
Restrict Fit Range
Class Description
CFAImageFD
Description: Calculates 2D image fractal dimensions using Box-Counting (BC), Differential Box-Counting (DBC), and Shifted DBC (SDBC).
Initialization Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
image | numpy.ndarray | Required | Input 2D single-channel array |
max_size | int | None | Maximum box size (default: min image dimension) |
max_scales | int | 30 | Target number of distinct scales |
with_progress | bool | True | Show progress bar |
min_size | int | 2 | Minimum box size |
get_bc_fd(corp_type=-1, fit_range=None)
Box-Counting on binary image. Any positive pixel = occupied.
corp_type: -1 crop (default), 0 strict, 1 pad
fit_range: Optional (min_scale, max_scale) to restrict regression to power-law regime
Returns dict: fd, scales, counts, log_scales, log_counts, intercept, r_value, p_value, std_err
get_dbc_fd(corp_type=-1, fit_range=None)
Differential Box-Counting (Sarkar & Chaudhuri 1994). Formula: n_r = ceil(I_max/h) - ceil(I_min/h) + 1 where h = s × H / G_max. For grayscale images.
get_sdbc_fd(corp_type=-1, fit_range=None)
Shifted DBC (Chen et al. 1995). Formula: n_r = floor((I_max - I_min)/h) + 1. Avoids boundary-crossing overcount of plain DBC.
get_fd(scale_list, box_count_list)
Utility: log-log linear regression on custom scale/count data. Returns same dict as get_bc_fd.
plot(raw_img, gray_img, bin_img, fd_bc, fd_dbc, fd_sdbc) [static]
2×3 subplot visualization: raw image, gray image, binary image, BC fit, DBC fit, SDBC fit.
get_batch_bc / get_batch_dbc / get_batch_sdbc [static]
Batch processing. Scale generation is shared across images. Parameters: images, max_size, max_scales, min_size, corp_type, fit_range, with_progress. Returns list of dicts.
Algorithm Description
BC Method
DBC Method
SDBC Method
Scale Generation
Geometrically spaced in [min_size, max_size]. Generates floats, rounds, deduplicates, and sorts — ensuring the requested count of distinct integer scales.
Log-Log Regression
Scales with N=0 are dropped (not replaced with epsilon). Use fit_range to restrict to the power-law regime.
Important Notes
- Image Preprocessing: BC requires binary image; DBC/SDBC accept grayscale directly
- Scale Selection:
max_scales=30is good default; usefit_rangeto exclude unreliable extremes - Result Interpretation: Dimension typically 1–2 for 2D images;
r_valueclose to ±1 means good power-law fit - Performance: Use
CFAImageFDGPUfor large images or batch; setwith_progress=Falseto suppress tqdm
References
- Mandelbrot, B. B. (1982). The Fractal Geometry of Nature. Freeman.
- Sarkar, N., & Chaudhuri, B. B. (1994). IEEE Transactions on Systems, Man, and Cybernetics.
- Chen, W. S., et al. (1995). Pattern Recognition.