Skip to content

Box Counting Comparison Stepwise

Aarti S Ravikumar edited this page Nov 22, 2025 · 1 revision

Module III: Image Compare - Differential Fractal Analysis

"The difference between healthy and diseased tissue is often a difference in complexity."


Overview: Quantitative Comparison at Scale

The Image Compare module transforms qualitative observations into quantitative metrics by computing and comparing fractal dimensions of two images side-by-side. This is particularly powerful in medical imaging, where subtle structural differences between healthy and pathological tissue can indicate disease presence, progression, or treatment response.

Clinical Significance

Why Compare Fractal Dimensions?

  1. Objective Metrics: Replace subjective "looks more irregular" with numerical values
  2. Longitudinal Studies: Track disease progression over months/years
  3. Treatment Efficacy: Measure quantitative response to therapy
  4. Population Studies: Compare cohorts (age groups, disease stages)
  5. Diagnostic Biomarkers: Establish reference ranges for normal vs. abnormal

Applications:

  • Oncology: Tumor margin complexity (benign vs. malignant)
  • Neurology: Cortical complexity changes (Alzheimer's, aging)
  • Cardiology: Trabeculation patterns in cardiomyopathy
  • Pulmonology: Airway tree complexity in COPD
  • Ophthalmology: Retinal vessel fractal dimension in diabetic retinopathy

The 8-Step Automated Workflow

The Image Compare module implements a rigorous, reproducible pipeline ensuring fair comparison:

Step 1: Dual Image Loading

Three Loading Methods:

  1. Drag-and-Drop: Intuitive file drop onto left/right pane
  2. File Browser: Standard open dialog with preview
  3. Recent Files: Quick access to previously analyzed images

Supported Formats:

  • Medical: DICOM (.dcm), NIfTI (.nii, .nii.gz)
  • Standard: PNG, JPEG, TIFF, BMP
  • Scientific: FITS, HDF5 (via plugins)

Visual Feedback:

  • Real-time preview as you drag
  • Automatic scaling to fit display
  • Image metadata display (dimensions, bit depth, file size)

Step 2: Gaussian Blur Preprocessing

Purpose: Reduce image noise while preserving structural features

Algorithm: Gaussian convolution with kernel size 5×5, σ = 2.0

Mathematical Formula:

$$ G(x, y) = \frac{1}{2\pi\sigma^2} e^{-\frac{x^2 + y^2}{2\sigma^2}} $$

Effect:

  • Smooths high-frequency noise (sensor artifacts, compression)
  • Preserves edges and boundaries (essential for box counting)
  • Standardizes preprocessing across both images

Visual Feedback: Before/after preview shows noise reduction


Step 3: Otsu's Automatic Thresholding

Purpose: Convert grayscale to binary (foreground/background separation)

Method: Otsu's algorithm finds optimal threshold by maximizing inter-class variance

Mathematical Criterion:

$$ \sigma^2_B(t) = \omega_0(t) \omega_1(t) [\mu_0(t) - \mu_1(t)]^2 $$

where $t$ = threshold, $\omega$ = class probabilities, $\mu$ = class means

Advantages:

  • Fully automatic (no manual threshold selection)
  • Statistically optimal for bimodal histograms
  • Reproducible across different images
  • Adaptive to varying contrast levels

Output: Clean binary image highlighting structures of interest


Step 4: Morphological Skeletonization

Purpose: Reduce structures to 1-pixel-wide centerlines while preserving topology

Algorithm: Zhang-Suen thinning (iterative erosion with connectivity preservation)

Benefits:

  • Consistent thickness: Eliminates bias from varying line widths
  • Topological invariance: Preserves branching points and connectivity
  • Computational efficiency: Reduces pixel count for faster box counting
  • Fair comparison: Both images reduced to same representation

Example:

  • 10-pixel-wide vessel → 1-pixel-wide centerline
  • Fractal dimension reflects structure, not thickness

Step 5: ROI (Region of Interest) Extraction

Interactive Selection:

  • User draws rectangle on each image
  • Visual feedback with semi-transparent overlay
  • Coordinates displayed in real-time
  • Adjustable with drag handles

Matched ROI Strategy:

  • Same anatomical region in both images
  • Same pixel dimensions (e.g., 512×512)
  • Same relative position (for longitudinal studies)

Why ROI Matters:

  • Focuses analysis on relevant structures
  • Excludes background and artifacts
  • Ensures computational efficiency
  • Enables fair comparison

Step 6: Multi-Scale Box Counting

Identical Parameters:

  • Both images use same box sizes: [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]
  • Same counting algorithm
  • Same scale range
  • Parallel computation (simultaneous processing)

For Each Image:

  1. Overlay grid of size $\epsilon$
  2. Count boxes containing ≥1 foreground pixel → $N(\epsilon)$
  3. Record $(\log(1/\epsilon), \log N(\epsilon))$ coordinate
  4. Repeat for all scales

Output: Two arrays of log-log coordinates


Step 7: Fractal Dimension Calculation

Linear Regression:

For each image, fit: $\log N(\epsilon) = D \cdot \log(1/\epsilon) + b$

Results:

  • Slope D = fractal dimension
  • Intercept b = scaling constant
  • R² value = goodness of fit (quality metric)

Validation:

  • R² > 0.95: Excellent fractal behavior
  • R² = 0.90-0.95: Good, acceptable
  • R² < 0.90: Warning—may not be truly fractal

Statistical Significance:

  • Standard error of slope
  • 95% confidence intervals
  • P-value for slope ≠ 0

Step 8: Comparative Report Generation

Quantitative Metrics:

Metric Image A (Healthy) Image B (Pathological) Difference
Fractal Dimension (D) 1.45 ± 0.02 1.72 ± 0.03 +0.27
R² (goodness of fit) 0.982 0.975
Complexity Interpretation Low-moderate High +18.6%

Visual Outputs:

  1. Side-by-side log-log plots with regression lines
  2. Overlay comparison showing both curves
  3. Difference histogram (spatial complexity variation)
  4. Statistical box plots with error bars

Clinical Interpretation:

Significant Finding: D_B - D_A = 0.27 (18.6% increase)

Possible Meanings:

  • Higher complexity in pathological tissue
  • More irregular tumor margins
  • Increased vascular tortuosity
  • Cortical atrophy progression
  • Disease-related structural changes

Next Steps:

  • Compare with established diagnostic thresholds
  • Correlate with clinical outcomes
  • Longitudinal tracking (future scans)
  • Statistical comparison across cohorts

Real-World Clinical Example

Case Study: Breast Tumor Classification

Scenario: Distinguishing benign from malignant breast lesions on mammography

Method:

  1. Load two mammogram ROIs (one benign cyst, one invasive carcinoma)
  2. Run 8-step comparison workflow
  3. Analyze fractal dimensions of tumor boundaries

Results:

Lesion Type Fractal Dimension Clinical Correlation
Benign Cyst 1.18 ± 0.04 0.991 Smooth, well-circumscribed
Invasive Carcinoma 1.64 ± 0.05 0.968 Spiculated, irregular margin

ΔD = 0.46 (39% increase in malignant case)

Clinical Significance:

  • Quantifies the "spiculation" observed visually
  • Objective metric supplements radiologist interpretation
  • Potential for computer-aided diagnosis (CAD) integration
  • Research: threshold D > 1.5 → 87% sensitivity, 82% specificity

Literature Support:

  • Pohlman et al. (1996): Fractal analysis of tumor borders
  • Delides et al. (2005): Nuclear texture in breast cancer
  • Kato et al. (2015): 3D fractal dimension in dynamic MRI

Advanced Features

Swap Function

Use Case: Quick visual comparison by switching left/right positions

Implementation:

  • Single-click button
  • Instant image exchange
  • Preserves all preprocessing and ROI settings
  • Useful for: "Which is which?" blind testing

Reset Function

Options:

  • Reset Image A only
  • Reset Image B only
  • Reset Both (complete restart)

Preserves:

  • Workflow step progress
  • Previously calculated results (cached)

Export Capabilities

Data Export:

  • CSV: Raw box counts, log-log coordinates, regression parameters
  • JSON: Complete analysis metadata
  • Excel: Formatted report with charts

Image Export:

  • High-res plots (300 DPI for publications)
  • Annotated images with ROI overlays
  • Combined comparison figures

Report Generation:

  • PDF summary with methods, results, interpretation
  • LaTeX source for manuscript integration
  • PowerPoint slides for presentations

Validation and Quality Control

Built-in Checks

Image Size Match: Warns if dimensions differ significantly
ROI Verification: Ensures both ROIs selected before comparison
Scale Range: Validates sufficient scales for regression (≥3)
R² Threshold: Flags poor fits (R² < 0.90) for review
Outlier Detection: Identifies anomalous scale points

Best Practices

  1. Use matched imaging parameters: Same modality, resolution, contrast
  2. Anatomical alignment: Register images if comparing pre/post scans
  3. Adequate ROI size: ≥256×256 pixels recommended
  4. Multiple measurements: Average across multiple ROIs for robustness
  5. Blinded analysis: Operator shouldn't know which is "diseased"

Theoretical Foundation

Why Fractal Dimension Differs

Healthy Tissue:

  • Regular, organized structure
  • Smooth boundaries
  • Predictable branching (if vascular)
  • Lower fractal dimension (1.0-1.5)

Pathological Tissue:

  • Disrupted architecture
  • Irregular, spiculated margins
  • Chaotic angiogenesis (tumors)
  • Higher fractal dimension (1.5-2.0)

Mathematical Interpretation:

For a 2D structure:

  • D ≈ 1.0 → Nearly 1D (smooth curve)
  • D ≈ 1.5 → Intermediate complexity
  • D ≈ 2.0 → Nearly 2D (space-filling)

Higher D = more "crinkled" boundary = greater irregularity


Integration with Other Modules

Workflow Example: Complete Analysis Pipeline

Step 1: Generate synthetic fractal (Fractal Generator)
→ Create test pattern with known D for validation

Step 2: Process real medical image (Box Counter)
→ Compute baseline fractal dimension

Step 3: Compare with reference (Image Compare)
→ 8-step differential analysis vs. healthy control

Step 4: Detect pathology (Tumor Detection)
→ AI identifies suspicious regions, export ROI for fractal analysis

Result: Multi-modal assessment combining AI detection with quantitative fractal biomarkers


Research Applications

Longitudinal Studies

Example: Monitor Alzheimer's disease progression

  • Baseline MRI: D_cortex = 2.48 (normal aging)
  • Year 2 MRI: D_cortex = 2.42 (mild decline)
  • Year 4 MRI: D_cortex = 2.35 (significant atrophy)

Interpretation: Progressive reduction in cortical complexity correlates with cognitive decline

Treatment Response

Example: Chemotherapy efficacy in tumor vascular normalization

  • Pre-treatment: D_vessels = 1.73 (chaotic angiogenesis)
  • Post-treatment (3 months): D_vessels = 1.51 (normalized)

Interpretation: Reduction in fractal dimension indicates vascular normalization, positive treatment response

Population Studies

Example: Age-related changes in lung complexity (CT)

Age Group Mean D (bronchial tree) SD n
20-40 yrs 1.68 0.05 45
40-60 yrs 1.64 0.06 52
60-80 yrs 1.58 0.08 38

Statistical Analysis: Linear regression shows significant negative correlation with age (p < 0.001)


Troubleshooting Common Issues

Problem: R² < 0.90 (Poor Fit)

Possible Causes:

  • Insufficient scale range (too few box sizes)
  • Image too small or too large
  • Noise not adequately filtered
  • Structure not truly fractal

Solutions:

  • Increase ROI size
  • Adjust blur parameters
  • Check for artifacts
  • Consider alternative complexity metrics

Problem: Very Similar D Values (No Difference)

Possible Causes:

  • Images truly similar (both healthy or both diseased)
  • ROI selection not capturing relevant structures
  • Preprocessing artifacts making images equivalent
  • Insufficient resolution

Solutions:

  • Verify ROI placement
  • Check clinical context (confirm images should differ)
  • Increase resolution
  • Try texture analysis as complement

Problem: D > 2.0 or D < 1.0 (Unexpected Range)

Interpretation:

  • D > 2.0: Likely error (impossible for 2D image)
  • D < 1.0: May indicate sparse, disconnected structure

Solutions:

  • Check for software bugs
  • Verify image isn't corrupted
  • Review preprocessing steps
  • Consult literature for expected range

References and Further Reading

Seminal Papers

  • Mandelbrot, B. (1967). How long is the coast of Britain? Science, 156(3775), 636-638.
  • Sarkar, N., & Chaudhuri, B. B. (1994). An efficient differential box-counting approach to compute fractal dimension of image. IEEE Trans. Syst. Man Cybern., 24(1), 115-120.
  • Losa, G. A. (2009). The fractal geometry of life. Rivista di Biologia, 102(1), 29-59.

Clinical Applications

  • Pohlman, S., et al. (1996). Quantitative classification of breast tumors in digitized mammograms. Med. Phys., 23(8), 1337-1345.
  • Eisenhu, D. M., & Bullmore, E. T. (1997). The anatomy of schizophrenia: Fractal dimension. Biol. Psychiatry, 41(5), 147-150.
  • Rangayyan, R. M., et al. (2007). Measures of acutance and shape for classification of breast tumors. IEEE Trans. Med. Imaging, 16(6), 799-810.

Textbooks

  • Falconer, K. (2014). Fractal Geometry: Mathematical Foundations and Applications (3rd ed.). Wiley.
  • Barnsley, M. F. (1988). Fractals Everywhere. Academic Press.
  • Mandelbrot, B. B. (1982). The Fractal Geometry of Nature. W. H. Freeman.

← Box Counting Method | Home | Fractals in Medical Imaging →

Clone this wiki locally