-
Notifications
You must be signed in to change notification settings - Fork 0
Box Counting Comparison Stepwise
"The difference between healthy and diseased tissue is often a difference in complexity."
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.
Why Compare Fractal Dimensions?
- Objective Metrics: Replace subjective "looks more irregular" with numerical values
- Longitudinal Studies: Track disease progression over months/years
- Treatment Efficacy: Measure quantitative response to therapy
- Population Studies: Compare cohorts (age groups, disease stages)
- 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 Image Compare module implements a rigorous, reproducible pipeline ensuring fair comparison:
Three Loading Methods:
- Drag-and-Drop: Intuitive file drop onto left/right pane
- File Browser: Standard open dialog with preview
- 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)
Purpose: Reduce image noise while preserving structural features
Algorithm: Gaussian convolution with kernel size 5×5, σ = 2.0
Mathematical Formula:
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
Purpose: Convert grayscale to binary (foreground/background separation)
Method: Otsu's algorithm finds optimal threshold by maximizing inter-class variance
Mathematical Criterion:
where
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
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
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
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:
- Overlay grid of size
$\epsilon$ - Count boxes containing ≥1 foreground pixel →
$N(\epsilon)$ - Record
$(\log(1/\epsilon), \log N(\epsilon))$ coordinate - Repeat for all scales
Output: Two arrays of log-log coordinates
Linear Regression:
For each image, fit:
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
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:
- Side-by-side log-log plots with regression lines
- Overlay comparison showing both curves
- Difference histogram (spatial complexity variation)
- 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
Scenario: Distinguishing benign from malignant breast lesions on mammography
Method:
- Load two mammogram ROIs (one benign cyst, one invasive carcinoma)
- Run 8-step comparison workflow
- Analyze fractal dimensions of tumor boundaries
Results:
| Lesion Type | Fractal Dimension | R² | 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
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
Options:
- Reset Image A only
- Reset Image B only
- Reset Both (complete restart)
Preserves:
- Workflow step progress
- Previously calculated results (cached)
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
✅ 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
- Use matched imaging parameters: Same modality, resolution, contrast
- Anatomical alignment: Register images if comparing pre/post scans
- Adequate ROI size: ≥256×256 pixels recommended
- Multiple measurements: Average across multiple ROIs for robustness
- Blinded analysis: Operator shouldn't know which is "diseased"
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
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
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
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
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)
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
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
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
- 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.
- 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.
- 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 →