nx_self_similarity.nx
buildroot/runtime/nx_self_similarity.nx
about
nx_self_similarity.nx -- box-counting fractal dimension primitive.
Cross-modal aesthetic kernel. Box-counting estimates the fractal
dimension D of an edge-image; for natural images D is empirically
in [1.0, 2.0] where:
D = 1.0 pure line (low fractal complexity)
D ~ 1.4 Spehar-2003 peak aesthetic preference
D = 2.0 filled plane (maximally complex)
Mandelbrot 1967, Falconer "Fractal Geometry" 1990, Spehar et al.
2003 "Universal aesthetic of fractals." Generalizes from images
to any 2D signal: spectrograms, attention heatmaps, terrain.
Output: Q10 of (D - 1), so 0 = line, 1024 = filled plane. Plus an
aesthetic_q10 derived from Spehar-fit Gaussian-shaped peak at
D~1.4 (Q10 dim ~410).
Why Q10 of (D - 1) instead of Q10 of D directly: 1.0 < D < 2.0 in
every realistic case, so the [1, 2] range maps cleanly to [0, Q10]
without wasting integer bits encoding the always-present 1.
genealogy_id: mandelbrot_1967_fractal + falconer_1990_geometry +
spehar_2003_universal_aesthetic_fractals
lineage_id: box_counting_fractal_dim_q10
dependencies 3 imports · 2 importers
imports: nx_syscalls.nxnx_tier.nxnx_image.nx
imported by: nx_image_feature_extract.nxnx_self_similarity_test.nx
structs
| 36 | struct SelfSimilarityReport |
consts
| none |
functions
| 53 | func _log2_q10(n: nx_int) -> nx_int called by 1: nx_self_similarity_compute |
| 76 | func _edge_mask_alloc(gray: *Image) -> *i64 |
| 126 | func _box_count(mask: *i64, w: nx_int, h: nx_int, s: nx_int) -> nx_int called by 1: nx_self_similarity_compute |
| 156 | func _edge_density_q10(mask: *i64, w: nx_int, h: nx_int) -> nx_int called by 1: nx_self_similarity_compute |
| 175 | func nx_self_similarity_compute(gray: *Image, report: *SelfSimilarityReport) -> nx_int called by 2: nx_image_feature_extractmain calls 4: _edge_mask_alloc_edge_density_q10_box_count_log2_q10 |
| 248 | func nx_self_similarity_in_peak_band(report: *SelfSimilarityReport) -> nx_int called by 1: main |