dogpack 0.0.0-stage → 0.1.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1029) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +313 -2
  3. package/dist/bundle/index.cjs +14129 -0
  4. package/dist/bundle/index.cjs.map +1 -0
  5. package/dist/bundle/index.d.ts +4320 -0
  6. package/dist/bundle/index.mjs +14108 -0
  7. package/dist/bundle/index.mjs.map +1 -0
  8. package/dist/bundle/index.umd.js +14135 -0
  9. package/dist/bundle/index.umd.js.map +1 -0
  10. package/dist/bundle/index.umd.min.js +2 -0
  11. package/dist/bundle/index.umd.min.js.map +1 -0
  12. package/dist/cjs/base.d.ts +74 -0
  13. package/dist/cjs/base.d.ts.map +1 -0
  14. package/dist/cjs/base.js +223 -0
  15. package/dist/cjs/base.js.map +1 -0
  16. package/dist/cjs/blur/edge-aware-blur.d.ts +10 -0
  17. package/dist/cjs/blur/edge-aware-blur.d.ts.map +1 -0
  18. package/dist/cjs/blur/edge-aware-blur.js +18 -0
  19. package/dist/cjs/blur/edge-aware-blur.js.map +1 -0
  20. package/dist/cjs/blur/flow-guided.d.ts +180 -0
  21. package/dist/cjs/blur/flow-guided.d.ts.map +1 -0
  22. package/dist/cjs/blur/flow-guided.js +703 -0
  23. package/dist/cjs/blur/flow-guided.js.map +1 -0
  24. package/dist/cjs/blur/gradient-aligned/cpu.d.ts +24 -0
  25. package/dist/cjs/blur/gradient-aligned/cpu.d.ts.map +1 -0
  26. package/dist/cjs/blur/gradient-aligned/cpu.js +94 -0
  27. package/dist/cjs/blur/gradient-aligned/cpu.js.map +1 -0
  28. package/dist/cjs/blur/gradient-aligned/index.d.ts +24 -0
  29. package/dist/cjs/blur/gradient-aligned/index.d.ts.map +1 -0
  30. package/dist/cjs/blur/gradient-aligned/index.js +96 -0
  31. package/dist/cjs/blur/gradient-aligned/index.js.map +1 -0
  32. package/dist/cjs/blur/gradient-aligned/webgl.d.ts +39 -0
  33. package/dist/cjs/blur/gradient-aligned/webgl.d.ts.map +1 -0
  34. package/dist/cjs/blur/gradient-aligned/webgl.js +239 -0
  35. package/dist/cjs/blur/gradient-aligned/webgl.js.map +1 -0
  36. package/dist/cjs/blur/gradient-aligned/webgpu.d.ts +79 -0
  37. package/dist/cjs/blur/gradient-aligned/webgpu.d.ts.map +1 -0
  38. package/dist/cjs/blur/gradient-aligned/webgpu.js +320 -0
  39. package/dist/cjs/blur/gradient-aligned/webgpu.js.map +1 -0
  40. package/dist/cjs/blur/index.d.ts +6 -0
  41. package/dist/cjs/blur/index.d.ts.map +1 -0
  42. package/dist/cjs/blur/index.js +15 -0
  43. package/dist/cjs/blur/index.js.map +1 -0
  44. package/dist/cjs/blur/isotropic.d.ts +29 -0
  45. package/dist/cjs/blur/isotropic.d.ts.map +1 -0
  46. package/dist/cjs/blur/isotropic.js +43 -0
  47. package/dist/cjs/blur/isotropic.js.map +1 -0
  48. package/dist/cjs/blur/shaders/flow-guided/webgl2-flow-blur.glsl.d.ts +3 -0
  49. package/dist/cjs/blur/shaders/flow-guided/webgl2-flow-blur.glsl.d.ts.map +1 -0
  50. package/dist/cjs/blur/shaders/flow-guided/webgl2-flow-blur.glsl.js +64 -0
  51. package/dist/cjs/blur/shaders/flow-guided/webgl2-flow-blur.glsl.js.map +1 -0
  52. package/dist/cjs/blur/shaders/flow-guided/webgl2-vertex.glsl.d.ts +3 -0
  53. package/dist/cjs/blur/shaders/flow-guided/webgl2-vertex.glsl.d.ts.map +1 -0
  54. package/dist/cjs/blur/shaders/flow-guided/webgl2-vertex.glsl.js +17 -0
  55. package/dist/cjs/blur/shaders/flow-guided/webgl2-vertex.glsl.js.map +1 -0
  56. package/dist/cjs/blur/shaders/flow-guided/webgpu-flow-blur.wgsl.d.ts +3 -0
  57. package/dist/cjs/blur/shaders/flow-guided/webgpu-flow-blur.wgsl.d.ts.map +1 -0
  58. package/dist/cjs/blur/shaders/flow-guided/webgpu-flow-blur.wgsl.js +111 -0
  59. package/dist/cjs/blur/shaders/flow-guided/webgpu-flow-blur.wgsl.js.map +1 -0
  60. package/dist/cjs/blur/shaders/gradient-aligned/vertex.glsl.d.ts +3 -0
  61. package/dist/cjs/blur/shaders/gradient-aligned/vertex.glsl.d.ts.map +1 -0
  62. package/dist/cjs/blur/shaders/gradient-aligned/vertex.glsl.js +12 -0
  63. package/dist/cjs/blur/shaders/gradient-aligned/vertex.glsl.js.map +1 -0
  64. package/dist/cjs/blur/shaders/gradient-aligned/webgl2-fragment.glsl.d.ts +3 -0
  65. package/dist/cjs/blur/shaders/gradient-aligned/webgl2-fragment.glsl.d.ts.map +1 -0
  66. package/dist/cjs/blur/shaders/gradient-aligned/webgl2-fragment.glsl.js +90 -0
  67. package/dist/cjs/blur/shaders/gradient-aligned/webgl2-fragment.glsl.js.map +1 -0
  68. package/dist/cjs/blur/shaders/gradient-aligned/webgpu-fragment.wgsl.d.ts +3 -0
  69. package/dist/cjs/blur/shaders/gradient-aligned/webgpu-fragment.wgsl.d.ts.map +1 -0
  70. package/dist/cjs/blur/shaders/gradient-aligned/webgpu-fragment.wgsl.js +99 -0
  71. package/dist/cjs/blur/shaders/gradient-aligned/webgpu-fragment.wgsl.js.map +1 -0
  72. package/dist/cjs/blur/shaders/isotropic/webgl-horizontal-blur.glsl.d.ts +3 -0
  73. package/dist/cjs/blur/shaders/isotropic/webgl-horizontal-blur.glsl.d.ts.map +1 -0
  74. package/dist/cjs/blur/shaders/isotropic/webgl-horizontal-blur.glsl.js +36 -0
  75. package/dist/cjs/blur/shaders/isotropic/webgl-horizontal-blur.glsl.js.map +1 -0
  76. package/dist/cjs/blur/shaders/isotropic/webgl-vertical-blur.glsl.d.ts +3 -0
  77. package/dist/cjs/blur/shaders/isotropic/webgl-vertical-blur.glsl.d.ts.map +1 -0
  78. package/dist/cjs/blur/shaders/isotropic/webgl-vertical-blur.glsl.js +36 -0
  79. package/dist/cjs/blur/shaders/isotropic/webgl-vertical-blur.glsl.js.map +1 -0
  80. package/dist/cjs/blur/shaders/isotropic/webgpu-horizontal-blur.wgsl.d.ts +3 -0
  81. package/dist/cjs/blur/shaders/isotropic/webgpu-horizontal-blur.wgsl.d.ts.map +1 -0
  82. package/dist/cjs/blur/shaders/isotropic/webgpu-horizontal-blur.wgsl.js +47 -0
  83. package/dist/cjs/blur/shaders/isotropic/webgpu-horizontal-blur.wgsl.js.map +1 -0
  84. package/dist/cjs/blur/shaders/isotropic/webgpu-vertical-blur.wgsl.d.ts +3 -0
  85. package/dist/cjs/blur/shaders/isotropic/webgpu-vertical-blur.wgsl.d.ts.map +1 -0
  86. package/dist/cjs/blur/shaders/isotropic/webgpu-vertical-blur.wgsl.js +47 -0
  87. package/dist/cjs/blur/shaders/isotropic/webgpu-vertical-blur.wgsl.js.map +1 -0
  88. package/dist/cjs/dog/adog.d.ts +80 -0
  89. package/dist/cjs/dog/adog.d.ts.map +1 -0
  90. package/dist/cjs/dog/adog.js +217 -0
  91. package/dist/cjs/dog/adog.js.map +1 -0
  92. package/dist/cjs/dog/fdog.d.ts +93 -0
  93. package/dist/cjs/dog/fdog.d.ts.map +1 -0
  94. package/dist/cjs/dog/fdog.js +230 -0
  95. package/dist/cjs/dog/fdog.js.map +1 -0
  96. package/dist/cjs/dog/hdog.d.ts +39 -0
  97. package/dist/cjs/dog/hdog.d.ts.map +1 -0
  98. package/dist/cjs/dog/hdog.js +126 -0
  99. package/dist/cjs/dog/hdog.js.map +1 -0
  100. package/dist/cjs/dog/index.d.ts +7 -0
  101. package/dist/cjs/dog/index.d.ts.map +1 -0
  102. package/dist/cjs/dog/index.js +32 -0
  103. package/dist/cjs/dog/index.js.map +1 -0
  104. package/dist/cjs/dog/xdog.d.ts +70 -0
  105. package/dist/cjs/dog/xdog.d.ts.map +1 -0
  106. package/dist/cjs/dog/xdog.js +152 -0
  107. package/dist/cjs/dog/xdog.js.map +1 -0
  108. package/dist/cjs/etf/cpu.d.ts +35 -0
  109. package/dist/cjs/etf/cpu.d.ts.map +1 -0
  110. package/dist/cjs/etf/cpu.js +334 -0
  111. package/dist/cjs/etf/cpu.js.map +1 -0
  112. package/dist/cjs/etf/flow-field.d.ts +29 -0
  113. package/dist/cjs/etf/flow-field.d.ts.map +1 -0
  114. package/dist/cjs/etf/flow-field.js +149 -0
  115. package/dist/cjs/etf/flow-field.js.map +1 -0
  116. package/dist/cjs/etf/index.d.ts +31 -0
  117. package/dist/cjs/etf/index.d.ts.map +1 -0
  118. package/dist/cjs/etf/index.js +99 -0
  119. package/dist/cjs/etf/index.js.map +1 -0
  120. package/dist/cjs/etf/shaders/webgl/finalize_magnitude.glsl.d.ts +3 -0
  121. package/dist/cjs/etf/shaders/webgl/finalize_magnitude.glsl.d.ts.map +1 -0
  122. package/dist/cjs/etf/shaders/webgl/finalize_magnitude.glsl.js +20 -0
  123. package/dist/cjs/etf/shaders/webgl/finalize_magnitude.glsl.js.map +1 -0
  124. package/dist/cjs/etf/shaders/webgl/gaussian_blur_h.glsl.d.ts +3 -0
  125. package/dist/cjs/etf/shaders/webgl/gaussian_blur_h.glsl.d.ts.map +1 -0
  126. package/dist/cjs/etf/shaders/webgl/gaussian_blur_h.glsl.js +31 -0
  127. package/dist/cjs/etf/shaders/webgl/gaussian_blur_h.glsl.js.map +1 -0
  128. package/dist/cjs/etf/shaders/webgl/gaussian_blur_v.glsl.d.ts +3 -0
  129. package/dist/cjs/etf/shaders/webgl/gaussian_blur_v.glsl.d.ts.map +1 -0
  130. package/dist/cjs/etf/shaders/webgl/gaussian_blur_v.glsl.js +31 -0
  131. package/dist/cjs/etf/shaders/webgl/gaussian_blur_v.glsl.js.map +1 -0
  132. package/dist/cjs/etf/shaders/webgl/gradient.glsl.d.ts +3 -0
  133. package/dist/cjs/etf/shaders/webgl/gradient.glsl.d.ts.map +1 -0
  134. package/dist/cjs/etf/shaders/webgl/gradient.glsl.js +36 -0
  135. package/dist/cjs/etf/shaders/webgl/gradient.glsl.js.map +1 -0
  136. package/dist/cjs/etf/shaders/webgl/structural_tensor.glsl.d.ts +3 -0
  137. package/dist/cjs/etf/shaders/webgl/structural_tensor.glsl.d.ts.map +1 -0
  138. package/dist/cjs/etf/shaders/webgl/structural_tensor.glsl.js +40 -0
  139. package/dist/cjs/etf/shaders/webgl/structural_tensor.glsl.js.map +1 -0
  140. package/dist/cjs/etf/shaders/webgl/tangent_extract.glsl.d.ts +3 -0
  141. package/dist/cjs/etf/shaders/webgl/tangent_extract.glsl.d.ts.map +1 -0
  142. package/dist/cjs/etf/shaders/webgl/tangent_extract.glsl.js +52 -0
  143. package/dist/cjs/etf/shaders/webgl/tangent_extract.glsl.js.map +1 -0
  144. package/dist/cjs/etf/shaders/webgl/tangent_refine.glsl.d.ts +3 -0
  145. package/dist/cjs/etf/shaders/webgl/tangent_refine.glsl.d.ts.map +1 -0
  146. package/dist/cjs/etf/shaders/webgl/tangent_refine.glsl.js +63 -0
  147. package/dist/cjs/etf/shaders/webgl/tangent_refine.glsl.js.map +1 -0
  148. package/dist/cjs/etf/shaders/webgl/vertex.glsl.d.ts +3 -0
  149. package/dist/cjs/etf/shaders/webgl/vertex.glsl.d.ts.map +1 -0
  150. package/dist/cjs/etf/shaders/webgl/vertex.glsl.js +16 -0
  151. package/dist/cjs/etf/shaders/webgl/vertex.glsl.js.map +1 -0
  152. package/dist/cjs/etf/shaders/webgpu/common.wgsl.d.ts +3 -0
  153. package/dist/cjs/etf/shaders/webgpu/common.wgsl.d.ts.map +1 -0
  154. package/dist/cjs/etf/shaders/webgpu/common.wgsl.js +25 -0
  155. package/dist/cjs/etf/shaders/webgpu/common.wgsl.js.map +1 -0
  156. package/dist/cjs/etf/shaders/webgpu/gaussian_blur.wgsl.d.ts +3 -0
  157. package/dist/cjs/etf/shaders/webgpu/gaussian_blur.wgsl.d.ts.map +1 -0
  158. package/dist/cjs/etf/shaders/webgpu/gaussian_blur.wgsl.js +51 -0
  159. package/dist/cjs/etf/shaders/webgpu/gaussian_blur.wgsl.js.map +1 -0
  160. package/dist/cjs/etf/shaders/webgpu/gaussian_blur_tiled.wgsl.d.ts +3 -0
  161. package/dist/cjs/etf/shaders/webgpu/gaussian_blur_tiled.wgsl.d.ts.map +1 -0
  162. package/dist/cjs/etf/shaders/webgpu/gaussian_blur_tiled.wgsl.js +113 -0
  163. package/dist/cjs/etf/shaders/webgpu/gaussian_blur_tiled.wgsl.js.map +1 -0
  164. package/dist/cjs/etf/shaders/webgpu/gradient_structure_tensor.wgsl.d.ts +3 -0
  165. package/dist/cjs/etf/shaders/webgpu/gradient_structure_tensor.wgsl.d.ts.map +1 -0
  166. package/dist/cjs/etf/shaders/webgpu/gradient_structure_tensor.wgsl.js +64 -0
  167. package/dist/cjs/etf/shaders/webgpu/gradient_structure_tensor.wgsl.js.map +1 -0
  168. package/dist/cjs/etf/shaders/webgpu/tangent_extract.wgsl.d.ts +3 -0
  169. package/dist/cjs/etf/shaders/webgpu/tangent_extract.wgsl.d.ts.map +1 -0
  170. package/dist/cjs/etf/shaders/webgpu/tangent_extract.wgsl.js +60 -0
  171. package/dist/cjs/etf/shaders/webgpu/tangent_extract.wgsl.js.map +1 -0
  172. package/dist/cjs/etf/shaders/webgpu/tangent_refine.wgsl.d.ts +3 -0
  173. package/dist/cjs/etf/shaders/webgpu/tangent_refine.wgsl.d.ts.map +1 -0
  174. package/dist/cjs/etf/shaders/webgpu/tangent_refine.wgsl.js +88 -0
  175. package/dist/cjs/etf/shaders/webgpu/tangent_refine.wgsl.js.map +1 -0
  176. package/dist/cjs/etf/webgl.d.ts +46 -0
  177. package/dist/cjs/etf/webgl.d.ts.map +1 -0
  178. package/dist/cjs/etf/webgl.js +350 -0
  179. package/dist/cjs/etf/webgl.js.map +1 -0
  180. package/dist/cjs/etf/webgpu.d.ts +139 -0
  181. package/dist/cjs/etf/webgpu.d.ts.map +1 -0
  182. package/dist/cjs/etf/webgpu.js +725 -0
  183. package/dist/cjs/etf/webgpu.js.map +1 -0
  184. package/dist/cjs/extensions/anti-alias.d.ts +55 -0
  185. package/dist/cjs/extensions/anti-alias.d.ts.map +1 -0
  186. package/dist/cjs/extensions/anti-alias.js +56 -0
  187. package/dist/cjs/extensions/anti-alias.js.map +1 -0
  188. package/dist/cjs/extensions/base.d.ts +33 -0
  189. package/dist/cjs/extensions/base.d.ts.map +1 -0
  190. package/dist/cjs/extensions/base.js +3 -0
  191. package/dist/cjs/extensions/base.js.map +1 -0
  192. package/dist/cjs/extensions/color-retention.d.ts +467 -0
  193. package/dist/cjs/extensions/color-retention.d.ts.map +1 -0
  194. package/dist/cjs/extensions/color-retention.js +795 -0
  195. package/dist/cjs/extensions/color-retention.js.map +1 -0
  196. package/dist/cjs/extensions/hatching.d.ts +111 -0
  197. package/dist/cjs/extensions/hatching.d.ts.map +1 -0
  198. package/dist/cjs/extensions/hatching.js +262 -0
  199. package/dist/cjs/extensions/hatching.js.map +1 -0
  200. package/dist/cjs/extensions/index.d.ts +33 -0
  201. package/dist/cjs/extensions/index.d.ts.map +1 -0
  202. package/dist/cjs/extensions/index.js +36 -0
  203. package/dist/cjs/extensions/index.js.map +1 -0
  204. package/dist/cjs/extensions/multi-scale.d.ts +301 -0
  205. package/dist/cjs/extensions/multi-scale.d.ts.map +1 -0
  206. package/dist/cjs/extensions/multi-scale.js +480 -0
  207. package/dist/cjs/extensions/multi-scale.js.map +1 -0
  208. package/dist/cjs/extensions/natural-media.d.ts +72 -0
  209. package/dist/cjs/extensions/natural-media.d.ts.map +1 -0
  210. package/dist/cjs/extensions/natural-media.js +136 -0
  211. package/dist/cjs/extensions/natural-media.js.map +1 -0
  212. package/dist/cjs/extensions/pipeline.d.ts +45 -0
  213. package/dist/cjs/extensions/pipeline.d.ts.map +1 -0
  214. package/dist/cjs/extensions/pipeline.js +53 -0
  215. package/dist/cjs/extensions/pipeline.js.map +1 -0
  216. package/dist/cjs/extensions/utils.d.ts +19 -0
  217. package/dist/cjs/extensions/utils.d.ts.map +1 -0
  218. package/dist/cjs/extensions/utils.js +69 -0
  219. package/dist/cjs/extensions/utils.js.map +1 -0
  220. package/dist/cjs/filters/cpu.d.ts +173 -0
  221. package/dist/cjs/filters/cpu.d.ts.map +1 -0
  222. package/dist/cjs/filters/cpu.js +463 -0
  223. package/dist/cjs/filters/cpu.js.map +1 -0
  224. package/dist/cjs/filters/filters.d.ts +114 -0
  225. package/dist/cjs/filters/filters.d.ts.map +1 -0
  226. package/dist/cjs/filters/filters.js +242 -0
  227. package/dist/cjs/filters/filters.js.map +1 -0
  228. package/dist/cjs/filters/index.d.ts +7 -0
  229. package/dist/cjs/filters/index.d.ts.map +1 -0
  230. package/dist/cjs/filters/index.js +23 -0
  231. package/dist/cjs/filters/index.js.map +1 -0
  232. package/dist/cjs/filters/isotropic/cpu.d.ts +21 -0
  233. package/dist/cjs/filters/isotropic/cpu.d.ts.map +1 -0
  234. package/dist/cjs/filters/isotropic/cpu.js +81 -0
  235. package/dist/cjs/filters/isotropic/cpu.js.map +1 -0
  236. package/dist/cjs/filters/isotropic/index.d.ts +4 -0
  237. package/dist/cjs/filters/isotropic/index.d.ts.map +1 -0
  238. package/dist/cjs/filters/isotropic/index.js +10 -0
  239. package/dist/cjs/filters/isotropic/index.js.map +1 -0
  240. package/dist/cjs/filters/isotropic/shaders/guassian-horizontal.glsl.d.ts +3 -0
  241. package/dist/cjs/filters/isotropic/shaders/guassian-horizontal.glsl.d.ts.map +1 -0
  242. package/dist/cjs/filters/isotropic/shaders/guassian-horizontal.glsl.js +34 -0
  243. package/dist/cjs/filters/isotropic/shaders/guassian-horizontal.glsl.js.map +1 -0
  244. package/dist/cjs/filters/isotropic/shaders/guassian-vertical.glsl.d.ts +3 -0
  245. package/dist/cjs/filters/isotropic/shaders/guassian-vertical.glsl.d.ts.map +1 -0
  246. package/dist/cjs/filters/isotropic/shaders/guassian-vertical.glsl.js +34 -0
  247. package/dist/cjs/filters/isotropic/shaders/guassian-vertical.glsl.js.map +1 -0
  248. package/dist/cjs/filters/isotropic/shaders/webgpu-horizontal-blur.wgsl.d.ts +3 -0
  249. package/dist/cjs/filters/isotropic/shaders/webgpu-horizontal-blur.wgsl.d.ts.map +1 -0
  250. package/dist/cjs/filters/isotropic/shaders/webgpu-horizontal-blur.wgsl.js +47 -0
  251. package/dist/cjs/filters/isotropic/shaders/webgpu-horizontal-blur.wgsl.js.map +1 -0
  252. package/dist/cjs/filters/isotropic/shaders/webgpu-vertical-blur.wgsl.d.ts +3 -0
  253. package/dist/cjs/filters/isotropic/shaders/webgpu-vertical-blur.wgsl.d.ts.map +1 -0
  254. package/dist/cjs/filters/isotropic/shaders/webgpu-vertical-blur.wgsl.js +47 -0
  255. package/dist/cjs/filters/isotropic/shaders/webgpu-vertical-blur.wgsl.js.map +1 -0
  256. package/dist/cjs/filters/isotropic/webgl.d.ts +22 -0
  257. package/dist/cjs/filters/isotropic/webgl.d.ts.map +1 -0
  258. package/dist/cjs/filters/isotropic/webgl.js +350 -0
  259. package/dist/cjs/filters/isotropic/webgl.js.map +1 -0
  260. package/dist/cjs/filters/isotropic/webgpu.d.ts +39 -0
  261. package/dist/cjs/filters/isotropic/webgpu.d.ts.map +1 -0
  262. package/dist/cjs/filters/isotropic/webgpu.js +183 -0
  263. package/dist/cjs/filters/isotropic/webgpu.js.map +1 -0
  264. package/dist/cjs/filters/multi-channel/bilateral/cpu.d.ts +17 -0
  265. package/dist/cjs/filters/multi-channel/bilateral/cpu.d.ts.map +1 -0
  266. package/dist/cjs/filters/multi-channel/bilateral/cpu.js +79 -0
  267. package/dist/cjs/filters/multi-channel/bilateral/cpu.js.map +1 -0
  268. package/dist/cjs/filters/multi-channel/bilateral/index.d.ts +18 -0
  269. package/dist/cjs/filters/multi-channel/bilateral/index.d.ts.map +1 -0
  270. package/dist/cjs/filters/multi-channel/bilateral/index.js +31 -0
  271. package/dist/cjs/filters/multi-channel/bilateral/index.js.map +1 -0
  272. package/dist/cjs/filters/multi-channel/bilateral/shared.d.ts +54 -0
  273. package/dist/cjs/filters/multi-channel/bilateral/shared.d.ts.map +1 -0
  274. package/dist/cjs/filters/multi-channel/bilateral/shared.js +55 -0
  275. package/dist/cjs/filters/multi-channel/bilateral/shared.js.map +1 -0
  276. package/dist/cjs/filters/multi-channel/bilateral/webgl.d.ts +16 -0
  277. package/dist/cjs/filters/multi-channel/bilateral/webgl.d.ts.map +1 -0
  278. package/dist/cjs/filters/multi-channel/bilateral/webgl.js +180 -0
  279. package/dist/cjs/filters/multi-channel/bilateral/webgl.js.map +1 -0
  280. package/dist/cjs/filters/multi-channel/bilateral/webgpu.d.ts +24 -0
  281. package/dist/cjs/filters/multi-channel/bilateral/webgpu.d.ts.map +1 -0
  282. package/dist/cjs/filters/multi-channel/bilateral/webgpu.js +128 -0
  283. package/dist/cjs/filters/multi-channel/bilateral/webgpu.js.map +1 -0
  284. package/dist/cjs/filters/multi-channel/index.d.ts +7 -0
  285. package/dist/cjs/filters/multi-channel/index.d.ts.map +1 -0
  286. package/dist/cjs/filters/multi-channel/index.js +10 -0
  287. package/dist/cjs/filters/multi-channel/index.js.map +1 -0
  288. package/dist/cjs/filters/multi-channel/kuwahara/cpu.d.ts +17 -0
  289. package/dist/cjs/filters/multi-channel/kuwahara/cpu.d.ts.map +1 -0
  290. package/dist/cjs/filters/multi-channel/kuwahara/cpu.js +110 -0
  291. package/dist/cjs/filters/multi-channel/kuwahara/cpu.js.map +1 -0
  292. package/dist/cjs/filters/multi-channel/kuwahara/index.d.ts +18 -0
  293. package/dist/cjs/filters/multi-channel/kuwahara/index.d.ts.map +1 -0
  294. package/dist/cjs/filters/multi-channel/kuwahara/index.js +31 -0
  295. package/dist/cjs/filters/multi-channel/kuwahara/index.js.map +1 -0
  296. package/dist/cjs/filters/multi-channel/kuwahara/shared.d.ts +47 -0
  297. package/dist/cjs/filters/multi-channel/kuwahara/shared.d.ts.map +1 -0
  298. package/dist/cjs/filters/multi-channel/kuwahara/shared.js +89 -0
  299. package/dist/cjs/filters/multi-channel/kuwahara/shared.js.map +1 -0
  300. package/dist/cjs/filters/multi-channel/kuwahara/webgl.d.ts +16 -0
  301. package/dist/cjs/filters/multi-channel/kuwahara/webgl.d.ts.map +1 -0
  302. package/dist/cjs/filters/multi-channel/kuwahara/webgl.js +178 -0
  303. package/dist/cjs/filters/multi-channel/kuwahara/webgl.js.map +1 -0
  304. package/dist/cjs/filters/multi-channel/kuwahara/webgpu.d.ts +24 -0
  305. package/dist/cjs/filters/multi-channel/kuwahara/webgpu.d.ts.map +1 -0
  306. package/dist/cjs/filters/multi-channel/kuwahara/webgpu.js +123 -0
  307. package/dist/cjs/filters/multi-channel/kuwahara/webgpu.js.map +1 -0
  308. package/dist/cjs/filters/multi-channel/median/cpu.d.ts +17 -0
  309. package/dist/cjs/filters/multi-channel/median/cpu.d.ts.map +1 -0
  310. package/dist/cjs/filters/multi-channel/median/cpu.js +93 -0
  311. package/dist/cjs/filters/multi-channel/median/cpu.js.map +1 -0
  312. package/dist/cjs/filters/multi-channel/median/index.d.ts +18 -0
  313. package/dist/cjs/filters/multi-channel/median/index.d.ts.map +1 -0
  314. package/dist/cjs/filters/multi-channel/median/index.js +31 -0
  315. package/dist/cjs/filters/multi-channel/median/index.js.map +1 -0
  316. package/dist/cjs/filters/multi-channel/median/shared.d.ts +34 -0
  317. package/dist/cjs/filters/multi-channel/median/shared.d.ts.map +1 -0
  318. package/dist/cjs/filters/multi-channel/median/shared.js +35 -0
  319. package/dist/cjs/filters/multi-channel/median/shared.js.map +1 -0
  320. package/dist/cjs/filters/multi-channel/median/webgl.d.ts +16 -0
  321. package/dist/cjs/filters/multi-channel/median/webgl.d.ts.map +1 -0
  322. package/dist/cjs/filters/multi-channel/median/webgl.js +177 -0
  323. package/dist/cjs/filters/multi-channel/median/webgl.js.map +1 -0
  324. package/dist/cjs/filters/multi-channel/median/webgpu.d.ts +24 -0
  325. package/dist/cjs/filters/multi-channel/median/webgpu.d.ts.map +1 -0
  326. package/dist/cjs/filters/multi-channel/median/webgpu.js +122 -0
  327. package/dist/cjs/filters/multi-channel/median/webgpu.js.map +1 -0
  328. package/dist/cjs/filters/multi-channel/multichannel.d.ts +35 -0
  329. package/dist/cjs/filters/multi-channel/multichannel.d.ts.map +1 -0
  330. package/dist/cjs/filters/multi-channel/multichannel.js +87 -0
  331. package/dist/cjs/filters/multi-channel/multichannel.js.map +1 -0
  332. package/dist/cjs/filters/multi-channel/shaders/bilateral.glsl.d.ts +3 -0
  333. package/dist/cjs/filters/multi-channel/shaders/bilateral.glsl.d.ts.map +1 -0
  334. package/dist/cjs/filters/multi-channel/shaders/bilateral.glsl.js +48 -0
  335. package/dist/cjs/filters/multi-channel/shaders/bilateral.glsl.js.map +1 -0
  336. package/dist/cjs/filters/multi-channel/shaders/bilateral.wgsl.d.ts +3 -0
  337. package/dist/cjs/filters/multi-channel/shaders/bilateral.wgsl.d.ts.map +1 -0
  338. package/dist/cjs/filters/multi-channel/shaders/bilateral.wgsl.js +59 -0
  339. package/dist/cjs/filters/multi-channel/shaders/bilateral.wgsl.js.map +1 -0
  340. package/dist/cjs/filters/multi-channel/shaders/kuwahara.glsl.d.ts +3 -0
  341. package/dist/cjs/filters/multi-channel/shaders/kuwahara.glsl.d.ts.map +1 -0
  342. package/dist/cjs/filters/multi-channel/shaders/kuwahara.glsl.js +53 -0
  343. package/dist/cjs/filters/multi-channel/shaders/kuwahara.glsl.js.map +1 -0
  344. package/dist/cjs/filters/multi-channel/shaders/kuwahara.wgsl.d.ts +3 -0
  345. package/dist/cjs/filters/multi-channel/shaders/kuwahara.wgsl.d.ts.map +1 -0
  346. package/dist/cjs/filters/multi-channel/shaders/kuwahara.wgsl.js +67 -0
  347. package/dist/cjs/filters/multi-channel/shaders/kuwahara.wgsl.js.map +1 -0
  348. package/dist/cjs/filters/multi-channel/shaders/median.glsl.d.ts +3 -0
  349. package/dist/cjs/filters/multi-channel/shaders/median.glsl.d.ts.map +1 -0
  350. package/dist/cjs/filters/multi-channel/shaders/median.glsl.js +96 -0
  351. package/dist/cjs/filters/multi-channel/shaders/median.glsl.js.map +1 -0
  352. package/dist/cjs/filters/multi-channel/shaders/median.wgsl.d.ts +3 -0
  353. package/dist/cjs/filters/multi-channel/shaders/median.wgsl.d.ts.map +1 -0
  354. package/dist/cjs/filters/multi-channel/shaders/median.wgsl.js +93 -0
  355. package/dist/cjs/filters/multi-channel/shaders/median.wgsl.js.map +1 -0
  356. package/dist/cjs/filters/resilient-filter.d.ts +31 -0
  357. package/dist/cjs/filters/resilient-filter.d.ts.map +1 -0
  358. package/dist/cjs/filters/resilient-filter.js +84 -0
  359. package/dist/cjs/filters/resilient-filter.js.map +1 -0
  360. package/dist/cjs/filters/shaders/webgl/bilateral.glsl.d.ts +3 -0
  361. package/dist/cjs/filters/shaders/webgl/bilateral.glsl.d.ts.map +1 -0
  362. package/dist/cjs/filters/shaders/webgl/bilateral.glsl.js +48 -0
  363. package/dist/cjs/filters/shaders/webgl/bilateral.glsl.js.map +1 -0
  364. package/dist/cjs/filters/shaders/webgl/contrast.glsl.d.ts +3 -0
  365. package/dist/cjs/filters/shaders/webgl/contrast.glsl.d.ts.map +1 -0
  366. package/dist/cjs/filters/shaders/webgl/contrast.glsl.js +28 -0
  367. package/dist/cjs/filters/shaders/webgl/contrast.glsl.js.map +1 -0
  368. package/dist/cjs/filters/shaders/webgl/guassian-horizontal.glsl.d.ts +3 -0
  369. package/dist/cjs/filters/shaders/webgl/guassian-horizontal.glsl.d.ts.map +1 -0
  370. package/dist/cjs/filters/shaders/webgl/guassian-horizontal.glsl.js +34 -0
  371. package/dist/cjs/filters/shaders/webgl/guassian-horizontal.glsl.js.map +1 -0
  372. package/dist/cjs/filters/shaders/webgl/guassian-vertical.glsl.d.ts +3 -0
  373. package/dist/cjs/filters/shaders/webgl/guassian-vertical.glsl.d.ts.map +1 -0
  374. package/dist/cjs/filters/shaders/webgl/guassian-vertical.glsl.js +34 -0
  375. package/dist/cjs/filters/shaders/webgl/guassian-vertical.glsl.js.map +1 -0
  376. package/dist/cjs/filters/shaders/webgl/kuwahara.glsl.d.ts +3 -0
  377. package/dist/cjs/filters/shaders/webgl/kuwahara.glsl.d.ts.map +1 -0
  378. package/dist/cjs/filters/shaders/webgl/kuwahara.glsl.js +59 -0
  379. package/dist/cjs/filters/shaders/webgl/kuwahara.glsl.js.map +1 -0
  380. package/dist/cjs/filters/shaders/webgl/median-small.glsl.d.ts +3 -0
  381. package/dist/cjs/filters/shaders/webgl/median-small.glsl.d.ts.map +1 -0
  382. package/dist/cjs/filters/shaders/webgl/median-small.glsl.js +52 -0
  383. package/dist/cjs/filters/shaders/webgl/median-small.glsl.js.map +1 -0
  384. package/dist/cjs/filters/shaders/webgl/median.glsl.d.ts +3 -0
  385. package/dist/cjs/filters/shaders/webgl/median.glsl.d.ts.map +1 -0
  386. package/dist/cjs/filters/shaders/webgl/median.glsl.js +59 -0
  387. package/dist/cjs/filters/shaders/webgl/median.glsl.js.map +1 -0
  388. package/dist/cjs/filters/shaders/webgl/quantize.glsl.d.ts +3 -0
  389. package/dist/cjs/filters/shaders/webgl/quantize.glsl.d.ts.map +1 -0
  390. package/dist/cjs/filters/shaders/webgl/quantize.glsl.js +23 -0
  391. package/dist/cjs/filters/shaders/webgl/quantize.glsl.js.map +1 -0
  392. package/dist/cjs/filters/shaders/webgpu/bilateral.wgsl.d.ts +3 -0
  393. package/dist/cjs/filters/shaders/webgpu/bilateral.wgsl.d.ts.map +1 -0
  394. package/dist/cjs/filters/shaders/webgpu/bilateral.wgsl.js +66 -0
  395. package/dist/cjs/filters/shaders/webgpu/bilateral.wgsl.js.map +1 -0
  396. package/dist/cjs/filters/shaders/webgpu/gaussian.wgsl.d.ts +3 -0
  397. package/dist/cjs/filters/shaders/webgpu/gaussian.wgsl.d.ts.map +1 -0
  398. package/dist/cjs/filters/shaders/webgpu/gaussian.wgsl.js +53 -0
  399. package/dist/cjs/filters/shaders/webgpu/gaussian.wgsl.js.map +1 -0
  400. package/dist/cjs/filters/shaders/webgpu/histogram.wgsl.d.ts +3 -0
  401. package/dist/cjs/filters/shaders/webgpu/histogram.wgsl.d.ts.map +1 -0
  402. package/dist/cjs/filters/shaders/webgpu/histogram.wgsl.js +32 -0
  403. package/dist/cjs/filters/shaders/webgpu/histogram.wgsl.js.map +1 -0
  404. package/dist/cjs/filters/shaders/webgpu/kuwahara.wgsl.d.ts +3 -0
  405. package/dist/cjs/filters/shaders/webgpu/kuwahara.wgsl.d.ts.map +1 -0
  406. package/dist/cjs/filters/shaders/webgpu/kuwahara.wgsl.js +69 -0
  407. package/dist/cjs/filters/shaders/webgpu/kuwahara.wgsl.js.map +1 -0
  408. package/dist/cjs/filters/shaders/webgpu/median.wgsl.d.ts +3 -0
  409. package/dist/cjs/filters/shaders/webgpu/median.wgsl.d.ts.map +1 -0
  410. package/dist/cjs/filters/shaders/webgpu/median.wgsl.js +70 -0
  411. package/dist/cjs/filters/shaders/webgpu/median.wgsl.js.map +1 -0
  412. package/dist/cjs/filters/shaders/webgpu/quantize.wgsl.d.ts +3 -0
  413. package/dist/cjs/filters/shaders/webgpu/quantize.wgsl.d.ts.map +1 -0
  414. package/dist/cjs/filters/shaders/webgpu/quantize.wgsl.js +31 -0
  415. package/dist/cjs/filters/shaders/webgpu/quantize.wgsl.js.map +1 -0
  416. package/dist/cjs/filters/shaders/webgpu/stretch.wgsl.d.ts +3 -0
  417. package/dist/cjs/filters/shaders/webgpu/stretch.wgsl.d.ts.map +1 -0
  418. package/dist/cjs/filters/shaders/webgpu/stretch.wgsl.js +32 -0
  419. package/dist/cjs/filters/shaders/webgpu/stretch.wgsl.js.map +1 -0
  420. package/dist/cjs/filters/webgl.d.ts +48 -0
  421. package/dist/cjs/filters/webgl.d.ts.map +1 -0
  422. package/dist/cjs/filters/webgl.js +613 -0
  423. package/dist/cjs/filters/webgl.js.map +1 -0
  424. package/dist/cjs/filters/webgpu.d.ts +85 -0
  425. package/dist/cjs/filters/webgpu.d.ts.map +1 -0
  426. package/dist/cjs/filters/webgpu.js +645 -0
  427. package/dist/cjs/filters/webgpu.js.map +1 -0
  428. package/dist/cjs/index.d.ts +100 -0
  429. package/dist/cjs/index.d.ts.map +1 -0
  430. package/dist/cjs/index.js +117 -0
  431. package/dist/cjs/index.js.map +1 -0
  432. package/dist/cjs/interfaces/base.d.ts +465 -0
  433. package/dist/cjs/interfaces/base.d.ts.map +1 -0
  434. package/dist/cjs/interfaces/base.js +57 -0
  435. package/dist/cjs/interfaces/base.js.map +1 -0
  436. package/dist/cjs/interfaces/dog.d.ts +632 -0
  437. package/dist/cjs/interfaces/dog.d.ts.map +1 -0
  438. package/dist/cjs/interfaces/dog.js +262 -0
  439. package/dist/cjs/interfaces/dog.js.map +1 -0
  440. package/dist/cjs/map/channel-map-ops.d.ts +19 -0
  441. package/dist/cjs/map/channel-map-ops.d.ts.map +1 -0
  442. package/dist/cjs/map/channel-map-ops.js +67 -0
  443. package/dist/cjs/map/channel-map-ops.js.map +1 -0
  444. package/dist/cjs/map/index.d.ts +40 -0
  445. package/dist/cjs/map/index.d.ts.map +1 -0
  446. package/dist/cjs/map/index.js +56 -0
  447. package/dist/cjs/map/index.js.map +1 -0
  448. package/dist/cjs/map/strategies.d.ts +127 -0
  449. package/dist/cjs/map/strategies.d.ts.map +1 -0
  450. package/dist/cjs/map/strategies.js +190 -0
  451. package/dist/cjs/map/strategies.js.map +1 -0
  452. package/dist/cjs/map/structure-tensor.d.ts +15 -0
  453. package/dist/cjs/map/structure-tensor.d.ts.map +1 -0
  454. package/dist/cjs/map/structure-tensor.js +80 -0
  455. package/dist/cjs/map/structure-tensor.js.map +1 -0
  456. package/dist/cjs/package.json +3 -0
  457. package/dist/cjs/preprocess/index.d.ts +3 -0
  458. package/dist/cjs/preprocess/index.d.ts.map +1 -0
  459. package/dist/cjs/preprocess/index.js +20 -0
  460. package/dist/cjs/preprocess/index.js.map +1 -0
  461. package/dist/cjs/preprocess/parameter-estimation/epsilon.d.ts +60 -0
  462. package/dist/cjs/preprocess/parameter-estimation/epsilon.d.ts.map +1 -0
  463. package/dist/cjs/preprocess/parameter-estimation/epsilon.js +75 -0
  464. package/dist/cjs/preprocess/parameter-estimation/epsilon.js.map +1 -0
  465. package/dist/cjs/preprocess/parameter-estimation/index.d.ts +4 -0
  466. package/dist/cjs/preprocess/parameter-estimation/index.d.ts.map +1 -0
  467. package/dist/cjs/preprocess/parameter-estimation/index.js +7 -0
  468. package/dist/cjs/preprocess/parameter-estimation/index.js.map +1 -0
  469. package/dist/cjs/preprocess/parameter-estimation/p.d.ts +45 -0
  470. package/dist/cjs/preprocess/parameter-estimation/p.d.ts.map +1 -0
  471. package/dist/cjs/preprocess/parameter-estimation/p.js +52 -0
  472. package/dist/cjs/preprocess/parameter-estimation/p.js.map +1 -0
  473. package/dist/cjs/preprocess/parameter-estimation/phi.d.ts +44 -0
  474. package/dist/cjs/preprocess/parameter-estimation/phi.d.ts.map +1 -0
  475. package/dist/cjs/preprocess/parameter-estimation/phi.js +51 -0
  476. package/dist/cjs/preprocess/parameter-estimation/phi.js.map +1 -0
  477. package/dist/cjs/preprocess/parameter-estimation/shared.d.ts +44 -0
  478. package/dist/cjs/preprocess/parameter-estimation/shared.d.ts.map +1 -0
  479. package/dist/cjs/preprocess/parameter-estimation/shared.js +175 -0
  480. package/dist/cjs/preprocess/parameter-estimation/shared.js.map +1 -0
  481. package/dist/cjs/preprocess/preprocessors/index.d.ts +153 -0
  482. package/dist/cjs/preprocess/preprocessors/index.d.ts.map +1 -0
  483. package/dist/cjs/preprocess/preprocessors/index.js +331 -0
  484. package/dist/cjs/preprocess/preprocessors/index.js.map +1 -0
  485. package/dist/cjs/processor.d.ts +150 -0
  486. package/dist/cjs/processor.d.ts.map +1 -0
  487. package/dist/cjs/processor.js +256 -0
  488. package/dist/cjs/processor.js.map +1 -0
  489. package/dist/cjs/shaders/vertex-shader.wgsl.d.ts +3 -0
  490. package/dist/cjs/shaders/vertex-shader.wgsl.d.ts.map +1 -0
  491. package/dist/cjs/shaders/vertex-shader.wgsl.js +20 -0
  492. package/dist/cjs/shaders/vertex-shader.wgsl.js.map +1 -0
  493. package/dist/cjs/threshold.d.ts +53 -0
  494. package/dist/cjs/threshold.d.ts.map +1 -0
  495. package/dist/cjs/threshold.js +130 -0
  496. package/dist/cjs/threshold.js.map +1 -0
  497. package/dist/cjs/utils/color.d.ts +77 -0
  498. package/dist/cjs/utils/color.d.ts.map +1 -0
  499. package/dist/cjs/utils/color.js +298 -0
  500. package/dist/cjs/utils/color.js.map +1 -0
  501. package/dist/cjs/utils/device.d.ts +3 -0
  502. package/dist/cjs/utils/device.d.ts.map +1 -0
  503. package/dist/cjs/utils/device.js +53 -0
  504. package/dist/cjs/utils/device.js.map +1 -0
  505. package/dist/cjs/utils/image.d.ts +67 -0
  506. package/dist/cjs/utils/image.d.ts.map +1 -0
  507. package/dist/cjs/utils/image.js +188 -0
  508. package/dist/cjs/utils/image.js.map +1 -0
  509. package/dist/cjs/utils/index.d.ts +13 -0
  510. package/dist/cjs/utils/index.d.ts.map +1 -0
  511. package/dist/cjs/utils/index.js +32 -0
  512. package/dist/cjs/utils/index.js.map +1 -0
  513. package/dist/cjs/utils/math.d.ts +29 -0
  514. package/dist/cjs/utils/math.d.ts.map +1 -0
  515. package/dist/cjs/utils/math.js +65 -0
  516. package/dist/cjs/utils/math.js.map +1 -0
  517. package/dist/cjs/utils/scalar-field.d.ts +67 -0
  518. package/dist/cjs/utils/scalar-field.d.ts.map +1 -0
  519. package/dist/cjs/utils/scalar-field.js +115 -0
  520. package/dist/cjs/utils/scalar-field.js.map +1 -0
  521. package/dist/esm/base.js +217 -0
  522. package/dist/esm/base.js.map +1 -0
  523. package/dist/esm/blur/edge-aware-blur.js +14 -0
  524. package/dist/esm/blur/edge-aware-blur.js.map +1 -0
  525. package/dist/esm/blur/flow-guided.js +696 -0
  526. package/dist/esm/blur/flow-guided.js.map +1 -0
  527. package/dist/esm/blur/gradient-aligned/cpu.js +90 -0
  528. package/dist/esm/blur/gradient-aligned/cpu.js.map +1 -0
  529. package/dist/esm/blur/gradient-aligned/index.js +92 -0
  530. package/dist/esm/blur/gradient-aligned/index.js.map +1 -0
  531. package/dist/esm/blur/gradient-aligned/webgl.js +235 -0
  532. package/dist/esm/blur/gradient-aligned/webgl.js.map +1 -0
  533. package/dist/esm/blur/gradient-aligned/webgpu.js +316 -0
  534. package/dist/esm/blur/gradient-aligned/webgpu.js.map +1 -0
  535. package/dist/esm/blur/index.js +5 -0
  536. package/dist/esm/blur/index.js.map +1 -0
  537. package/dist/esm/blur/isotropic.js +39 -0
  538. package/dist/esm/blur/isotropic.js.map +1 -0
  539. package/dist/esm/blur/shaders/flow-guided/webgl2-flow-blur.glsl.js +62 -0
  540. package/dist/esm/blur/shaders/flow-guided/webgl2-flow-blur.glsl.js.map +1 -0
  541. package/dist/esm/blur/shaders/flow-guided/webgl2-vertex.glsl.js +15 -0
  542. package/dist/esm/blur/shaders/flow-guided/webgl2-vertex.glsl.js.map +1 -0
  543. package/dist/esm/blur/shaders/flow-guided/webgpu-flow-blur.wgsl.js +109 -0
  544. package/dist/esm/blur/shaders/flow-guided/webgpu-flow-blur.wgsl.js.map +1 -0
  545. package/dist/esm/blur/shaders/gradient-aligned/vertex.glsl.js +10 -0
  546. package/dist/esm/blur/shaders/gradient-aligned/vertex.glsl.js.map +1 -0
  547. package/dist/esm/blur/shaders/gradient-aligned/webgl2-fragment.glsl.js +88 -0
  548. package/dist/esm/blur/shaders/gradient-aligned/webgl2-fragment.glsl.js.map +1 -0
  549. package/dist/esm/blur/shaders/gradient-aligned/webgpu-fragment.wgsl.js +97 -0
  550. package/dist/esm/blur/shaders/gradient-aligned/webgpu-fragment.wgsl.js.map +1 -0
  551. package/dist/esm/blur/shaders/isotropic/webgl-horizontal-blur.glsl.js +34 -0
  552. package/dist/esm/blur/shaders/isotropic/webgl-horizontal-blur.glsl.js.map +1 -0
  553. package/dist/esm/blur/shaders/isotropic/webgl-vertical-blur.glsl.js +34 -0
  554. package/dist/esm/blur/shaders/isotropic/webgl-vertical-blur.glsl.js.map +1 -0
  555. package/dist/esm/blur/shaders/isotropic/webgpu-horizontal-blur.wgsl.js +45 -0
  556. package/dist/esm/blur/shaders/isotropic/webgpu-horizontal-blur.wgsl.js.map +1 -0
  557. package/dist/esm/blur/shaders/isotropic/webgpu-vertical-blur.wgsl.js +45 -0
  558. package/dist/esm/blur/shaders/isotropic/webgpu-vertical-blur.wgsl.js.map +1 -0
  559. package/dist/esm/dog/adog.js +213 -0
  560. package/dist/esm/dog/adog.js.map +1 -0
  561. package/dist/esm/dog/fdog.js +224 -0
  562. package/dist/esm/dog/fdog.js.map +1 -0
  563. package/dist/esm/dog/hdog.js +122 -0
  564. package/dist/esm/dog/hdog.js.map +1 -0
  565. package/dist/esm/dog/index.js +6 -0
  566. package/dist/esm/dog/index.js.map +1 -0
  567. package/dist/esm/dog/xdog.js +148 -0
  568. package/dist/esm/dog/xdog.js.map +1 -0
  569. package/dist/esm/etf/cpu.js +330 -0
  570. package/dist/esm/etf/cpu.js.map +1 -0
  571. package/dist/esm/etf/flow-field.js +145 -0
  572. package/dist/esm/etf/flow-field.js.map +1 -0
  573. package/dist/esm/etf/index.js +95 -0
  574. package/dist/esm/etf/index.js.map +1 -0
  575. package/dist/esm/etf/shaders/webgl/finalize_magnitude.glsl.js +18 -0
  576. package/dist/esm/etf/shaders/webgl/finalize_magnitude.glsl.js.map +1 -0
  577. package/dist/esm/etf/shaders/webgl/gaussian_blur_h.glsl.js +29 -0
  578. package/dist/esm/etf/shaders/webgl/gaussian_blur_h.glsl.js.map +1 -0
  579. package/dist/esm/etf/shaders/webgl/gaussian_blur_v.glsl.js +29 -0
  580. package/dist/esm/etf/shaders/webgl/gaussian_blur_v.glsl.js.map +1 -0
  581. package/dist/esm/etf/shaders/webgl/gradient.glsl.js +34 -0
  582. package/dist/esm/etf/shaders/webgl/gradient.glsl.js.map +1 -0
  583. package/dist/esm/etf/shaders/webgl/structural_tensor.glsl.js +38 -0
  584. package/dist/esm/etf/shaders/webgl/structural_tensor.glsl.js.map +1 -0
  585. package/dist/esm/etf/shaders/webgl/tangent_extract.glsl.js +50 -0
  586. package/dist/esm/etf/shaders/webgl/tangent_extract.glsl.js.map +1 -0
  587. package/dist/esm/etf/shaders/webgl/tangent_refine.glsl.js +61 -0
  588. package/dist/esm/etf/shaders/webgl/tangent_refine.glsl.js.map +1 -0
  589. package/dist/esm/etf/shaders/webgl/vertex.glsl.js +14 -0
  590. package/dist/esm/etf/shaders/webgl/vertex.glsl.js.map +1 -0
  591. package/dist/esm/etf/shaders/webgpu/common.wgsl.js +23 -0
  592. package/dist/esm/etf/shaders/webgpu/common.wgsl.js.map +1 -0
  593. package/dist/esm/etf/shaders/webgpu/gaussian_blur.wgsl.js +49 -0
  594. package/dist/esm/etf/shaders/webgpu/gaussian_blur.wgsl.js.map +1 -0
  595. package/dist/esm/etf/shaders/webgpu/gaussian_blur_tiled.wgsl.js +111 -0
  596. package/dist/esm/etf/shaders/webgpu/gaussian_blur_tiled.wgsl.js.map +1 -0
  597. package/dist/esm/etf/shaders/webgpu/gradient_structure_tensor.wgsl.js +62 -0
  598. package/dist/esm/etf/shaders/webgpu/gradient_structure_tensor.wgsl.js.map +1 -0
  599. package/dist/esm/etf/shaders/webgpu/tangent_extract.wgsl.js +58 -0
  600. package/dist/esm/etf/shaders/webgpu/tangent_extract.wgsl.js.map +1 -0
  601. package/dist/esm/etf/shaders/webgpu/tangent_refine.wgsl.js +86 -0
  602. package/dist/esm/etf/shaders/webgpu/tangent_refine.wgsl.js.map +1 -0
  603. package/dist/esm/etf/webgl.js +346 -0
  604. package/dist/esm/etf/webgl.js.map +1 -0
  605. package/dist/esm/etf/webgpu.js +720 -0
  606. package/dist/esm/etf/webgpu.js.map +1 -0
  607. package/dist/esm/extensions/anti-alias.js +52 -0
  608. package/dist/esm/extensions/anti-alias.js.map +1 -0
  609. package/dist/esm/extensions/base.js +2 -0
  610. package/dist/esm/extensions/base.js.map +1 -0
  611. package/dist/esm/extensions/color-retention.js +790 -0
  612. package/dist/esm/extensions/color-retention.js.map +1 -0
  613. package/dist/esm/extensions/hatching.js +258 -0
  614. package/dist/esm/extensions/hatching.js.map +1 -0
  615. package/dist/esm/extensions/index.js +27 -0
  616. package/dist/esm/extensions/index.js.map +1 -0
  617. package/dist/esm/extensions/multi-scale.js +459 -0
  618. package/dist/esm/extensions/multi-scale.js.map +1 -0
  619. package/dist/esm/extensions/natural-media.js +132 -0
  620. package/dist/esm/extensions/natural-media.js.map +1 -0
  621. package/dist/esm/extensions/pipeline.js +49 -0
  622. package/dist/esm/extensions/pipeline.js.map +1 -0
  623. package/dist/esm/extensions/utils.js +63 -0
  624. package/dist/esm/extensions/utils.js.map +1 -0
  625. package/dist/esm/filters/cpu.js +453 -0
  626. package/dist/esm/filters/cpu.js.map +1 -0
  627. package/dist/esm/filters/filters.js +229 -0
  628. package/dist/esm/filters/filters.js.map +1 -0
  629. package/dist/esm/filters/index.js +6 -0
  630. package/dist/esm/filters/index.js.map +1 -0
  631. package/dist/esm/filters/isotropic/cpu.js +77 -0
  632. package/dist/esm/filters/isotropic/cpu.js.map +1 -0
  633. package/dist/esm/filters/isotropic/index.js +4 -0
  634. package/dist/esm/filters/isotropic/index.js.map +1 -0
  635. package/dist/esm/filters/isotropic/shaders/guassian-horizontal.glsl.js +32 -0
  636. package/dist/esm/filters/isotropic/shaders/guassian-horizontal.glsl.js.map +1 -0
  637. package/dist/esm/filters/isotropic/shaders/guassian-vertical.glsl.js +32 -0
  638. package/dist/esm/filters/isotropic/shaders/guassian-vertical.glsl.js.map +1 -0
  639. package/dist/esm/filters/isotropic/shaders/webgpu-horizontal-blur.wgsl.js +45 -0
  640. package/dist/esm/filters/isotropic/shaders/webgpu-horizontal-blur.wgsl.js.map +1 -0
  641. package/dist/esm/filters/isotropic/shaders/webgpu-vertical-blur.wgsl.js +45 -0
  642. package/dist/esm/filters/isotropic/shaders/webgpu-vertical-blur.wgsl.js.map +1 -0
  643. package/dist/esm/filters/isotropic/webgl.js +344 -0
  644. package/dist/esm/filters/isotropic/webgl.js.map +1 -0
  645. package/dist/esm/filters/isotropic/webgpu.js +179 -0
  646. package/dist/esm/filters/isotropic/webgpu.js.map +1 -0
  647. package/dist/esm/filters/multi-channel/bilateral/cpu.js +75 -0
  648. package/dist/esm/filters/multi-channel/bilateral/cpu.js.map +1 -0
  649. package/dist/esm/filters/multi-channel/bilateral/index.js +25 -0
  650. package/dist/esm/filters/multi-channel/bilateral/index.js.map +1 -0
  651. package/dist/esm/filters/multi-channel/bilateral/shared.js +48 -0
  652. package/dist/esm/filters/multi-channel/bilateral/shared.js.map +1 -0
  653. package/dist/esm/filters/multi-channel/bilateral/webgl.js +175 -0
  654. package/dist/esm/filters/multi-channel/bilateral/webgl.js.map +1 -0
  655. package/dist/esm/filters/multi-channel/bilateral/webgpu.js +124 -0
  656. package/dist/esm/filters/multi-channel/bilateral/webgpu.js.map +1 -0
  657. package/dist/esm/filters/multi-channel/index.js +4 -0
  658. package/dist/esm/filters/multi-channel/index.js.map +1 -0
  659. package/dist/esm/filters/multi-channel/kuwahara/cpu.js +106 -0
  660. package/dist/esm/filters/multi-channel/kuwahara/cpu.js.map +1 -0
  661. package/dist/esm/filters/multi-channel/kuwahara/index.js +25 -0
  662. package/dist/esm/filters/multi-channel/kuwahara/index.js.map +1 -0
  663. package/dist/esm/filters/multi-channel/kuwahara/shared.js +82 -0
  664. package/dist/esm/filters/multi-channel/kuwahara/shared.js.map +1 -0
  665. package/dist/esm/filters/multi-channel/kuwahara/webgl.js +173 -0
  666. package/dist/esm/filters/multi-channel/kuwahara/webgl.js.map +1 -0
  667. package/dist/esm/filters/multi-channel/kuwahara/webgpu.js +119 -0
  668. package/dist/esm/filters/multi-channel/kuwahara/webgpu.js.map +1 -0
  669. package/dist/esm/filters/multi-channel/median/cpu.js +89 -0
  670. package/dist/esm/filters/multi-channel/median/cpu.js.map +1 -0
  671. package/dist/esm/filters/multi-channel/median/index.js +25 -0
  672. package/dist/esm/filters/multi-channel/median/index.js.map +1 -0
  673. package/dist/esm/filters/multi-channel/median/shared.js +28 -0
  674. package/dist/esm/filters/multi-channel/median/shared.js.map +1 -0
  675. package/dist/esm/filters/multi-channel/median/webgl.js +172 -0
  676. package/dist/esm/filters/multi-channel/median/webgl.js.map +1 -0
  677. package/dist/esm/filters/multi-channel/median/webgpu.js +118 -0
  678. package/dist/esm/filters/multi-channel/median/webgpu.js.map +1 -0
  679. package/dist/esm/filters/multi-channel/multichannel.js +78 -0
  680. package/dist/esm/filters/multi-channel/multichannel.js.map +1 -0
  681. package/dist/esm/filters/multi-channel/shaders/bilateral.glsl.js +46 -0
  682. package/dist/esm/filters/multi-channel/shaders/bilateral.glsl.js.map +1 -0
  683. package/dist/esm/filters/multi-channel/shaders/bilateral.wgsl.js +57 -0
  684. package/dist/esm/filters/multi-channel/shaders/bilateral.wgsl.js.map +1 -0
  685. package/dist/esm/filters/multi-channel/shaders/kuwahara.glsl.js +51 -0
  686. package/dist/esm/filters/multi-channel/shaders/kuwahara.glsl.js.map +1 -0
  687. package/dist/esm/filters/multi-channel/shaders/kuwahara.wgsl.js +65 -0
  688. package/dist/esm/filters/multi-channel/shaders/kuwahara.wgsl.js.map +1 -0
  689. package/dist/esm/filters/multi-channel/shaders/median.glsl.js +94 -0
  690. package/dist/esm/filters/multi-channel/shaders/median.glsl.js.map +1 -0
  691. package/dist/esm/filters/multi-channel/shaders/median.wgsl.js +91 -0
  692. package/dist/esm/filters/multi-channel/shaders/median.wgsl.js.map +1 -0
  693. package/dist/esm/filters/resilient-filter.js +80 -0
  694. package/dist/esm/filters/resilient-filter.js.map +1 -0
  695. package/dist/esm/filters/shaders/webgl/bilateral.glsl.js +46 -0
  696. package/dist/esm/filters/shaders/webgl/bilateral.glsl.js.map +1 -0
  697. package/dist/esm/filters/shaders/webgl/contrast.glsl.js +26 -0
  698. package/dist/esm/filters/shaders/webgl/contrast.glsl.js.map +1 -0
  699. package/dist/esm/filters/shaders/webgl/guassian-horizontal.glsl.js +32 -0
  700. package/dist/esm/filters/shaders/webgl/guassian-horizontal.glsl.js.map +1 -0
  701. package/dist/esm/filters/shaders/webgl/guassian-vertical.glsl.js +32 -0
  702. package/dist/esm/filters/shaders/webgl/guassian-vertical.glsl.js.map +1 -0
  703. package/dist/esm/filters/shaders/webgl/kuwahara.glsl.js +57 -0
  704. package/dist/esm/filters/shaders/webgl/kuwahara.glsl.js.map +1 -0
  705. package/dist/esm/filters/shaders/webgl/median-small.glsl.js +50 -0
  706. package/dist/esm/filters/shaders/webgl/median-small.glsl.js.map +1 -0
  707. package/dist/esm/filters/shaders/webgl/median.glsl.js +57 -0
  708. package/dist/esm/filters/shaders/webgl/median.glsl.js.map +1 -0
  709. package/dist/esm/filters/shaders/webgl/quantize.glsl.js +21 -0
  710. package/dist/esm/filters/shaders/webgl/quantize.glsl.js.map +1 -0
  711. package/dist/esm/filters/shaders/webgpu/bilateral.wgsl.js +64 -0
  712. package/dist/esm/filters/shaders/webgpu/bilateral.wgsl.js.map +1 -0
  713. package/dist/esm/filters/shaders/webgpu/gaussian.wgsl.js +51 -0
  714. package/dist/esm/filters/shaders/webgpu/gaussian.wgsl.js.map +1 -0
  715. package/dist/esm/filters/shaders/webgpu/histogram.wgsl.js +30 -0
  716. package/dist/esm/filters/shaders/webgpu/histogram.wgsl.js.map +1 -0
  717. package/dist/esm/filters/shaders/webgpu/kuwahara.wgsl.js +67 -0
  718. package/dist/esm/filters/shaders/webgpu/kuwahara.wgsl.js.map +1 -0
  719. package/dist/esm/filters/shaders/webgpu/median.wgsl.js +68 -0
  720. package/dist/esm/filters/shaders/webgpu/median.wgsl.js.map +1 -0
  721. package/dist/esm/filters/shaders/webgpu/quantize.wgsl.js +29 -0
  722. package/dist/esm/filters/shaders/webgpu/quantize.wgsl.js.map +1 -0
  723. package/dist/esm/filters/shaders/webgpu/stretch.wgsl.js +30 -0
  724. package/dist/esm/filters/shaders/webgpu/stretch.wgsl.js.map +1 -0
  725. package/dist/esm/filters/webgl.js +600 -0
  726. package/dist/esm/filters/webgl.js.map +1 -0
  727. package/dist/esm/filters/webgpu.js +633 -0
  728. package/dist/esm/filters/webgpu.js.map +1 -0
  729. package/dist/esm/index.js +101 -0
  730. package/dist/esm/index.js.map +1 -0
  731. package/dist/esm/interfaces/base.js +54 -0
  732. package/dist/esm/interfaces/base.js.map +1 -0
  733. package/dist/esm/interfaces/dog.js +258 -0
  734. package/dist/esm/interfaces/dog.js.map +1 -0
  735. package/dist/esm/map/channel-map-ops.js +58 -0
  736. package/dist/esm/map/channel-map-ops.js.map +1 -0
  737. package/dist/esm/map/index.js +40 -0
  738. package/dist/esm/map/index.js.map +1 -0
  739. package/dist/esm/map/strategies.js +179 -0
  740. package/dist/esm/map/strategies.js.map +1 -0
  741. package/dist/esm/map/structure-tensor.js +77 -0
  742. package/dist/esm/map/structure-tensor.js.map +1 -0
  743. package/dist/esm/preprocess/index.js +3 -0
  744. package/dist/esm/preprocess/index.js.map +1 -0
  745. package/dist/esm/preprocess/parameter-estimation/epsilon.js +69 -0
  746. package/dist/esm/preprocess/parameter-estimation/epsilon.js.map +1 -0
  747. package/dist/esm/preprocess/parameter-estimation/index.js +4 -0
  748. package/dist/esm/preprocess/parameter-estimation/index.js.map +1 -0
  749. package/dist/esm/preprocess/parameter-estimation/p.js +47 -0
  750. package/dist/esm/preprocess/parameter-estimation/p.js.map +1 -0
  751. package/dist/esm/preprocess/parameter-estimation/phi.js +46 -0
  752. package/dist/esm/preprocess/parameter-estimation/phi.js.map +1 -0
  753. package/dist/esm/preprocess/parameter-estimation/shared.js +168 -0
  754. package/dist/esm/preprocess/parameter-estimation/shared.js.map +1 -0
  755. package/dist/esm/preprocess/preprocessors/index.js +318 -0
  756. package/dist/esm/preprocess/preprocessors/index.js.map +1 -0
  757. package/dist/esm/processor.js +251 -0
  758. package/dist/esm/processor.js.map +1 -0
  759. package/dist/esm/shaders/vertex-shader.wgsl.js +18 -0
  760. package/dist/esm/shaders/vertex-shader.wgsl.js.map +1 -0
  761. package/dist/esm/threshold.js +124 -0
  762. package/dist/esm/threshold.js.map +1 -0
  763. package/dist/esm/utils/color.js +284 -0
  764. package/dist/esm/utils/color.js.map +1 -0
  765. package/dist/esm/utils/device.js +49 -0
  766. package/dist/esm/utils/device.js.map +1 -0
  767. package/dist/esm/utils/image.js +172 -0
  768. package/dist/esm/utils/image.js.map +1 -0
  769. package/dist/esm/utils/index.js +14 -0
  770. package/dist/esm/utils/index.js.map +1 -0
  771. package/dist/esm/utils/math.js +57 -0
  772. package/dist/esm/utils/math.js.map +1 -0
  773. package/dist/esm/utils/scalar-field.js +109 -0
  774. package/dist/esm/utils/scalar-field.js.map +1 -0
  775. package/dist/types/base.d.ts +74 -0
  776. package/dist/types/base.d.ts.map +1 -0
  777. package/dist/types/blur/edge-aware-blur.d.ts +10 -0
  778. package/dist/types/blur/edge-aware-blur.d.ts.map +1 -0
  779. package/dist/types/blur/flow-guided.d.ts +180 -0
  780. package/dist/types/blur/flow-guided.d.ts.map +1 -0
  781. package/dist/types/blur/gradient-aligned/cpu.d.ts +24 -0
  782. package/dist/types/blur/gradient-aligned/cpu.d.ts.map +1 -0
  783. package/dist/types/blur/gradient-aligned/index.d.ts +24 -0
  784. package/dist/types/blur/gradient-aligned/index.d.ts.map +1 -0
  785. package/dist/types/blur/gradient-aligned/webgl.d.ts +39 -0
  786. package/dist/types/blur/gradient-aligned/webgl.d.ts.map +1 -0
  787. package/dist/types/blur/gradient-aligned/webgpu.d.ts +79 -0
  788. package/dist/types/blur/gradient-aligned/webgpu.d.ts.map +1 -0
  789. package/dist/types/blur/index.d.ts +6 -0
  790. package/dist/types/blur/index.d.ts.map +1 -0
  791. package/dist/types/blur/isotropic.d.ts +29 -0
  792. package/dist/types/blur/isotropic.d.ts.map +1 -0
  793. package/dist/types/blur/shaders/flow-guided/webgl2-flow-blur.glsl.d.ts +3 -0
  794. package/dist/types/blur/shaders/flow-guided/webgl2-flow-blur.glsl.d.ts.map +1 -0
  795. package/dist/types/blur/shaders/flow-guided/webgl2-vertex.glsl.d.ts +3 -0
  796. package/dist/types/blur/shaders/flow-guided/webgl2-vertex.glsl.d.ts.map +1 -0
  797. package/dist/types/blur/shaders/flow-guided/webgpu-flow-blur.wgsl.d.ts +3 -0
  798. package/dist/types/blur/shaders/flow-guided/webgpu-flow-blur.wgsl.d.ts.map +1 -0
  799. package/dist/types/blur/shaders/gradient-aligned/vertex.glsl.d.ts +3 -0
  800. package/dist/types/blur/shaders/gradient-aligned/vertex.glsl.d.ts.map +1 -0
  801. package/dist/types/blur/shaders/gradient-aligned/webgl2-fragment.glsl.d.ts +3 -0
  802. package/dist/types/blur/shaders/gradient-aligned/webgl2-fragment.glsl.d.ts.map +1 -0
  803. package/dist/types/blur/shaders/gradient-aligned/webgpu-fragment.wgsl.d.ts +3 -0
  804. package/dist/types/blur/shaders/gradient-aligned/webgpu-fragment.wgsl.d.ts.map +1 -0
  805. package/dist/types/blur/shaders/isotropic/webgl-horizontal-blur.glsl.d.ts +3 -0
  806. package/dist/types/blur/shaders/isotropic/webgl-horizontal-blur.glsl.d.ts.map +1 -0
  807. package/dist/types/blur/shaders/isotropic/webgl-vertical-blur.glsl.d.ts +3 -0
  808. package/dist/types/blur/shaders/isotropic/webgl-vertical-blur.glsl.d.ts.map +1 -0
  809. package/dist/types/blur/shaders/isotropic/webgpu-horizontal-blur.wgsl.d.ts +3 -0
  810. package/dist/types/blur/shaders/isotropic/webgpu-horizontal-blur.wgsl.d.ts.map +1 -0
  811. package/dist/types/blur/shaders/isotropic/webgpu-vertical-blur.wgsl.d.ts +3 -0
  812. package/dist/types/blur/shaders/isotropic/webgpu-vertical-blur.wgsl.d.ts.map +1 -0
  813. package/dist/types/dog/adog.d.ts +80 -0
  814. package/dist/types/dog/adog.d.ts.map +1 -0
  815. package/dist/types/dog/fdog.d.ts +93 -0
  816. package/dist/types/dog/fdog.d.ts.map +1 -0
  817. package/dist/types/dog/hdog.d.ts +39 -0
  818. package/dist/types/dog/hdog.d.ts.map +1 -0
  819. package/dist/types/dog/index.d.ts +7 -0
  820. package/dist/types/dog/index.d.ts.map +1 -0
  821. package/dist/types/dog/xdog.d.ts +70 -0
  822. package/dist/types/dog/xdog.d.ts.map +1 -0
  823. package/dist/types/etf/cpu.d.ts +35 -0
  824. package/dist/types/etf/cpu.d.ts.map +1 -0
  825. package/dist/types/etf/flow-field.d.ts +29 -0
  826. package/dist/types/etf/flow-field.d.ts.map +1 -0
  827. package/dist/types/etf/index.d.ts +31 -0
  828. package/dist/types/etf/index.d.ts.map +1 -0
  829. package/dist/types/etf/shaders/webgl/finalize_magnitude.glsl.d.ts +3 -0
  830. package/dist/types/etf/shaders/webgl/finalize_magnitude.glsl.d.ts.map +1 -0
  831. package/dist/types/etf/shaders/webgl/gaussian_blur_h.glsl.d.ts +3 -0
  832. package/dist/types/etf/shaders/webgl/gaussian_blur_h.glsl.d.ts.map +1 -0
  833. package/dist/types/etf/shaders/webgl/gaussian_blur_v.glsl.d.ts +3 -0
  834. package/dist/types/etf/shaders/webgl/gaussian_blur_v.glsl.d.ts.map +1 -0
  835. package/dist/types/etf/shaders/webgl/gradient.glsl.d.ts +3 -0
  836. package/dist/types/etf/shaders/webgl/gradient.glsl.d.ts.map +1 -0
  837. package/dist/types/etf/shaders/webgl/structural_tensor.glsl.d.ts +3 -0
  838. package/dist/types/etf/shaders/webgl/structural_tensor.glsl.d.ts.map +1 -0
  839. package/dist/types/etf/shaders/webgl/tangent_extract.glsl.d.ts +3 -0
  840. package/dist/types/etf/shaders/webgl/tangent_extract.glsl.d.ts.map +1 -0
  841. package/dist/types/etf/shaders/webgl/tangent_refine.glsl.d.ts +3 -0
  842. package/dist/types/etf/shaders/webgl/tangent_refine.glsl.d.ts.map +1 -0
  843. package/dist/types/etf/shaders/webgl/vertex.glsl.d.ts +3 -0
  844. package/dist/types/etf/shaders/webgl/vertex.glsl.d.ts.map +1 -0
  845. package/dist/types/etf/shaders/webgpu/common.wgsl.d.ts +3 -0
  846. package/dist/types/etf/shaders/webgpu/common.wgsl.d.ts.map +1 -0
  847. package/dist/types/etf/shaders/webgpu/gaussian_blur.wgsl.d.ts +3 -0
  848. package/dist/types/etf/shaders/webgpu/gaussian_blur.wgsl.d.ts.map +1 -0
  849. package/dist/types/etf/shaders/webgpu/gaussian_blur_tiled.wgsl.d.ts +3 -0
  850. package/dist/types/etf/shaders/webgpu/gaussian_blur_tiled.wgsl.d.ts.map +1 -0
  851. package/dist/types/etf/shaders/webgpu/gradient_structure_tensor.wgsl.d.ts +3 -0
  852. package/dist/types/etf/shaders/webgpu/gradient_structure_tensor.wgsl.d.ts.map +1 -0
  853. package/dist/types/etf/shaders/webgpu/tangent_extract.wgsl.d.ts +3 -0
  854. package/dist/types/etf/shaders/webgpu/tangent_extract.wgsl.d.ts.map +1 -0
  855. package/dist/types/etf/shaders/webgpu/tangent_refine.wgsl.d.ts +3 -0
  856. package/dist/types/etf/shaders/webgpu/tangent_refine.wgsl.d.ts.map +1 -0
  857. package/dist/types/etf/webgl.d.ts +46 -0
  858. package/dist/types/etf/webgl.d.ts.map +1 -0
  859. package/dist/types/etf/webgpu.d.ts +139 -0
  860. package/dist/types/etf/webgpu.d.ts.map +1 -0
  861. package/dist/types/extensions/anti-alias.d.ts +55 -0
  862. package/dist/types/extensions/anti-alias.d.ts.map +1 -0
  863. package/dist/types/extensions/base.d.ts +33 -0
  864. package/dist/types/extensions/base.d.ts.map +1 -0
  865. package/dist/types/extensions/color-retention.d.ts +467 -0
  866. package/dist/types/extensions/color-retention.d.ts.map +1 -0
  867. package/dist/types/extensions/hatching.d.ts +111 -0
  868. package/dist/types/extensions/hatching.d.ts.map +1 -0
  869. package/dist/types/extensions/index.d.ts +33 -0
  870. package/dist/types/extensions/index.d.ts.map +1 -0
  871. package/dist/types/extensions/multi-scale.d.ts +301 -0
  872. package/dist/types/extensions/multi-scale.d.ts.map +1 -0
  873. package/dist/types/extensions/natural-media.d.ts +72 -0
  874. package/dist/types/extensions/natural-media.d.ts.map +1 -0
  875. package/dist/types/extensions/pipeline.d.ts +45 -0
  876. package/dist/types/extensions/pipeline.d.ts.map +1 -0
  877. package/dist/types/extensions/utils.d.ts +19 -0
  878. package/dist/types/extensions/utils.d.ts.map +1 -0
  879. package/dist/types/filters/cpu.d.ts +173 -0
  880. package/dist/types/filters/cpu.d.ts.map +1 -0
  881. package/dist/types/filters/filters.d.ts +114 -0
  882. package/dist/types/filters/filters.d.ts.map +1 -0
  883. package/dist/types/filters/index.d.ts +7 -0
  884. package/dist/types/filters/index.d.ts.map +1 -0
  885. package/dist/types/filters/isotropic/cpu.d.ts +21 -0
  886. package/dist/types/filters/isotropic/cpu.d.ts.map +1 -0
  887. package/dist/types/filters/isotropic/index.d.ts +4 -0
  888. package/dist/types/filters/isotropic/index.d.ts.map +1 -0
  889. package/dist/types/filters/isotropic/shaders/guassian-horizontal.glsl.d.ts +3 -0
  890. package/dist/types/filters/isotropic/shaders/guassian-horizontal.glsl.d.ts.map +1 -0
  891. package/dist/types/filters/isotropic/shaders/guassian-vertical.glsl.d.ts +3 -0
  892. package/dist/types/filters/isotropic/shaders/guassian-vertical.glsl.d.ts.map +1 -0
  893. package/dist/types/filters/isotropic/shaders/webgpu-horizontal-blur.wgsl.d.ts +3 -0
  894. package/dist/types/filters/isotropic/shaders/webgpu-horizontal-blur.wgsl.d.ts.map +1 -0
  895. package/dist/types/filters/isotropic/shaders/webgpu-vertical-blur.wgsl.d.ts +3 -0
  896. package/dist/types/filters/isotropic/shaders/webgpu-vertical-blur.wgsl.d.ts.map +1 -0
  897. package/dist/types/filters/isotropic/webgl.d.ts +22 -0
  898. package/dist/types/filters/isotropic/webgl.d.ts.map +1 -0
  899. package/dist/types/filters/isotropic/webgpu.d.ts +39 -0
  900. package/dist/types/filters/isotropic/webgpu.d.ts.map +1 -0
  901. package/dist/types/filters/multi-channel/bilateral/cpu.d.ts +17 -0
  902. package/dist/types/filters/multi-channel/bilateral/cpu.d.ts.map +1 -0
  903. package/dist/types/filters/multi-channel/bilateral/index.d.ts +18 -0
  904. package/dist/types/filters/multi-channel/bilateral/index.d.ts.map +1 -0
  905. package/dist/types/filters/multi-channel/bilateral/shared.d.ts +54 -0
  906. package/dist/types/filters/multi-channel/bilateral/shared.d.ts.map +1 -0
  907. package/dist/types/filters/multi-channel/bilateral/webgl.d.ts +16 -0
  908. package/dist/types/filters/multi-channel/bilateral/webgl.d.ts.map +1 -0
  909. package/dist/types/filters/multi-channel/bilateral/webgpu.d.ts +24 -0
  910. package/dist/types/filters/multi-channel/bilateral/webgpu.d.ts.map +1 -0
  911. package/dist/types/filters/multi-channel/index.d.ts +7 -0
  912. package/dist/types/filters/multi-channel/index.d.ts.map +1 -0
  913. package/dist/types/filters/multi-channel/kuwahara/cpu.d.ts +17 -0
  914. package/dist/types/filters/multi-channel/kuwahara/cpu.d.ts.map +1 -0
  915. package/dist/types/filters/multi-channel/kuwahara/index.d.ts +18 -0
  916. package/dist/types/filters/multi-channel/kuwahara/index.d.ts.map +1 -0
  917. package/dist/types/filters/multi-channel/kuwahara/shared.d.ts +47 -0
  918. package/dist/types/filters/multi-channel/kuwahara/shared.d.ts.map +1 -0
  919. package/dist/types/filters/multi-channel/kuwahara/webgl.d.ts +16 -0
  920. package/dist/types/filters/multi-channel/kuwahara/webgl.d.ts.map +1 -0
  921. package/dist/types/filters/multi-channel/kuwahara/webgpu.d.ts +24 -0
  922. package/dist/types/filters/multi-channel/kuwahara/webgpu.d.ts.map +1 -0
  923. package/dist/types/filters/multi-channel/median/cpu.d.ts +17 -0
  924. package/dist/types/filters/multi-channel/median/cpu.d.ts.map +1 -0
  925. package/dist/types/filters/multi-channel/median/index.d.ts +18 -0
  926. package/dist/types/filters/multi-channel/median/index.d.ts.map +1 -0
  927. package/dist/types/filters/multi-channel/median/shared.d.ts +34 -0
  928. package/dist/types/filters/multi-channel/median/shared.d.ts.map +1 -0
  929. package/dist/types/filters/multi-channel/median/webgl.d.ts +16 -0
  930. package/dist/types/filters/multi-channel/median/webgl.d.ts.map +1 -0
  931. package/dist/types/filters/multi-channel/median/webgpu.d.ts +24 -0
  932. package/dist/types/filters/multi-channel/median/webgpu.d.ts.map +1 -0
  933. package/dist/types/filters/multi-channel/multichannel.d.ts +35 -0
  934. package/dist/types/filters/multi-channel/multichannel.d.ts.map +1 -0
  935. package/dist/types/filters/multi-channel/shaders/bilateral.glsl.d.ts +3 -0
  936. package/dist/types/filters/multi-channel/shaders/bilateral.glsl.d.ts.map +1 -0
  937. package/dist/types/filters/multi-channel/shaders/bilateral.wgsl.d.ts +3 -0
  938. package/dist/types/filters/multi-channel/shaders/bilateral.wgsl.d.ts.map +1 -0
  939. package/dist/types/filters/multi-channel/shaders/kuwahara.glsl.d.ts +3 -0
  940. package/dist/types/filters/multi-channel/shaders/kuwahara.glsl.d.ts.map +1 -0
  941. package/dist/types/filters/multi-channel/shaders/kuwahara.wgsl.d.ts +3 -0
  942. package/dist/types/filters/multi-channel/shaders/kuwahara.wgsl.d.ts.map +1 -0
  943. package/dist/types/filters/multi-channel/shaders/median.glsl.d.ts +3 -0
  944. package/dist/types/filters/multi-channel/shaders/median.glsl.d.ts.map +1 -0
  945. package/dist/types/filters/multi-channel/shaders/median.wgsl.d.ts +3 -0
  946. package/dist/types/filters/multi-channel/shaders/median.wgsl.d.ts.map +1 -0
  947. package/dist/types/filters/resilient-filter.d.ts +31 -0
  948. package/dist/types/filters/resilient-filter.d.ts.map +1 -0
  949. package/dist/types/filters/shaders/webgl/bilateral.glsl.d.ts +3 -0
  950. package/dist/types/filters/shaders/webgl/bilateral.glsl.d.ts.map +1 -0
  951. package/dist/types/filters/shaders/webgl/contrast.glsl.d.ts +3 -0
  952. package/dist/types/filters/shaders/webgl/contrast.glsl.d.ts.map +1 -0
  953. package/dist/types/filters/shaders/webgl/guassian-horizontal.glsl.d.ts +3 -0
  954. package/dist/types/filters/shaders/webgl/guassian-horizontal.glsl.d.ts.map +1 -0
  955. package/dist/types/filters/shaders/webgl/guassian-vertical.glsl.d.ts +3 -0
  956. package/dist/types/filters/shaders/webgl/guassian-vertical.glsl.d.ts.map +1 -0
  957. package/dist/types/filters/shaders/webgl/kuwahara.glsl.d.ts +3 -0
  958. package/dist/types/filters/shaders/webgl/kuwahara.glsl.d.ts.map +1 -0
  959. package/dist/types/filters/shaders/webgl/median-small.glsl.d.ts +3 -0
  960. package/dist/types/filters/shaders/webgl/median-small.glsl.d.ts.map +1 -0
  961. package/dist/types/filters/shaders/webgl/median.glsl.d.ts +3 -0
  962. package/dist/types/filters/shaders/webgl/median.glsl.d.ts.map +1 -0
  963. package/dist/types/filters/shaders/webgl/quantize.glsl.d.ts +3 -0
  964. package/dist/types/filters/shaders/webgl/quantize.glsl.d.ts.map +1 -0
  965. package/dist/types/filters/shaders/webgpu/bilateral.wgsl.d.ts +3 -0
  966. package/dist/types/filters/shaders/webgpu/bilateral.wgsl.d.ts.map +1 -0
  967. package/dist/types/filters/shaders/webgpu/gaussian.wgsl.d.ts +3 -0
  968. package/dist/types/filters/shaders/webgpu/gaussian.wgsl.d.ts.map +1 -0
  969. package/dist/types/filters/shaders/webgpu/histogram.wgsl.d.ts +3 -0
  970. package/dist/types/filters/shaders/webgpu/histogram.wgsl.d.ts.map +1 -0
  971. package/dist/types/filters/shaders/webgpu/kuwahara.wgsl.d.ts +3 -0
  972. package/dist/types/filters/shaders/webgpu/kuwahara.wgsl.d.ts.map +1 -0
  973. package/dist/types/filters/shaders/webgpu/median.wgsl.d.ts +3 -0
  974. package/dist/types/filters/shaders/webgpu/median.wgsl.d.ts.map +1 -0
  975. package/dist/types/filters/shaders/webgpu/quantize.wgsl.d.ts +3 -0
  976. package/dist/types/filters/shaders/webgpu/quantize.wgsl.d.ts.map +1 -0
  977. package/dist/types/filters/shaders/webgpu/stretch.wgsl.d.ts +3 -0
  978. package/dist/types/filters/shaders/webgpu/stretch.wgsl.d.ts.map +1 -0
  979. package/dist/types/filters/webgl.d.ts +48 -0
  980. package/dist/types/filters/webgl.d.ts.map +1 -0
  981. package/dist/types/filters/webgpu.d.ts +85 -0
  982. package/dist/types/filters/webgpu.d.ts.map +1 -0
  983. package/dist/types/index.d.ts +100 -0
  984. package/dist/types/index.d.ts.map +1 -0
  985. package/dist/types/interfaces/base.d.ts +465 -0
  986. package/dist/types/interfaces/base.d.ts.map +1 -0
  987. package/dist/types/interfaces/dog.d.ts +632 -0
  988. package/dist/types/interfaces/dog.d.ts.map +1 -0
  989. package/dist/types/map/channel-map-ops.d.ts +19 -0
  990. package/dist/types/map/channel-map-ops.d.ts.map +1 -0
  991. package/dist/types/map/index.d.ts +40 -0
  992. package/dist/types/map/index.d.ts.map +1 -0
  993. package/dist/types/map/strategies.d.ts +127 -0
  994. package/dist/types/map/strategies.d.ts.map +1 -0
  995. package/dist/types/map/structure-tensor.d.ts +15 -0
  996. package/dist/types/map/structure-tensor.d.ts.map +1 -0
  997. package/dist/types/preprocess/index.d.ts +3 -0
  998. package/dist/types/preprocess/index.d.ts.map +1 -0
  999. package/dist/types/preprocess/parameter-estimation/epsilon.d.ts +60 -0
  1000. package/dist/types/preprocess/parameter-estimation/epsilon.d.ts.map +1 -0
  1001. package/dist/types/preprocess/parameter-estimation/index.d.ts +4 -0
  1002. package/dist/types/preprocess/parameter-estimation/index.d.ts.map +1 -0
  1003. package/dist/types/preprocess/parameter-estimation/p.d.ts +45 -0
  1004. package/dist/types/preprocess/parameter-estimation/p.d.ts.map +1 -0
  1005. package/dist/types/preprocess/parameter-estimation/phi.d.ts +44 -0
  1006. package/dist/types/preprocess/parameter-estimation/phi.d.ts.map +1 -0
  1007. package/dist/types/preprocess/parameter-estimation/shared.d.ts +44 -0
  1008. package/dist/types/preprocess/parameter-estimation/shared.d.ts.map +1 -0
  1009. package/dist/types/preprocess/preprocessors/index.d.ts +153 -0
  1010. package/dist/types/preprocess/preprocessors/index.d.ts.map +1 -0
  1011. package/dist/types/processor.d.ts +150 -0
  1012. package/dist/types/processor.d.ts.map +1 -0
  1013. package/dist/types/shaders/vertex-shader.wgsl.d.ts +3 -0
  1014. package/dist/types/shaders/vertex-shader.wgsl.d.ts.map +1 -0
  1015. package/dist/types/threshold.d.ts +53 -0
  1016. package/dist/types/threshold.d.ts.map +1 -0
  1017. package/dist/types/utils/color.d.ts +77 -0
  1018. package/dist/types/utils/color.d.ts.map +1 -0
  1019. package/dist/types/utils/device.d.ts +3 -0
  1020. package/dist/types/utils/device.d.ts.map +1 -0
  1021. package/dist/types/utils/image.d.ts +67 -0
  1022. package/dist/types/utils/image.d.ts.map +1 -0
  1023. package/dist/types/utils/index.d.ts +13 -0
  1024. package/dist/types/utils/index.d.ts.map +1 -0
  1025. package/dist/types/utils/math.d.ts +29 -0
  1026. package/dist/types/utils/math.d.ts.map +1 -0
  1027. package/dist/types/utils/scalar-field.d.ts +67 -0
  1028. package/dist/types/utils/scalar-field.d.ts.map +1 -0
  1029. package/package.json +187 -3
@@ -0,0 +1,4320 @@
1
+ /**
2
+ * Core types for XDoG/FDoG/ADoG/HDoG line drawing implementation
3
+ *
4
+ * Based on: "XDoG: An eXtended difference-of-Gaussians compendium including
5
+ * advanced image stylization" by Winnemöller et al. (2012)
6
+ * and: "Gaussian Image Binarization" by Kang & Stamoulis (2021)
7
+ */
8
+ /**
9
+ * Simple 2D vector
10
+ */
11
+ interface Vec2 {
12
+ x: number;
13
+ y: number;
14
+ }
15
+ /**
16
+ * Single-channel image representation
17
+ * Using a flat Float32Array for performance and future GPU compatibility
18
+ * Values are normalized to 0-1 range
19
+ */
20
+ interface ChannelImage {
21
+ data: Float32Array;
22
+ width: number;
23
+ height: number;
24
+ }
25
+ /**
26
+ * Color spaces a MultiChannelImage can be stored in. This describes what the
27
+ * channels *mean*, not whether transparency is present (see `alpha`).
28
+ *
29
+ * Native value ranges per space:
30
+ * - gray: [v] v in [0, 1]
31
+ * - rgb: [r, g, b] sRGB (gamma-encoded), each in [0, 1]
32
+ * - linear-rgb: [r, g, b] linear light, each in [0, 1]
33
+ * - lab: [L, a, b] CIE Lab (D65). L in [0, 100]; a, b roughly [-128, 127]
34
+ * - hsv / hsl: [h, s, v|l] h in [0, 1) as a fraction of a turn; s, v|l in [0, 1].
35
+ * Note h is circular: don't take plain gradients of it.
36
+ *
37
+ * Channels are stored in their native units; any normalization a consumer
38
+ * wants (e.g. Lab -> [0, 1] for ETF) is applied at the point of use.
39
+ */
40
+ type ColorSpace = 'gray' | 'rgb' | 'linear-rgb' | 'lab' | 'hsv' | 'hsl';
41
+ /**
42
+ * Color-space-agnostic planar image.
43
+ *
44
+ * Planar layout: `channels[c][y * width + x]`. Every plane has length
45
+ * `width * height` and `channels.length === CHANNEL_COUNTS[space]`. Each plane
46
+ * is a plain Float32Array, so `{ data: channels[c], width, height }` is a
47
+ * zero-copy ChannelImage (see channelView() in utils/image.ts).
48
+ *
49
+ * Alpha is deliberately not a color space: it is an optional extra plane in
50
+ * [0, 1] that colour conversions pass through untouched.
51
+ */
52
+ interface MultiChannelImage<S extends ColorSpace = ColorSpace> {
53
+ space: S;
54
+ width: number;
55
+ height: number;
56
+ channels: Float32Array[];
57
+ alpha?: Float32Array;
58
+ }
59
+ /** sRGB image, planar: channels = [r, g, b], each in [0, 1]. */
60
+ type RGBImage$1 = MultiChannelImage<'rgb'>;
61
+ /**
62
+ * Implemented by anything holding resources that must be explicitly
63
+ * released (e.g. GPU buffers/textures). CPU-only implementations may
64
+ * implement this as a no-op, but still implement it — callers that manage
65
+ * a mixed pipeline of strategies need to be able to dispose everything
66
+ * uniformly without checking which backend each instance happens to use.
67
+ */
68
+ interface Disposable {
69
+ dispose(): void;
70
+ }
71
+ /**
72
+ * Implemented by anything with a technology-specific backing
73
+ * implementation (CPU, WebGL, WebGPU, ...), exposing which one is
74
+ * actually in use.
75
+ *
76
+ * Lets callers/perf tooling tell what ran without guessing — relevant
77
+ * since backend selection can fall back silently after construction (e.g.
78
+ * on a lost WebGL context). Single-backend implementations (e.g. a
79
+ * CPU-only preprocessor with no GPU counterpart) still report it — just
80
+ * always the same value.
81
+ */
82
+ interface BackendIdentifiable {
83
+ readonly backend: 'webgpu' | 'webgl' | 'cpu';
84
+ }
85
+ /** Anything an edge-aware filter can consume and produce. */
86
+ type FilterImage = ChannelImage | MultiChannelImage;
87
+ interface EdgeAwareFilterCore<TParams, TImage extends FilterImage = ChannelImage> extends Disposable, BackendIdentifiable {
88
+ apply(input: TImage, params: Partial<TParams>): Promise<TImage>;
89
+ }
90
+ type EdgeAwareFilterCtor<TParams, TImage extends FilterImage = ChannelImage> = StrategyCtor<EdgeAwareFilterCore<TParams, TImage>, Partial<TParams>>;
91
+ /**
92
+ * Abstract blur strategy interface
93
+ * Implementations provide different blur algorithms (isotropic, flow-guided, etc.)
94
+ */
95
+ interface BlurStrategy extends Disposable, BackendIdentifiable {
96
+ /**
97
+ * Apply blur to an image with the given sigma
98
+ * @param input Source image
99
+ * @param sigma Blur radius (standard deviation)
100
+ * @returns Blurred image
101
+ */
102
+ blur(input: ChannelImage, sigma: number): Promise<ChannelImage>;
103
+ }
104
+ /** Add a config generic so Ctor config is typed instead of `any`. Default keeps existing users compiling. */
105
+ interface StrategyCtor<T, TConfig = any> {
106
+ new (config: TConfig): T;
107
+ isSupported(): Promise<boolean>;
108
+ getUnsupportedReason?(): string | undefined | Promise<string | undefined>;
109
+ }
110
+ /**
111
+ * Generic static (constructor) interface shared by every strategy family
112
+ * in this file (blur, preprocessing, ETF, ...).
113
+ *
114
+ * This is deliberately a separate interface from the instance interface
115
+ * (`T`) rather than statics bolted onto it: `implements` only constrains
116
+ * instance shape, not the statics on a class object, so runtime-
117
+ * availability checks have to live on their own constructor-shaped
118
+ * interface and get asserted with `satisfies` instead.
119
+ */
120
+ interface StrategyCtor<T> {
121
+ new (config: any): T;
122
+ /**
123
+ * Check if this backend is supported in the current environment. Async
124
+ * because GPU support checks (requestAdapter(), WebGL context creation)
125
+ * are inherently async.
126
+ * @returns true if the backend can be used, false otherwise
127
+ */
128
+ isSupported(): Promise<boolean>;
129
+ /**
130
+ * Get a human-readable reason if the backend is not supported. May be
131
+ * asynchronous: cheap synchronous API-surface checks can't confirm a GPU
132
+ * adapter is actually obtainable — that requires an async request.
133
+ * @returns undefined if supported, or a string explaining why it's not
134
+ */
135
+ getUnsupportedReason?(): string | undefined | Promise<string | undefined>;
136
+ }
137
+ /**
138
+ * Abstract preprocessing strategy interface
139
+ * Implementations provide different image preprocessing/conditioning
140
+ * operations (bilateral filtering, median filtering, Kuwahara filtering,
141
+ * Gaussian blur, contrast enhancement, quantization, etc.) applied to an
142
+ * image before line detection.
143
+ */
144
+ interface Preprocessor extends Disposable, BackendIdentifiable {
145
+ /**
146
+ * Apply this preprocessing operation to an image
147
+ * @param input Source image
148
+ * @returns Processed image
149
+ */
150
+ process(input: ChannelImage): Promise<ChannelImage>;
151
+ }
152
+ /**
153
+ * Configuration for isotropic Gaussian blur
154
+ */
155
+ interface IsotropicBlurConfig {
156
+ sigma: number;
157
+ /**
158
+ * Kernel size multiplier relative to sigma (default: 6, meaning 3 * sigma on each side)
159
+ * Paper samples at 2x sigma for flow-aligned, 2.45x for structure tensor
160
+ */
161
+ kernelSizeMultiplier: number;
162
+ /** Maximum kernel size (default: 63) */
163
+ maxKernelSize: number;
164
+ }
165
+ declare const DEFAULT_ISOTROPIC_BLUR_CONFIG: IsotropicBlurConfig;
166
+ /**
167
+ * Configuration for flow-guided blur
168
+ */
169
+ interface GradientAlignedBlurConfig {
170
+ /**
171
+ * Kernel size multiplier for flow-aligned LIC (default: 6)
172
+ */
173
+ kernelSizeMultiplier: number;
174
+ /**
175
+ * Step size for line integral convolution (default: 1.0)
176
+ * Smaller values give smoother integration but cost more
177
+ */
178
+ stepSize: number;
179
+ }
180
+ declare const DEFAULT_GRADIENT_ALIGNED_BLUR_CONFIG: GradientAlignedBlurConfig;
181
+ /**
182
+ * Flow field representing edge tangent directions at each pixel, along
183
+ * with the structure-tensor-derived confidence data for that direction.
184
+ *
185
+ * magnitude and anisotropy are first-class here (not a separate
186
+ * "detailed" result) because every consumer of a FlowField benefits from
187
+ * knowing how much to trust it -- not just the callers who happened to
188
+ * ask for the detailed variant. See ETFComputer.compute() for how these
189
+ * are produced.
190
+ */
191
+ interface FlowField {
192
+ getTangent(x: number, y: number): Vec2;
193
+ /**
194
+ * Structure-tensor trace magnitude, sqrt(E + G), at this pixel.
195
+ * Unnormalized -- scale depends on input contrast. Use
196
+ * utils/scalar-field.js's normalizedMagnitudeField() to get a [0,1]
197
+ * field normalized against this FlowField's own maximum.
198
+ */
199
+ getMagnitude(x: number, y: number): number;
200
+ /**
201
+ * (lambda1-lambda2)/(lambda1+lambda2) in [0,1] at this pixel. 1 =
202
+ * coherent line direction, 0 = isotropic (flat region, corner, or
203
+ * texture noise where local gradients disagree).
204
+ */
205
+ getAnisotropy(x: number, y: number): number;
206
+ readonly width: number;
207
+ readonly height: number;
208
+ }
209
+ interface BilateralFilterConfig {
210
+ /** Spatial sigma - controls the size of the neighborhood (default: 3) */
211
+ sigmaSpatial: number;
212
+ /** Range/intensity sigma - controls sensitivity to intensity differences (default: 0.1) */
213
+ sigmaRange: number;
214
+ /** Kernel radius multiplier (default: 2, meaning radius = sigmaSpatial * 2) */
215
+ radiusMultiplier?: number;
216
+ }
217
+ declare const DEFAULT_BILATERAL_CONFIG: BilateralFilterConfig;
218
+ /**
219
+ * Configuration for Local Variance Texture Detection
220
+ *
221
+ * These parameters control how texture is detected. They are independent
222
+ * from XDoG/FDoG/HDoG parameters - you tune them separately based on the
223
+ * image characteristics you're working with.
224
+ */
225
+ interface LocalVarianceConfig {
226
+ /**
227
+ * Window radius for variance computation
228
+ * Examples:
229
+ * - 1 = 3x3 window (fast, fine detail)
230
+ * - 2 = 5x5 window (recommended, balanced)
231
+ * - 3 = 7x7 window (slower, coarser texture detection)
232
+ */
233
+ windowRadius: number;
234
+ /**
235
+ * Normalize by local gradient to distinguish texture from structure edges
236
+ *
237
+ * Without normalization:
238
+ * - High variance alone indicates texture
239
+ * - Problem: Subtle structural edges with variance get suppressed
240
+ *
241
+ * With normalization:
242
+ * - High variance + low gradient = texture (keep)
243
+ * - High variance + high gradient = edge (reduce texture score)
244
+ * - Formula: texture *= 1 / (1 + gradient^2)
245
+ *
246
+ * Recommended: true
247
+ */
248
+ normalizeByGradient: boolean;
249
+ /**
250
+ * Scale factor for raw variance values
251
+ * Typical range: 1.0 - 3.0
252
+ * Higher = more sensitive to texture variations
253
+ * Output is clamped to [0, 1] after scaling
254
+ */
255
+ varianceScale: number;
256
+ /**
257
+ * Optional hard cap on variance values (before normalization)
258
+ * Prevents outliers from dominating
259
+ * If undefined, no capping is applied
260
+ */
261
+ maxVariance?: number;
262
+ }
263
+ /**
264
+ * Configuration for median filter
265
+ */
266
+ interface MedianFilterConfig {
267
+ /** Radius of the filter (default: 2, meaning 5x5 kernel) */
268
+ radius: number;
269
+ }
270
+ declare const DEFAULT_MEDIAN_CONFIG: MedianFilterConfig;
271
+ /**
272
+ * Configuration for Kuwahara filter
273
+ */
274
+ interface KuwaharaFilterConfig {
275
+ /** Radius of the filter (default: 3) */
276
+ radius: number;
277
+ }
278
+ declare const DEFAULT_KUWAHARA_CONFIG: KuwaharaFilterConfig;
279
+ interface ContrastEnhancementConfig {
280
+ blackPoint: number;
281
+ whitePoint: number;
282
+ }
283
+ declare const DEFAULT_CONTRAST_ENHANCEMENT_CONFIG: ContrastEnhancementConfig;
284
+ interface QuantizerConfig {
285
+ levels: number;
286
+ }
287
+ declare const DEFAULT_QUANTIZER_CONFIG: {
288
+ levels: number;
289
+ };
290
+ interface GaussianConfig {
291
+ sigma: number;
292
+ }
293
+ declare const DEFAULT_GAUSSIAN_CONFIG: {
294
+ sigma: number;
295
+ };
296
+ /**
297
+ * Configuration for Edge Tangent Flow computation
298
+ *
299
+ * The ETF is computed from the smoothed structure tensor of image gradients.
300
+ * See Section 2.6 of the paper.
301
+ */
302
+ interface ETFConfig {
303
+ /**
304
+ * Number of refinement iterations for the tangent field (default: 3)
305
+ * More iterations increase line coherence but add computation time
306
+ */
307
+ iterations: number;
308
+ /**
309
+ * Kernel size for structure tensor smoothing (default: 5)
310
+ * Paper uses Gaussian smoothing with sampling within 2.45 * σc
311
+ */
312
+ kernelSize: number;
313
+ }
314
+ /**
315
+ * Default ETF configuration values
316
+ */
317
+ declare const DEFAULT_ETF_CONFIG: ETFConfig;
318
+ /**
319
+ * Common interface implemented by every Edge Tangent Flow backend
320
+ * (CPU, WebGL, WebGPU, ...).
321
+ *
322
+ * Multi-channel computation follows Di Zenzo's multichannel structure
323
+ * tensor approach ("A note on the gradient of a multi-image", CVGIP 33,
324
+ * 1986): implementations must combine per-channel structure tensors
325
+ * (not per-channel tangents) before eigendecomposition, so that a single
326
+ * eigendecomposition is performed on the combined tensor.
327
+ *
328
+ * Implementations have no color-space knowledge: a ChannelImage is just
329
+ * an arbitrary scalar field. Any color-space conversion or splitting
330
+ * (e.g. RGB -> Lab, or de-interleaving RGB into R/G/B channels) is the
331
+ * caller's responsibility and happens before compute()/computeMultiChannel()
332
+ * is called.
333
+ */
334
+ interface ETFComputer extends Disposable, BackendIdentifiable {
335
+ /**
336
+ * Compute an Edge Tangent Flow from a single scalar channel.
337
+ *
338
+ * @param input Scalar channel image (values in 0-1)
339
+ * @param config ETF configuration
340
+ * @param sigmaC Structure tensor smoothing sigma (optional override)
341
+ */
342
+ compute(input: ChannelImage, config?: Partial<ETFConfig>, sigmaC?: number): Promise<FlowField>;
343
+ /**
344
+ * Compute an Edge Tangent Flow jointly from several co-registered
345
+ * scalar channels (e.g. R/G/B or L/a/b), using Di Zenzo's multichannel
346
+ * structure tensor. All channels must share the same width/height.
347
+ *
348
+ * @param inputs Channel images, all with the same dimensions
349
+ * @param config ETF configuration
350
+ * @param sigmaC Structure tensor smoothing sigma (optional override)
351
+ */
352
+ computeMultiChannel(inputs: ChannelImage[], config?: Partial<ETFConfig>, sigmaC?: number): Promise<FlowField>;
353
+ }
354
+ interface ToneAdaptiveOptions {
355
+ /** Value to use where the local area is darkest (local tone -> 0). */
356
+ low: number;
357
+ /** Value to use where the local area is lightest (local tone -> 1). */
358
+ high: number;
359
+ /** Blur sigma for the local tone reading. Default: 8 */
360
+ localitySigma?: number;
361
+ /** tanh steepness (paper's `s` in Eq. 5/6). Default: 2 */
362
+ s?: number;
363
+ blurStrategy?: BlurStrategy;
364
+ }
365
+ interface ToneAdaptiveAutoOptions extends Omit<ToneAdaptiveOptions, 'low' | 'high'> {
366
+ center: number;
367
+ spread: number;
368
+ /** If true (default), dark -> center - spread, light -> center + spread. */
369
+ higherInLight?: boolean;
370
+ }
371
+ interface LocalBaselineOptions {
372
+ sigma: number;
373
+ /** Flat offset on top of the baseline. Default: 0 */
374
+ offset?: number;
375
+ /** Variance-scaled margin on top of baseline + offset. Default: 0 */
376
+ contrastMargin?: number;
377
+ blurStrategy?: BlurStrategy;
378
+ }
379
+ interface FieldAdaptiveOptions {
380
+ /** Value at the weakest/flattest end of the field. */
381
+ low: number;
382
+ /** Value at the field's own strongest point (normalized against its own max). */
383
+ high: number;
384
+ /** Exponent applied after normalizing. >1 favors only the strongest responses; <1 spreads out. Default: 1 */
385
+ gamma?: number;
386
+ blurStrategy?: BlurStrategy;
387
+ }
388
+ interface MagnitudeAdaptiveOptions extends FieldAdaptiveOptions {
389
+ /** Smooths the raw gradient magnitude before normalizing. Set 0 to skip. Default: 1 */
390
+ smoothingSigma?: number;
391
+ }
392
+ interface VarianceAdaptiveOptions extends FieldAdaptiveOptions {
393
+ /** Neighborhood size used to compute local variance. */
394
+ sigma: number;
395
+ }
396
+
397
+ interface ThresholdStrategy {
398
+ threshold(sharpened: ChannelImage, config: ThresholdConfig): ChannelImage;
399
+ }
400
+ interface ThresholdConfig {
401
+ epsilon: number | ChannelImage;
402
+ phi: number | ChannelImage;
403
+ }
404
+ declare class SoftThresholdStrategy implements ThresholdStrategy {
405
+ threshold(sharpened: ChannelImage, config: ThresholdConfig): ChannelImage;
406
+ }
407
+ /**
408
+ * Hard black/white threshold (step function).
409
+ * Equivalent to phi -> inf in SoftThresholdStrategy, and to ThresholdModes.hard
410
+ * in processor.ts, but expressed as a ThresholdStrategy so it can be plugged
411
+ * into DoGConfig.thresholdStrategy (e.g. as ADoG's default, since the paper's
412
+ * screentone output is binarized rather than soft-thresholded).
413
+ */
414
+ declare class HardThresholdStrategy implements ThresholdStrategy {
415
+ threshold(input: ChannelImage, config: ThresholdConfig): ChannelImage;
416
+ }
417
+ /**
418
+ * Canny-style double-threshold strategy with hysteresis edge linking.
419
+ *
420
+ * Classifies each pixel against a high and low bound derived from `epsilon`
421
+ * (`epsilon + highOffset` and `epsilon - highOffset`... see note below) into
422
+ * strong edge, weak edge, and background tiers then promotes weak
423
+ * edges to strong ones if they are 8-connected to a strong edge via flood fill.
424
+ * This suppresses isolated noise pixels while preserving continuous edge lines
425
+ * that dip briefly below the main threshold, which a single global threshold
426
+ * (e.g. HardThresholdStrategy) cannot do.
427
+ *
428
+ * Note: `phi` from ThresholdConfig is unused by this strategy. Sharpness of
429
+ * the strong/weak/background split is controlled entirely by `highOffset` and
430
+ * `lowOffset`, not by a tanh steepness parameter.
431
+ */
432
+ declare class HysteresisThresholdStrategy implements ThresholdStrategy {
433
+ private readonly highOffset;
434
+ private readonly lowOffset;
435
+ /**
436
+ * @param highOffset - Amount added to `epsilon` to form the high (strong-edge)
437
+ * bound (default: 0.2). Pixels at or above `epsilon + highOffset` are
438
+ * immediately classified as strong edges (seeds for flood fill).
439
+ * @param lowOffset - Amount subtracted from `epsilon` to form the low
440
+ * (weak-edge) bound (default: 0.2). Pixels at or above `epsilon - lowOffset`
441
+ * but below the high bound are classified as weak edges, which only survive
442
+ * in the output if connected to a strong edge.
443
+ */
444
+ constructor(highOffset?: number, lowOffset?: number);
445
+ threshold(sharpened: ChannelImage, config: ThresholdConfig): ChannelImage;
446
+ private floodFill;
447
+ }
448
+
449
+ type threshold_HardThresholdStrategy = HardThresholdStrategy;
450
+ declare const threshold_HardThresholdStrategy: typeof HardThresholdStrategy;
451
+ type threshold_HysteresisThresholdStrategy = HysteresisThresholdStrategy;
452
+ declare const threshold_HysteresisThresholdStrategy: typeof HysteresisThresholdStrategy;
453
+ type threshold_SoftThresholdStrategy = SoftThresholdStrategy;
454
+ declare const threshold_SoftThresholdStrategy: typeof SoftThresholdStrategy;
455
+ type threshold_ThresholdConfig = ThresholdConfig;
456
+ type threshold_ThresholdStrategy = ThresholdStrategy;
457
+ declare namespace threshold {
458
+ export { threshold_HardThresholdStrategy as HardThresholdStrategy, threshold_HysteresisThresholdStrategy as HysteresisThresholdStrategy, threshold_SoftThresholdStrategy as SoftThresholdStrategy };
459
+ export type { threshold_ThresholdConfig as ThresholdConfig, threshold_ThresholdStrategy as ThresholdStrategy };
460
+ }
461
+
462
+ /**
463
+ * Configuration for Difference of Gaussians processing
464
+ *
465
+ * Uses the reparameterized formulation from Section 2.5 of the paper:
466
+ * S_σ,k,p(x) = G_σ(x) + p · D_σ,k(x) = (1 + p) · G_σ(x) - p · G_kσ(x)
467
+ *
468
+ * This decouples edge sharpening strength (p) from threshold parameters,
469
+ * making the filter much easier to control.
470
+ */
471
+ interface DoGConfig {
472
+ /**
473
+ * Base blur sigma for edge detection (default: 1.0)
474
+ * Controls the scale of detected edges - larger values detect coarser edges
475
+ * Paper typically uses 0.4-2.0 for most styles
476
+ */
477
+ sigma: number;
478
+ /**
479
+ * Ratio between the two Gaussian blur sizes (default: 1.6)
480
+ * Paper recommends k = 1.6 as a good engineering trade-off
481
+ * This approximates the Laplacian of Gaussian
482
+ */
483
+ k: number;
484
+ /**
485
+ * Sharpening strength parameter 'p' from Equation 7 (default: 20)
486
+ * Controls the strength of edge emphasis
487
+ * - p ≈ 0: No edge enhancement, just blurred image
488
+ * - p ≈ 20: Strong edges suitable for thresholding (paper's typical value)
489
+ * - p ≈ 100+: Extreme edge emphasis for woodcut style
490
+ *
491
+ * Note: This replaces the original τ parameter. The relationship is:
492
+ * p = τ / (1 - τ), or equivalently τ = p / (p + 1)
493
+ */
494
+ p: number | ChannelImage;
495
+ /**
496
+ * Threshold for white vs black transition (default: 0.5)
497
+ * Values above this become white, values below follow the soft threshold
498
+ * Should be in 0-1 range for normalized images
499
+ * Paper's Appendix A shows values around 0.72-0.88 (normalized from 0-100)
500
+ */
501
+ epsilon: number | ChannelImage;
502
+ /**
503
+ * Sharpness of the soft threshold / tanh steepness (default: 100)
504
+ * Controls the transition sharpness between black and white
505
+ * - φ ≈ 0.01: Very soft transitions (pencil shading, pastel)
506
+ * - φ ≈ 1-10: Moderate transitions
507
+ * - φ >> 10: Hard black/white threshold (approaches step function)
508
+ */
509
+ phi: number | ChannelImage;
510
+ /**
511
+ * Strategy used to convert the sharpened DoG response into the final output image
512
+ *
513
+ * Decouples how thresholding is performed from the edge-detection/sharpening
514
+ * pipeline (sigma, k, p). Allows swapping strategies without touching the rest of the config.
515
+ * Consumes `epsilon` and `phi` from this config as its ThresholdConfig.
516
+ *
517
+ * Built-in strategies (see threshold.ts):
518
+ * - `SoftThresholdStrategy`: tanh-based soft transition, governed by `phi`
519
+ * (steepness) and `epsilon` (midpoint). Produces the smooth pencil/pastel-to-hard-edge
520
+ * range described by `phi` above. This is the paper's standard XDoG threshold.
521
+ * - `HardThresholdStrategy`: binary step function at `epsilon` (ignores `phi`).
522
+ * Equivalent to the φ → ∞ limit of the soft strategy; suited to styles like ADoG
523
+ * that expect a strictly binarized screentone output.
524
+ * - `HysteresisThresholdStrategy`: Canny-style double threshold with flood-fill
525
+ * linking, using `epsilon ± highOffset/lowOffset` as the high/low bounds. Produces
526
+ * cleaner, more connected edge lines than a single global threshold, at the cost
527
+ * of ignoring `phi` and requiring a full-image connectivity pass.
528
+ */
529
+ thresholdStrategy: ThresholdStrategy;
530
+ }
531
+ /**
532
+ * XDoG configuration combining DoG parameters with isotropic blur options
533
+ */
534
+ interface XDoGConfig extends DoGConfig {
535
+ /** Kernel size multiplier for Gaussian blur (default: 6) */
536
+ kernelSizeMultiplier?: number;
537
+ blurStrategy?: BlurStrategy;
538
+ }
539
+ /**
540
+ * Extended configuration for Flow-based DoG (FDoG)
541
+ *
542
+ * FDoG uses three separate sigma parameters as described in Section 2.6:
543
+ */
544
+ interface FDoGConfig extends DoGConfig {
545
+ /**
546
+ * σc: Structure tensor smoothing sigma (default: 2.5)
547
+ * Controls the scale of the edge tangent flow computation
548
+ * - Small values: More noise in flow field, captures fine edges
549
+ * - Large values: Smoother flow, may distort fine features
550
+ */
551
+ sigmaC: number;
552
+ /**
553
+ * σe: Edge detection sigma - same as 'sigma' in base DoGConfig
554
+ * Controls the width of gradient-aligned DoG filter
555
+ * Larger values discard more fine details and result in wider edge lines
556
+ */
557
+ /**
558
+ * σm: Flow-aligned smoothing sigma for line integral convolution (default: 3.0)
559
+ * Controls the coherence of edge lines
560
+ * - Small values: Short, potentially disconnected edges
561
+ * - Large values: Long, coherent edges (may introduce noise if >> σc)
562
+ */
563
+ sigmaM: number;
564
+ /**
565
+ * σa: Anti-aliasing LIC sigma (default: 1.0)
566
+ * Applied as a post-processing step along the ETF
567
+ * - 0: No anti-aliasing
568
+ * - 0.5-2: Typical anti-aliasing
569
+ * - >2: Stylistic smoothing effect
570
+ */
571
+ sigmaA: number;
572
+ /**
573
+ * Number of smoothing iterations applied when computing the Edge Tangent Flow (ETF)
574
+ *
575
+ * The ETF is built iteratively by locally averaging tangent directions with
576
+ * neighboring pixels, progressively refining the flow field so it follows
577
+ * coherent edge structures rather than noisy per-pixel gradients (default: 3)
578
+ * - 0-1: Flow field closely follows raw gradients; noisy, jagged edge directions
579
+ * - 2-4: Typical range; smooth, stable flow suitable for line integral convolution
580
+ * - 5+: Very smooth flow, but expensive and can over-round sharp corners/junctions
581
+ *
582
+ * This directly affects the quality of edges produced during LIC-based smoothing
583
+ * (governed by sigmaM/sigmaA) an under-converged ETF will propagate noise into
584
+ * the final stylized lines regardless of how sigmaM/sigmaA are tuned.
585
+ */
586
+ etfIterations?: number;
587
+ /**
588
+ * Enables confidence-weighted adjustments to p/epsilon/sigmaM/sigmaA,
589
+ * derived from the ETF's per-pixel anisotropy/magnitude (see
590
+ * utils/scalar-field.ts's flowConfidenceField()).
591
+ *
592
+ * Undefined (the default) means fully OFF: this changes output versus
593
+ * flat p/epsilon and costs an extra per-pixel pass on every call, so
594
+ * callers opt in explicitly rather than getting it silently applied --
595
+ * see FDoGConfidenceWeightingConfig for what each sub-option does and its
596
+ * own default once enabled.
597
+ *
598
+ * Pass `{}` to turn everything on at its defaults, or set individual
599
+ * fields to override just one piece; unset fields fall back to
600
+ * DEFAULT_CONFIDENCE_WEIGHTING_CONFIG the same way FDoGConfig itself
601
+ * falls back to DEFAULT_FDOG_CONFIG.
602
+ */
603
+ confidenceWeighting?: Partial<FDoGConfidenceWeightingConfig>;
604
+ }
605
+ /**
606
+ * Sub-options for FDoGConfig.confidenceWeighting. Each field defaults to
607
+ * "on" once the parent `confidenceWeighting` object is present at all --
608
+ * the opt-in gate is having the object, not these individual flags.
609
+ */
610
+ interface FDoGConfidenceWeightingConfig {
611
+ /**
612
+ * Margin added to a flat `epsilon` where flow confidence
613
+ * (anisotropy * normalized magnitude) is low, raising the threshold and
614
+ * suppressing spurious edges in flat/noisy regions. Ignored if
615
+ * `epsilon` is already a ChannelImage -- an explicit map is never
616
+ * overridden. Set to 0 to disable epsilon adaptation specifically while
617
+ * leaving the other confidence-weighted passes on (default: 0.15).
618
+ */
619
+ epsilonMargin: number;
620
+ /**
621
+ * Blend the sigmaM flow-aligned accumulation pass back toward its
622
+ * pre-blur input, weighted by anisotropy, instead of applying it
623
+ * uniformly (default: true).
624
+ */
625
+ sigmaMBlend: boolean;
626
+ /**
627
+ * Blend the sigmaA anti-aliasing pass back toward its pre-blur input,
628
+ * weighted by anisotropy, instead of applying it uniformly
629
+ * (default: true).
630
+ */
631
+ sigmaABlend: boolean;
632
+ /**
633
+ * If `p` is a plain number, scale it per-pixel by normalized ETF
634
+ * magnitude (weak-gradient pixels get less sharpening). Ignored if `p`
635
+ * is already a ChannelImage (default: true).
636
+ */
637
+ pByMagnitude: boolean;
638
+ }
639
+ /**
640
+ * Configuration for Adaptive Difference of Gaussians (ADoG)
641
+ *
642
+ * Based on Section 3.2, Eqs. (3)-(6) of "Gaussian Image Binarization"
643
+ * (Kang & Stamoulis, 2021). ADoG modifies the DoG contrast-sensitivity
644
+ * parameter to be a function of local tone, producing a screentoning effect
645
+ * whose primitive density is inversely proportional to brightness.
646
+ *
647
+ * Note: 'sigma' (inherited from DoGConfig) plays the role of σc, and
648
+ * 'k' plays the role of the σs/σc ratio (σs = k * σc), matching the
649
+ * paper's defaults of σc = 1.0 and σs = 1.6σc.
650
+ */
651
+ interface ADoGConfig extends DoGConfig {
652
+ /**
653
+ * τ: minimum contrast sensitivity (default: 0.99)
654
+ * ρ(x) ranges within [τ, 1]. Higher values produce noisier responses.
655
+ * Paper restricts τ to [0.97, 1.0].
656
+ */
657
+ tau: number;
658
+ /**
659
+ * s: controls the steepness of tone-dependent falloff in ρ(x) (Eq. 5)
660
+ * and in the adaptive noise scale σ(x) (Eq. 6) (default: 2.0)
661
+ * Larger s concentrates the density transition into darker tones.
662
+ */
663
+ s: number;
664
+ /**
665
+ * Adaptive noise scale factor 'c' in Eq. (6) (default: 0.01)
666
+ * Set to 0 to disable noise injection entirely (Eq. 6 is optional --
667
+ * see Fig. 8 in the paper for the effect of enabling it).
668
+ */
669
+ noiseScaleC: number;
670
+ /**
671
+ * Kernel size multiplier for the isotropic Gaussian blur (default: 6)
672
+ * Same meaning as XDoGConfig's kernelSizeMultiplier.
673
+ */
674
+ kernelSizeMultiplier?: number;
675
+ }
676
+ /**
677
+ * Configuration for Hybrid Difference of Gaussians (HDoG)
678
+ *
679
+ * Combines FDoG (line drawing) with two ADoG passes at different scales,
680
+ * per Eq. (9): HDoG = FDoG ∧ ADoG_s ∧ ADoG_s'
681
+ */
682
+ interface HDoGConfig {
683
+ /** Configuration passed to the internal FDoG instance */
684
+ fdog: Partial<FDoGConfig>;
685
+ /**
686
+ * Configuration passed to the primary ADoG instance (uses its own 's').
687
+ * The secondary ADoG pass reuses this config but overrides 's' with
688
+ * s * adogSecondaryScaleFactor (Eq. 9).
689
+ */
690
+ adog: Partial<ADoGConfig>;
691
+ /**
692
+ * s' = adogSecondaryScaleFactor * s, per Eq. (9) (default: 4)
693
+ * Generates additional screentone in the darkest regions without
694
+ * affecting brighter ones (paper empirically sets s' = 4s).
695
+ */
696
+ adogSecondaryScaleFactor: number;
697
+ /**
698
+ * Optional partial override applied on top of the derived secondary
699
+ * ADoG config (primary config + s' = adogSecondaryScaleFactor * s).
700
+ * Use this to tweak individual fields (e.g. epsilon, phi) for the
701
+ * secondary pass without re-specifying the whole config.
702
+ */
703
+ adogSecondary?: Partial<ADoGConfig>;
704
+ }
705
+ /**
706
+ * Preset types. A preset is just a partial config: any field it omits (for
707
+ * example `thresholdStrategy`) falls back to the processor's defaults. Use
708
+ * these to author your own presets with type-checking and autocomplete:
709
+ *
710
+ * const mine = { sigma: 1.1, p: 45, phi: 60, epsilon: 0.7 } satisfies XDoGPreset;
711
+ * new XDoG(mine);
712
+ * XDoG.withPreset(mine, { p: 60 });
713
+ */
714
+ type XDoGPreset = Partial<XDoGConfig>;
715
+ type FDoGPreset = Partial<FDoGConfig>;
716
+ interface DoGProcessingResult {
717
+ /** Final thresholded output */
718
+ result: ChannelImage;
719
+ /** Sharpened image before thresholding */
720
+ sharpened: ChannelImage;
721
+ /** Raw DoG response (blur1 - blur2) */
722
+ rawDoG?: ChannelImage;
723
+ }
724
+ /**
725
+ * Result of HDoG processing.
726
+ *
727
+ * Structurally compatible with DoGProcessingResult (result and sharpened
728
+ * are present), so this satisfies DoGImplementation.processDetailed()'s
729
+ * return type. `sharpened` is set to the FDoG pass's sharpened image as a
730
+ * representative value -- HDoG has no single "sharpened" stage of its own,
731
+ * since it combines three already-binarized outputs. Callers holding a
732
+ * concrete HDoG get the full per-pass breakdown via fdogResult /
733
+ * adogPrimaryResult / adogSecondaryResult.
734
+ */
735
+ interface HDoGProcessingResult extends DoGProcessingResult {
736
+ fdogResult: ChannelImage;
737
+ adogPrimaryResult: ChannelImage;
738
+ adogSecondaryResult: ChannelImage;
739
+ }
740
+ /**
741
+ * Result of ADoG processing, extending the standard DoGProcessingResult
742
+ * with ADoG-specific intermediate artifacts.
743
+ *
744
+ * This is structurally compatible with DoGProcessingResult (result,
745
+ * sharpened, and rawDoG are all present with matching types), so it
746
+ * satisfies DoGImplementation.processDetailed()'s return type. Callers
747
+ * holding a concrete ADoG (rather than the generic DoGImplementation
748
+ * interface) additionally get rhoMap and noisyInput; nothing is lost, it's
749
+ * just not visible through the narrower interface type.
750
+ *
751
+ * Field mapping vs. XDoG/FDoG's use of "sharpened"/"rawDoG":
752
+ * - rawDoG: the UNWEIGHTED response G_σc - G_σs (ρ ≡ 1), i.e. standard
753
+ * DoG -- this is what Fig. 7(b) in the paper compares against.
754
+ * - sharpened: the ρ(x)-WEIGHTED response (Eq. 4), pre-threshold. It's
755
+ * not an unsharp-mask "sharpened" image the way XDoG uses the term,
756
+ * but it plays the same structural role (pre-threshold DoG response).
757
+ */
758
+ interface ADoGProcessingResult extends DoGProcessingResult {
759
+ /** Per-pixel adaptive contrast sensitivity ρ(x), Eq. (5) */
760
+ rhoMap: ChannelImage;
761
+ /** Input after adaptive noise injection (Eq. 6), or the original input if noiseScaleC === 0 */
762
+ noisyInput: ChannelImage;
763
+ }
764
+ /**
765
+ * Interface for DoG processors (XDoG, FDoG, ADoG, or HDoG)
766
+ */
767
+ interface DoGImplementation {
768
+ process(input: ChannelImage, overrides?: Partial<DoGConfig>): Promise<ChannelImage>;
769
+ /** Process and return all intermediate results (avoids redundant blur operations) */
770
+ processDetailed(input: ChannelImage, overrides?: Partial<DoGConfig>): Promise<DoGProcessingResult>;
771
+ dispose(): void;
772
+ }
773
+ interface ParamRange {
774
+ hardMin: number;
775
+ hardMax: number;
776
+ recommendedMin: number;
777
+ recommendedMax: number;
778
+ default: number;
779
+ step: number;
780
+ }
781
+ type DogConfigParamType = 'sigma' | 'k' | 'p' | 'epsilon' | 'phi';
782
+ /**
783
+ * Base DoG / XDoG parameter ranges.
784
+ *
785
+ * Recommended ranges follow the span of settings in Table A.1 of
786
+ * Winnemöller et al., "XDoG: An eXtended difference-of-Gaussians
787
+ * compendium" (Computers & Graphics 36(6), 2012), which is the reference
788
+ * for the reparameterized (σ, k, p, φ, ε) formulation used here. In that
789
+ * table p ranges 15.7–120, φ ranges 0.01–10.3 (with φ >> 0.01 pushing the
790
+ * soft tanh ramp toward a step function — Sec. 4.1), and ε ranges 72.6–100
791
+ * on the paper's 0–100 luminance scale, i.e. ~0.73–1.0 once normalized.
792
+ * σe (== `sigma` here) ranges 0.8–6.8 across natural-media styles.
793
+ * k = 1.6 is Marr & Hildreth's engineering trade-off (Sec. 2.3).
794
+ */
795
+ declare const DOG_PARAM_RANGES: Record<DogConfigParamType, ParamRange>;
796
+ type XDogConfigParamType = 'kernelSizeMultiplier';
797
+ /**
798
+ * XDoG-specific parameter ranges (on top of DOG_PARAM_RANGES).
799
+ *
800
+ * kernelSizeMultiplier is the Gaussian truncation radius as a multiple of
801
+ * σ. Winnemöller samples the Gaussian out to ~2σ for the DoG passes
802
+ * (Appendix A/B), but a wider window (≈6σ) captures the tail more fully;
803
+ * 3σ covers ~99.7% and is the practical floor for a clean kernel.
804
+ */
805
+ declare const XDOG_PARAM_RANGES: Record<DogConfigParamType | XDogConfigParamType, ParamRange>;
806
+ /**
807
+ * FDoG-specific parameter ranges (on top of DOG_PARAM_RANGES).
808
+ *
809
+ * Ranges follow Table A.1: σc 0.10–5.84, σm 3.2–20, σa 0.6–7.2. σe is the
810
+ * base `sigma` and keeps its DOG_PARAM_RANGES entry. Defaults track the
811
+ * paper's more conservative line-drawing settings rather than the extreme
812
+ * pastel/woodcut ends of the table.
813
+ */
814
+ type FDogConfigParamType = 'sigmaC' | 'sigmaM' | 'sigmaA';
815
+ declare const FDOG_PARAM_RANGES: Record<DogConfigParamType | FDogConfigParamType, ParamRange>;
816
+ type FDogConfidenceWeightConfigParamType = 'epsilonMargin';
817
+ declare const FDOG_CONFIDENCE_WEIGHT_PARAM_RANGES: Record<FDogConfidenceWeightConfigParamType, ParamRange>;
818
+ /**
819
+ * ADoG parameter ranges.
820
+ *
821
+ * ADoG overrides several base ranges to match its own operating regime
822
+ * (Gaussian Image Binarization, Sec. 3.2):
823
+ * - k: fixed by σs = 1.6σc, so the recommended band tightens to 1.6.
824
+ * - epsilon/phi: ADoG binarizes with a HARD threshold, so ε sits low
825
+ * (screentone primitives are dark-on-white) and φ is driven high to
826
+ * approximate a step function. These differ from the base DoG ranges,
827
+ * which are tuned for XDoG's soft tone-mapping.
828
+ * - tau, s, noiseScaleC: ADoG's own contrast-sensitivity and noise knobs.
829
+ */
830
+ type ADogConfigParamType = 'tau' | 's' | 'noiseScaleC' | 'kernelSizeMultiplier';
831
+ declare const ADOG_PARAM_RANGES: Record<DogConfigParamType | ADogConfigParamType, ParamRange>;
832
+ type HDogConfigParamType = ADogConfigParamType | 'adogSecondaryScaleFactor';
833
+ /** HDoG shares ADoG's parameter regime (its screentone passes are ADoG). */
834
+ declare const HDOG_PARAM_RANGES: Record<DogConfigParamType | HDogConfigParamType, ParamRange>;
835
+ /**
836
+ * Default DoG configuration values
837
+ * Based on paper's recommendations and Appendix A parameter ranges
838
+ */
839
+ declare const DEFAULT_DOG_CONFIG: DoGConfig;
840
+ declare const DEFAULT_XDOG_CONFIG: DoGConfig;
841
+ /**
842
+ * Default FDoG configuration values
843
+ * Based on Table A.1 in the paper
844
+ */
845
+ declare const DEFAULT_FDOG_CONFIG: FDoGConfig;
846
+ /**
847
+ * Default ADoG configuration values
848
+ * Based on Section 3.2 of "Gaussian Image Binarization"
849
+ * (σc = 1.0, σs = 1.6σc, τ = 0.99, s = 2.0, noise c = 0.01)
850
+ */
851
+ declare const DEFAULT_ADOG_CONFIG: ADoGConfig;
852
+ /**
853
+ * Default HDoG configuration values
854
+ * s' defaults to 4s per the paper's empirical setting (Eq. 9)
855
+ */
856
+ declare const DEFAULT_HDOG_CONFIG: HDoGConfig;
857
+ /**
858
+ * Preset configurations for common styles from the paper
859
+ */
860
+ declare const STYLE_PRESETS: {
861
+ /**
862
+ * Pencil shading style (Figure 1b, Section 5.2)
863
+ * High-frequency detail resembling graphite on paper
864
+ */
865
+ pencilShading: {
866
+ sigma: number;
867
+ k: number;
868
+ p: number;
869
+ epsilon: number;
870
+ phi: number;
871
+ };
872
+ /**
873
+ * Pastel style (Figure 18b, Section 5.2)
874
+ * Intermediate edge width with flow turbulence
875
+ */
876
+ pastel: {
877
+ sigma: number;
878
+ k: number;
879
+ p: number;
880
+ epsilon: number;
881
+ phi: number;
882
+ };
883
+ /**
884
+ * Charcoal style (Figure 18c, Section 5.2)
885
+ * Broad strokes from large spatial support
886
+ */
887
+ charcoal: {
888
+ sigma: number;
889
+ k: number;
890
+ p: number;
891
+ epsilon: number;
892
+ phi: number;
893
+ };
894
+ /**
895
+ * Thresholding / line art (Section 4.1)
896
+ * Clean black and white edges
897
+ */
898
+ threshold: {
899
+ sigma: number;
900
+ k: number;
901
+ p: number;
902
+ epsilon: number;
903
+ phi: number;
904
+ };
905
+ /**
906
+ * Woodcut style (Section 4.2, Figure 15)
907
+ * Aggressive flow distortion with extreme edge emphasis
908
+ */
909
+ woodcut: {
910
+ sigma: number;
911
+ k: number;
912
+ p: number;
913
+ epsilon: number;
914
+ phi: number;
915
+ };
916
+ };
917
+ /** Names of the built-in XDoG presets, for `XDoG.withPreset()`. */
918
+ type StylePresetName = keyof typeof STYLE_PRESETS;
919
+ /**
920
+ * Preset FDoG configurations including flow parameters
921
+ */
922
+ declare const FDOG_STYLE_PRESETS: {
923
+ /**
924
+ * Standard FDoG for coherent line drawing (Figure 2g)
925
+ */
926
+ standard: {
927
+ sigmaC: number;
928
+ sigmaM: number;
929
+ sigmaA: number;
930
+ sigma: number;
931
+ k: number;
932
+ p: number;
933
+ epsilon: number;
934
+ phi: number;
935
+ };
936
+ /**
937
+ * Pastel with flow (Figure 18b)
938
+ */
939
+ pastel: {
940
+ sigmaC: number;
941
+ sigmaM: number;
942
+ sigmaA: number;
943
+ sigma: number;
944
+ k: number;
945
+ p: number;
946
+ epsilon: number;
947
+ phi: number;
948
+ };
949
+ /**
950
+ * Woodcut with aggressive flow (Figure 15)
951
+ */
952
+ woodcut: {
953
+ sigmaC: number;
954
+ sigmaM: number;
955
+ sigmaA: number;
956
+ sigma: number;
957
+ k: number;
958
+ p: number;
959
+ epsilon: number;
960
+ phi: number;
961
+ };
962
+ };
963
+ /** Names of the built-in FDoG presets, for `FDoG.withPreset()`. */
964
+ type FDoGPresetName = keyof typeof FDOG_STYLE_PRESETS;
965
+ /**
966
+ * Preset ADoG configurations
967
+ * (No presets given directly in the paper's tables beyond the defaults
968
+ * above; add named presets here as you tune them, e.g. denser/lighter
969
+ * screentone variants.)
970
+ */
971
+ declare const ADOG_STYLE_PRESETS: {
972
+ standard: {
973
+ /**
974
+ * τ: minimum contrast sensitivity (default: 0.99)
975
+ * ρ(x) ranges within [τ, 1]. Higher values produce noisier responses.
976
+ * Paper restricts τ to [0.97, 1.0].
977
+ */
978
+ tau: number;
979
+ /**
980
+ * s: controls the steepness of tone-dependent falloff in ρ(x) (Eq. 5)
981
+ * and in the adaptive noise scale σ(x) (Eq. 6) (default: 2.0)
982
+ * Larger s concentrates the density transition into darker tones.
983
+ */
984
+ s: number;
985
+ /**
986
+ * Adaptive noise scale factor 'c' in Eq. (6) (default: 0.01)
987
+ * Set to 0 to disable noise injection entirely (Eq. 6 is optional --
988
+ * see Fig. 8 in the paper for the effect of enabling it).
989
+ */
990
+ noiseScaleC: number;
991
+ /**
992
+ * Kernel size multiplier for the isotropic Gaussian blur (default: 6)
993
+ * Same meaning as XDoGConfig's kernelSizeMultiplier.
994
+ */
995
+ kernelSizeMultiplier?: number;
996
+ /**
997
+ * Base blur sigma for edge detection (default: 1.0)
998
+ * Controls the scale of detected edges - larger values detect coarser edges
999
+ * Paper typically uses 0.4-2.0 for most styles
1000
+ */
1001
+ sigma: number;
1002
+ /**
1003
+ * Ratio between the two Gaussian blur sizes (default: 1.6)
1004
+ * Paper recommends k = 1.6 as a good engineering trade-off
1005
+ * This approximates the Laplacian of Gaussian
1006
+ */
1007
+ k: number;
1008
+ /**
1009
+ * Sharpening strength parameter 'p' from Equation 7 (default: 20)
1010
+ * Controls the strength of edge emphasis
1011
+ * - p ≈ 0: No edge enhancement, just blurred image
1012
+ * - p ≈ 20: Strong edges suitable for thresholding (paper's typical value)
1013
+ * - p ≈ 100+: Extreme edge emphasis for woodcut style
1014
+ *
1015
+ * Note: This replaces the original τ parameter. The relationship is:
1016
+ * p = τ / (1 - τ), or equivalently τ = p / (p + 1)
1017
+ */
1018
+ p: number | ChannelImage;
1019
+ /**
1020
+ * Threshold for white vs black transition (default: 0.5)
1021
+ * Values above this become white, values below follow the soft threshold
1022
+ * Should be in 0-1 range for normalized images
1023
+ * Paper's Appendix A shows values around 0.72-0.88 (normalized from 0-100)
1024
+ */
1025
+ epsilon: number | ChannelImage;
1026
+ /**
1027
+ * Sharpness of the soft threshold / tanh steepness (default: 100)
1028
+ * Controls the transition sharpness between black and white
1029
+ * - φ ≈ 0.01: Very soft transitions (pencil shading, pastel)
1030
+ * - φ ≈ 1-10: Moderate transitions
1031
+ * - φ >> 10: Hard black/white threshold (approaches step function)
1032
+ */
1033
+ phi: number | ChannelImage;
1034
+ /**
1035
+ * Strategy used to convert the sharpened DoG response into the final output image
1036
+ *
1037
+ * Decouples how thresholding is performed from the edge-detection/sharpening
1038
+ * pipeline (sigma, k, p). Allows swapping strategies without touching the rest of the config.
1039
+ * Consumes `epsilon` and `phi` from this config as its ThresholdConfig.
1040
+ *
1041
+ * Built-in strategies (see threshold.ts):
1042
+ * - `SoftThresholdStrategy`: tanh-based soft transition, governed by `phi`
1043
+ * (steepness) and `epsilon` (midpoint). Produces the smooth pencil/pastel-to-hard-edge
1044
+ * range described by `phi` above. This is the paper's standard XDoG threshold.
1045
+ * - `HardThresholdStrategy`: binary step function at `epsilon` (ignores `phi`).
1046
+ * Equivalent to the φ → ∞ limit of the soft strategy; suited to styles like ADoG
1047
+ * that expect a strictly binarized screentone output.
1048
+ * - `HysteresisThresholdStrategy`: Canny-style double threshold with flood-fill
1049
+ * linking, using `epsilon ± highOffset/lowOffset` as the high/low bounds. Produces
1050
+ * cleaner, more connected edge lines than a single global threshold, at the cost
1051
+ * of ignoring `phi` and requiring a full-image connectivity pass.
1052
+ */
1053
+ thresholdStrategy: ThresholdStrategy;
1054
+ };
1055
+ };
1056
+ declare const HDOG_STYLE_PRESETS: {
1057
+ /**
1058
+ * Paper defaults (Sec. 3.1–3.3): σc=1.0, k=1.6 (σs=1.6σc), σm=3.0,
1059
+ * σa≈1.0 (not explicitly stated as a default in the paper's FDoG
1060
+ * section, so this uses a light anti-aliasing value), τ=0.99, s=2.0,
1061
+ * noiseScaleC=0.01, s'=4s. This is the closest match to Figs. 13–14.
1062
+ */
1063
+ default: {
1064
+ fdog: FDoGConfig;
1065
+ adog: ADoGConfig;
1066
+ adogSecondaryScaleFactor: number;
1067
+ };
1068
+ };
1069
+
1070
+ /**
1071
+ * High-level XDoG implementation
1072
+ *
1073
+ * This class provides a convenient wrapper that compose the blur strategies
1074
+ * and DoG processor together.
1075
+ *
1076
+ * Based on: "XDoG: An eXtended difference-of-Gaussians compendium including
1077
+ * advanced image stylization" by Winnemöller et al. (2012)
1078
+ */
1079
+
1080
+ /**
1081
+ * XDoG (Extended Difference of Gaussians)
1082
+ *
1083
+ * Uses standard isotropic Gaussian blur for edge detection and stylization.
1084
+ * Good for general-purpose edge detection and artistic effects.
1085
+ *
1086
+ * This implements the reparameterized XDoG from Section 2.5 of the paper,
1087
+ * using Equation 7 for the sharpening computation.
1088
+ */
1089
+ declare class XDoG implements DoGImplementation {
1090
+ private config;
1091
+ private dogConfig;
1092
+ private blurStrategyPromise;
1093
+ constructor(config?: Partial<XDoGConfig>);
1094
+ dispose(): void;
1095
+ /**
1096
+ * Create XDoG with a preset style
1097
+ */
1098
+ static withPreset(preset: StylePresetName | XDoGPreset, overrides?: XDoGPreset): XDoG;
1099
+ private getProcessor;
1100
+ /**
1101
+ * Process a grayscale image
1102
+ */
1103
+ process(input: ChannelImage, overrides?: Partial<DoGConfig>): Promise<ChannelImage>;
1104
+ /**
1105
+ * Process without thresholding (returns sharpened image)
1106
+ */
1107
+ processSharpened(input: ChannelImage, overrides?: Partial<DoGConfig>): Promise<ChannelImage>;
1108
+ /**
1109
+ * Get raw DoG response for visualization
1110
+ */
1111
+ processRawDoG(input: ChannelImage, overrides?: Partial<DoGConfig>): Promise<ChannelImage>;
1112
+ /**
1113
+ * Process and return all intermediate results
1114
+ *
1115
+ * This is more efficient than calling process(), processSharpened(), and
1116
+ * processRawDoG() separately as it only performs the blur operations once.
1117
+ *
1118
+ * Useful for:
1119
+ * - Hatching strategies that need the sharpened image
1120
+ * - Debugging and visualization
1121
+ * - Custom post-processing pipelines
1122
+ */
1123
+ processDetailed(input: ChannelImage, overrides?: Partial<DoGConfig>): Promise<DoGProcessingResult>;
1124
+ /**
1125
+ * Convenience method to process ImageData directly (e.g., from a canvas)
1126
+ */
1127
+ processGrayscaleImageData(input: ImageData, overrides?: Partial<DoGConfig>): Promise<ImageData>;
1128
+ /**
1129
+ * Get current configuration.
1130
+ */
1131
+ getConfig(): Readonly<XDoGConfig>;
1132
+ setConfig(config: Partial<XDoGConfig>): void;
1133
+ }
1134
+ /**
1135
+ * Convenience function for one-shot XDoG processing
1136
+ */
1137
+ declare function xdog(input: ChannelImage, config?: Partial<XDoGConfig>): Promise<ChannelImage>;
1138
+
1139
+ /**
1140
+ * High-level FDoG implementation
1141
+ *
1142
+ * This class provides a convenient wrapper that compose the blur strategies
1143
+ * and DoG processor together.
1144
+ *
1145
+ * Based on: "XDoG: An eXtended difference-of-Gaussians compendium including
1146
+ * advanced image stylization" by Winnemöller et al. (2012)
1147
+ */
1148
+
1149
+ /**
1150
+ * FDoG (Flow-based Difference of Gaussians)
1151
+ *
1152
+ * Uses flow-guided blur along edge tangent directions for coherent line drawing.
1153
+ * Produces smoother, more artistic results similar to hand-drawn illustrations.
1154
+ *
1155
+ * This implements the full FDoG pipeline from Section 2.6:
1156
+ * 1. Compute Edge Tangent Flow (ETF) from structure tensor
1157
+ * 2. Apply gradient-aligned DoG (across edges)
1158
+ * 3. Apply flow-aligned smoothing (along edges)
1159
+ * 4. Apply soft thresholding
1160
+ * 5. Optional: Apply anti-aliasing LIC pass
1161
+ *
1162
+ * Parameters:
1163
+ * - sigmaC: Structure tensor smoothing (controls ETF smoothness)
1164
+ * - sigmaE: Edge detection sigma (controls edge width)
1165
+ * - sigmaM: Flow-aligned smoothing (controls line coherence)
1166
+ * - sigmaA: Anti-aliasing sigma (optional post-processing)
1167
+ */
1168
+ declare class FDoG implements DoGImplementation {
1169
+ private config;
1170
+ constructor(config?: Partial<FDoGConfig>);
1171
+ dispose(): void;
1172
+ static withPreset(preset: FDoGPresetName | FDoGPreset, overrides?: FDoGPreset): FDoG;
1173
+ /**
1174
+ * Process a grayscale image
1175
+ *
1176
+ * Unlike XDoG, FDoG computes a new flow field for each image,
1177
+ * so the full pipeline runs fresh each time.
1178
+ */
1179
+ process(input: ChannelImage, overrides?: Partial<FDoGConfig>): Promise<ChannelImage>;
1180
+ /**
1181
+ * Process with more control over individual stages
1182
+ */
1183
+ processDetailed(input: ChannelImage, overrides?: Partial<FDoGConfig>): Promise<{
1184
+ result: ChannelImage;
1185
+ etf: FlowField;
1186
+ sharpened: ChannelImage;
1187
+ thresholded: ChannelImage;
1188
+ smoothed: ChannelImage;
1189
+ }>;
1190
+ /**
1191
+ * Convenience method to process ImageData directly
1192
+ */
1193
+ processGrayscaleImageData(input: ImageData, overrides?: Partial<FDoGConfig>): Promise<ImageData>;
1194
+ /**
1195
+ * Process with a pre-computed ETF
1196
+ *
1197
+ * Useful when processing multiple frames of video where the ETF
1198
+ * can be computed once and reused, or interpolated between keyframes.
1199
+ */
1200
+ processWithETF(input: ChannelImage, etf: FlowField, overrides?: Partial<FDoGConfig>): Promise<ChannelImage>;
1201
+ /**
1202
+ * Apply only the anti-aliasing pass to an already-processed image
1203
+ */
1204
+ applyAntiAliasing(input: ChannelImage, etf: FlowField, sigmaA?: number): Promise<ChannelImage>;
1205
+ /**
1206
+ * Get current configuration
1207
+ */
1208
+ getConfig(): Readonly<FDoGConfig>;
1209
+ /**
1210
+ * Update configuration
1211
+ */
1212
+ setConfig(config: Partial<FDoGConfig>): void;
1213
+ }
1214
+ /**
1215
+ * Convenience function for one-shot FDoG processing
1216
+ */
1217
+ declare function fdog(input: ChannelImage, config?: Partial<FDoGConfig>): Promise<ChannelImage>;
1218
+
1219
+ /**
1220
+ * High-level ADog implementations
1221
+ *
1222
+ * These classes provide convenient wrappers that compose the blur strategies
1223
+ * and DoG processor together.
1224
+ */
1225
+
1226
+ declare class ADoG implements DoGImplementation {
1227
+ private config;
1228
+ private blurStrategy;
1229
+ constructor(config?: Partial<ADoGConfig>);
1230
+ dispose(): void;
1231
+ /**
1232
+ * Analytical epsilon ceiling for a given tau: beyond this, no flat
1233
+ * region (however bright) can cross threshold, and the output floods
1234
+ * to solid black regardless of image content. Pure function of tau,
1235
+ * so it's sync and doesn't need an input image or a processor instance.
1236
+ */
1237
+ static getEpsilonCeiling(tau: number): number;
1238
+ /**
1239
+ * Runs the pipeline once and returns mean/std of the pre-threshold
1240
+ * sharpened response, plus the tau-derived ceiling. Shared by
1241
+ * estimateEpsilon() and getEpsilonRange() so they don't each pay for
1242
+ * their own processDetailed() pass.
1243
+ */
1244
+ private static computeEpsilonStats;
1245
+ /**
1246
+ * Recommended [min, max] band for the epsilon slider, plus a sensible
1247
+ * default, derived from the actual image + config rather than the
1248
+ * static ADOG_PARAM_RANGES.epsilon entry (which can't account for
1249
+ * tau/s/noiseScaleC/image content).
1250
+ */
1251
+ static getEpsilonRange(input: ChannelImage, config?: Partial<ADoGConfig>, spread?: number): Promise<ParamRange>;
1252
+ /** Existing method, now built on computeEpsilonStats. */
1253
+ static estimateEpsilon(input: ChannelImage, config?: Partial<ADoGConfig>, biasOffset?: number): Promise<number>;
1254
+ /**
1255
+ * Analytical epsilon ceiling for a given tau: beyond this, no flat
1256
+ * region (however bright) can cross threshold, and the output floods
1257
+ * to solid black regardless of image content. Pure function of tau,
1258
+ * so it's sync and doesn't need an input image or a processor instance.
1259
+ */
1260
+ static getEpsilonMax(tau: number): number;
1261
+ static estimateSigma(input: ChannelImage, { referenceDimension, baseSigma }?: {
1262
+ referenceDimension?: number;
1263
+ baseSigma?: number;
1264
+ }): number;
1265
+ /**
1266
+ * Process a grayscale image through the ADoG pipeline.
1267
+ */
1268
+ process(input: ChannelImage, overrides?: Partial<ADoGConfig>): Promise<ChannelImage>;
1269
+ processDetailed(input: ChannelImage, overrides?: Partial<ADoGConfig>): Promise<ADoGProcessingResult>;
1270
+ /**
1271
+ * Convenience method to process ImageData directly (e.g., from a canvas),
1272
+ * matching XDoG/FDoG's convenience method of the same name.
1273
+ */
1274
+ processGrayscaleImageData(input: ImageData, overrides?: Partial<ADoGConfig>): Promise<ImageData>;
1275
+ /**
1276
+ * Get current configuration
1277
+ */
1278
+ getConfig(): Readonly<ADoGConfig>;
1279
+ /**
1280
+ * Update configuration
1281
+ */
1282
+ setConfig(config: Partial<ADoGConfig>): Promise<void>;
1283
+ /** Eq. (5): rho(x) = tau + (1 - tau) * (1 - tanh(s * I(x))) */
1284
+ private computeRhoMap;
1285
+ /** Eq. (6): sigma(x) = c * (1 - tanh(s * I(x))); sampled noise ~ N(0,1) * sigma(x) added to I(x) */
1286
+ private injectAdaptiveNoise;
1287
+ /** Eq. (3)/(4): ADoG(x) = G_sigmaC(x) - rho(x) * G_sigmaS(x) */
1288
+ private computeWeightedDoG;
1289
+ /** Standard (non-adaptive) DoG: G_sigmaC(x) - G_sigmaS(x), i.e. rho == 1 everywhere */
1290
+ private computeUnweightedDoG;
1291
+ }
1292
+ /**
1293
+ * Convenience function for one-shot ADoG processing, matching xdog()/fdog()
1294
+ * in dog.ts
1295
+ */
1296
+ declare function adog(input: ChannelImage, config?: Partial<ADoGConfig>): Promise<ChannelImage>;
1297
+
1298
+ /**
1299
+ * High-level HDoG implementations
1300
+ *
1301
+ * This class provides a convenient wrapper that compose the blur strategies
1302
+ * and DoG processor together.
1303
+ */
1304
+
1305
+ declare class HDoG implements DoGImplementation {
1306
+ private fdog;
1307
+ private adogPrimary;
1308
+ private adogSecondary;
1309
+ constructor(config?: Partial<HDoGConfig>);
1310
+ dispose(): void;
1311
+ /**
1312
+ * Eq. (9): HDoG = FDoG ∧ ADoG_s ∧ ADoG_s'
1313
+ *
1314
+ * Note: HDoG's own configuration (fdog/adog/adogSecondaryScaleFactor) is
1315
+ * nested rather than a flat DoGConfig, so per-call overrides aren't
1316
+ * exposed here the way XDoG/FDoG/ADoG expose them -- there's no clean way
1317
+ * to map a flat Partial<DoGConfig> onto "override the nested fdog config,
1318
+ * or the nested adog config, or the scale factor". Configure via the
1319
+ * constructor; if you need per-call tuning, consider adding a dedicated
1320
+ * method (e.g. processWithConfig(input, HDoGConfig overrides)) rather than
1321
+ * overloading `process`.
1322
+ */
1323
+ process(input: ChannelImage): Promise<ChannelImage>;
1324
+ processDetailed(input: ChannelImage): Promise<HDoGProcessingResult>;
1325
+ /**
1326
+ * Convenience method to process ImageData directly (e.g., from a canvas)
1327
+ */
1328
+ processGrayscaleImageData(input: ImageData): Promise<ImageData>;
1329
+ }
1330
+ /**
1331
+ * Convenience function for one-shot HDoG processing, matching xdog()/fdog()
1332
+ * in dog.ts and adog() in adog.ts
1333
+ */
1334
+ declare function hdog(input: ChannelImage, config?: Partial<HDoGConfig>): Promise<ChannelImage>;
1335
+
1336
+ declare const index$7_ADOG_PARAM_RANGES: typeof ADOG_PARAM_RANGES;
1337
+ declare const index$7_ADOG_STYLE_PRESETS: typeof ADOG_STYLE_PRESETS;
1338
+ type index$7_ADoG = ADoG;
1339
+ declare const index$7_ADoG: typeof ADoG;
1340
+ type index$7_ADoGConfig = ADoGConfig;
1341
+ type index$7_ADoGProcessingResult = ADoGProcessingResult;
1342
+ type index$7_ADogConfigParamType = ADogConfigParamType;
1343
+ declare const index$7_DEFAULT_ADOG_CONFIG: typeof DEFAULT_ADOG_CONFIG;
1344
+ declare const index$7_DEFAULT_DOG_CONFIG: typeof DEFAULT_DOG_CONFIG;
1345
+ declare const index$7_DEFAULT_FDOG_CONFIG: typeof DEFAULT_FDOG_CONFIG;
1346
+ declare const index$7_DEFAULT_HDOG_CONFIG: typeof DEFAULT_HDOG_CONFIG;
1347
+ declare const index$7_DEFAULT_XDOG_CONFIG: typeof DEFAULT_XDOG_CONFIG;
1348
+ declare const index$7_DOG_PARAM_RANGES: typeof DOG_PARAM_RANGES;
1349
+ type index$7_DoGConfig = DoGConfig;
1350
+ type index$7_DoGImplementation = DoGImplementation;
1351
+ type index$7_DogConfigParamType = DogConfigParamType;
1352
+ declare const index$7_FDOG_CONFIDENCE_WEIGHT_PARAM_RANGES: typeof FDOG_CONFIDENCE_WEIGHT_PARAM_RANGES;
1353
+ declare const index$7_FDOG_PARAM_RANGES: typeof FDOG_PARAM_RANGES;
1354
+ declare const index$7_FDOG_STYLE_PRESETS: typeof FDOG_STYLE_PRESETS;
1355
+ type index$7_FDoG = FDoG;
1356
+ declare const index$7_FDoG: typeof FDoG;
1357
+ type index$7_FDoGConfidenceWeightingConfig = FDoGConfidenceWeightingConfig;
1358
+ type index$7_FDoGConfig = FDoGConfig;
1359
+ type index$7_FDogConfidenceWeightConfigParamType = FDogConfidenceWeightConfigParamType;
1360
+ type index$7_FDogConfigParamType = FDogConfigParamType;
1361
+ declare const index$7_HDOG_PARAM_RANGES: typeof HDOG_PARAM_RANGES;
1362
+ declare const index$7_HDOG_STYLE_PRESETS: typeof HDOG_STYLE_PRESETS;
1363
+ type index$7_HDoG = HDoG;
1364
+ declare const index$7_HDoG: typeof HDoG;
1365
+ type index$7_HDoGConfig = HDoGConfig;
1366
+ type index$7_HDoGProcessingResult = HDoGProcessingResult;
1367
+ type index$7_HDogConfigParamType = HDogConfigParamType;
1368
+ type index$7_ParamRange = ParamRange;
1369
+ declare const index$7_STYLE_PRESETS: typeof STYLE_PRESETS;
1370
+ declare const index$7_XDOG_PARAM_RANGES: typeof XDOG_PARAM_RANGES;
1371
+ type index$7_XDoG = XDoG;
1372
+ declare const index$7_XDoG: typeof XDoG;
1373
+ type index$7_XDoGConfig = XDoGConfig;
1374
+ type index$7_XDogConfigParamType = XDogConfigParamType;
1375
+ declare const index$7_adog: typeof adog;
1376
+ declare const index$7_fdog: typeof fdog;
1377
+ declare const index$7_hdog: typeof hdog;
1378
+ declare const index$7_xdog: typeof xdog;
1379
+ declare namespace index$7 {
1380
+ export { index$7_ADOG_PARAM_RANGES as ADOG_PARAM_RANGES, index$7_ADOG_STYLE_PRESETS as ADOG_STYLE_PRESETS, index$7_ADoG as ADoG, index$7_DEFAULT_ADOG_CONFIG as DEFAULT_ADOG_CONFIG, index$7_DEFAULT_DOG_CONFIG as DEFAULT_DOG_CONFIG, index$7_DEFAULT_FDOG_CONFIG as DEFAULT_FDOG_CONFIG, index$7_DEFAULT_HDOG_CONFIG as DEFAULT_HDOG_CONFIG, index$7_DEFAULT_XDOG_CONFIG as DEFAULT_XDOG_CONFIG, index$7_DOG_PARAM_RANGES as DOG_PARAM_RANGES, index$7_FDOG_CONFIDENCE_WEIGHT_PARAM_RANGES as FDOG_CONFIDENCE_WEIGHT_PARAM_RANGES, index$7_FDOG_PARAM_RANGES as FDOG_PARAM_RANGES, index$7_FDOG_STYLE_PRESETS as FDOG_STYLE_PRESETS, index$7_FDoG as FDoG, index$7_HDOG_PARAM_RANGES as HDOG_PARAM_RANGES, index$7_HDOG_STYLE_PRESETS as HDOG_STYLE_PRESETS, index$7_HDoG as HDoG, index$7_STYLE_PRESETS as STYLE_PRESETS, index$7_XDOG_PARAM_RANGES as XDOG_PARAM_RANGES, index$7_XDoG as XDoG, index$7_adog as adog, index$7_fdog as fdog, index$7_hdog as hdog, index$7_xdog as xdog };
1381
+ export type { index$7_ADoGConfig as ADoGConfig, index$7_ADoGProcessingResult as ADoGProcessingResult, index$7_ADogConfigParamType as ADogConfigParamType, index$7_DoGConfig as DoGConfig, index$7_DoGImplementation as DoGImplementation, index$7_DogConfigParamType as DogConfigParamType, index$7_FDoGConfidenceWeightingConfig as FDoGConfidenceWeightingConfig, index$7_FDoGConfig as FDoGConfig, index$7_FDogConfidenceWeightConfigParamType as FDogConfidenceWeightConfigParamType, index$7_FDogConfigParamType as FDogConfigParamType, index$7_HDoGConfig as HDoGConfig, index$7_HDoGProcessingResult as HDoGProcessingResult, index$7_HDogConfigParamType as HDogConfigParamType, index$7_ParamRange as ParamRange, index$7_XDoGConfig as XDoGConfig, index$7_XDogConfigParamType as XDogConfigParamType };
1382
+ }
1383
+
1384
+ /**
1385
+ * Difference of Gaussians processor
1386
+ *
1387
+ * This is the core processor that can be used for both XDoG (with IsotropicBlur)
1388
+ * and FDoG (with FlowGuidedBlur).
1389
+ *
1390
+ * Implements the reparameterized formulation from Section 2.5 of:
1391
+ * "XDoG: An eXtended difference-of-Gaussians compendium including
1392
+ * advanced image stylization" by Winnemoller et al. (2012)
1393
+ */
1394
+
1395
+ /**
1396
+ * Difference of Gaussians processor
1397
+ *
1398
+ * Uses the reparameterized formulation (Equation 7):
1399
+ * S_sigma,k,p(x) = G_sigma(x) + p x D_sigma,k(x) = (1 + p) x G_sigma(x) - p x G_ksigma(x)
1400
+ *
1401
+ * This is equivalent to unsharp masking of the blurred image, which
1402
+ * decouples edge sharpening strength (p) from threshold parameters.
1403
+ *
1404
+ * The blur strategy can be swapped to get different effects:
1405
+ * - IsotropicBlur: Standard XDoG with uniform blur
1406
+ * - FlowGuidedBlur: FDoG with edge-coherent blur
1407
+ * - GradientAlignedBlur: Blur across edges only
1408
+ */
1409
+ declare class DoGProcessor {
1410
+ private config;
1411
+ private blurStrategy;
1412
+ private thresholdStrategy;
1413
+ constructor(blurStrategy: BlurStrategy, config?: Partial<DoGConfig>);
1414
+ dispose(): void;
1415
+ /**
1416
+ * Process an image through the DoG pipeline
1417
+ *
1418
+ * Pipeline:
1419
+ * 1. Apply two Gaussian blurs with different sigma values
1420
+ * 2. Compute sharpened image using Equation 7
1421
+ * 3. Apply soft thresholding using Equation 5
1422
+ *
1423
+ * @param input Grayscale input image (values in 0-1 range)
1424
+ * @param overrides Optional parameter overrides for this call
1425
+ * @returns Processed image with edges detected and stylized
1426
+ */
1427
+ process(input: ChannelImage, overrides?: Partial<DoGConfig>): Promise<ChannelImage>;
1428
+ /**
1429
+ * Process without thresholding - returns the sharpened image
1430
+ * Useful for debugging or custom post-processing
1431
+ */
1432
+ processNoThreshold(input: ChannelImage, overrides?: Partial<DoGConfig>): Promise<ChannelImage>;
1433
+ /**
1434
+ * Get the raw DoG response (without sharpening or thresholding)
1435
+ * Useful for visualization and debugging
1436
+ */
1437
+ processRawDoG(input: ChannelImage, overrides?: Partial<DoGConfig>): Promise<ChannelImage>;
1438
+ /**
1439
+ * Process and return all intermediate results in a single pass
1440
+ *
1441
+ * This is more efficient than calling process(), processNoThreshold(), and
1442
+ * processRawDoG() separately as it only performs the blur operations once.
1443
+ *
1444
+ * @param input Grayscale input image (values in 0-1 range)
1445
+ * @param overrides Optional parameter overrides for this call
1446
+ * @returns Object containing result, sharpened, and rawDoG images
1447
+ */
1448
+ processDetailed(input: ChannelImage, overrides?: Partial<DoGConfig>): Promise<DoGProcessingResult>;
1449
+ /**
1450
+ * Get current configuration
1451
+ */
1452
+ getConfig(): Readonly<DoGConfig>;
1453
+ /**
1454
+ * Update configuration
1455
+ */
1456
+ setConfig(config: Partial<DoGConfig>): void;
1457
+ /**
1458
+ * Replace blur strategy
1459
+ */
1460
+ setBlurStrategy(strategy: BlurStrategy): void;
1461
+ /**
1462
+ * Compute raw Difference of Gaussians: D(x) = G_sigma(x) - G_ksigma(x)
1463
+ * This is the standard DoG without any weighting
1464
+ */
1465
+ private computeDoG;
1466
+ /**
1467
+ * Compute sharpened image using Equation 7 from the paper:
1468
+ * S_sigma,k,p(x) = G_sigma(x) + p x D_sigma,k(x) = (1 + p) x G_sigma(x) - p x G_ksigma(x)
1469
+ *
1470
+ * This can be understood as unsharp masking of the blurred image.
1471
+ * The parameter p controls the edge sharpening strength independently
1472
+ * of the threshold parameters.
1473
+ *
1474
+ * @param blur1 G_sigma * I (smaller blur)
1475
+ * @param blur2 G_ksigma * I (larger blur)
1476
+ * @param p Sharpening strength (p ≈ 20 typical, p ≈ 100 for woodcut)
1477
+ */
1478
+ private computeSharpening;
1479
+ /**
1480
+ * Apply thresholding using the configured strategy
1481
+ * This creates the characteristic XDoG stylization:
1482
+ * - Values above ε become white (1)
1483
+ * - Values below ε get soft-thresholded with tanh
1484
+ * - φ controls the sharpness of the transition
1485
+ *
1486
+ * @param sharpened Sharpened image from computeSharpening
1487
+ * @param epsilon Threshold value (typically around 0.5-0.8 for normalized images)
1488
+ * @param phi Threshold sharpness (0.01 = soft, 100 = near step function)
1489
+ */
1490
+ applyThreshold(sharpened: ChannelImage, epsilon: number | ChannelImage, phi: number | ChannelImage): ChannelImage;
1491
+ }
1492
+ /**
1493
+ * Alternative thresholding modes that can be used for different effects
1494
+ * These can be applied to the sharpened image manually for custom styles
1495
+ */
1496
+ declare const ThresholdModes: {
1497
+ /**
1498
+ * Hard black and white threshold (step function)
1499
+ * Equivalent to φ → ∞ in the soft threshold
1500
+ */
1501
+ hard: (value: number, epsilon: number) => number;
1502
+ /**
1503
+ * Soft threshold (default XDoG style, Equation 5)
1504
+ */
1505
+ soft: (value: number, epsilon: number, phi: number) => number;
1506
+ /**
1507
+ * Three-tone (white, gray, black) for sketch effect
1508
+ * Creates a posterized look with three distinct values
1509
+ */
1510
+ threeTone: (value: number, epsilon: number, midPoint?: number) => number;
1511
+ /**
1512
+ * Multi-tone quantization
1513
+ * Quantizes to n discrete levels
1514
+ */
1515
+ multiTone: (value: number, levels: number) => number;
1516
+ /**
1517
+ * Continuous (no thresholding) - useful for seeing raw sharpened output
1518
+ * Maps the range to 0-1 for visualization
1519
+ */
1520
+ continuous: (value: number) => number;
1521
+ /**
1522
+ * Smooth curve approximating three-value quantization
1523
+ * Used for Figure 7(c) in the paper
1524
+ */
1525
+ smoothThreeTone: (value: number, epsilon: number, phi: number) => number;
1526
+ };
1527
+ /**
1528
+ * Apply a custom threshold function to a grayscale image
1529
+ */
1530
+ declare function applyCustomThreshold(input: ChannelImage, thresholdFn: (value: number) => number): ChannelImage;
1531
+
1532
+ /**
1533
+ * Blur strategies for DoG processing
1534
+ *
1535
+ * Provides both isotropic (standard) and anisotropic (flow-guided) blur
1536
+ * implementations for use in XDoG and FDoG pipelines.
1537
+ *
1538
+ * Supports parallel/concurrent blur operations
1539
+ */
1540
+
1541
+ /**
1542
+ * Backend-agnostic isotropic blur. Picks the best backend this device
1543
+ * actually supports for *this algorithm* (not a global session-wide
1544
+ * choice), and falls back to the next-best backend if the active one
1545
+ * fails mid-session (lost context, driver crash, etc.).
1546
+ *
1547
+ * Construction is async (`IsotropicBlur.create()`) because backend
1548
+ * detection is inherently async; constructors can't be async, so a
1549
+ * private constructor plus a static factory forces detection to
1550
+ * complete before the instance is usable.
1551
+ */
1552
+ declare class IsotropicBlur implements BlurStrategy {
1553
+ private filter;
1554
+ private constructor();
1555
+ static create(config?: Partial<IsotropicBlurConfig>): Promise<IsotropicBlur>;
1556
+ get backend(): "webgpu" | "webgl" | "cpu";
1557
+ dispose(): void;
1558
+ blur(input: ChannelImage, sigma: number): Promise<ChannelImage>;
1559
+ }
1560
+
1561
+ declare class BaseCPUStrategy {
1562
+ readonly backend: "cpu";
1563
+ dispose(): void;
1564
+ static isSupported(): Promise<boolean>;
1565
+ static getUnsupportedReason(): string | undefined;
1566
+ }
1567
+ declare class BaseWebGLStrategy {
1568
+ readonly backend: "webgl";
1569
+ dispose(): void;
1570
+ static isSupported(): Promise<boolean>;
1571
+ /**
1572
+ * Get reason if WebGL2 is not supported.
1573
+ *
1574
+ * Declared to allow an async return (per StrategyCtor in interfaces/base.ts)
1575
+ * even though this base implementation itself is synchronous, so that
1576
+ * subclasses that need to probe the shared/module-level GL context
1577
+ * asynchronously can override it without a static-side type conflict.
1578
+ */
1579
+ static getUnsupportedReason(): string | undefined | Promise<string | undefined>;
1580
+ /**
1581
+ * WebGL errors are synchronous — no scopes, just drain-then-check.
1582
+ * See discussion in webgl.ts for why this is needed.
1583
+ */
1584
+ protected runGuarded<T>(gl: WebGL2RenderingContext, fn: () => T): T;
1585
+ }
1586
+ declare class BaseWebGPUStrategy {
1587
+ readonly backend: "webgpu";
1588
+ dispose(): void;
1589
+ protected static cachedAdapter: GPUAdapter | null;
1590
+ protected static cachedDevice: GPUDevice | null;
1591
+ protected static devicePromise: Promise<GPUDevice | null> | null;
1592
+ protected static adapterInfo: GPUAdapterInfo | null;
1593
+ protected static isSoftwareRenderer: boolean;
1594
+ /**
1595
+ * Check if WebGPU is supported (sync check - just API availability)
1596
+ */
1597
+ static isSupported(): Promise<boolean>;
1598
+ /**
1599
+ * Get reason if WebGPU is not supported.
1600
+ *
1601
+ * Declared to allow an async return (per StrategyCtor in interfaces/base.ts)
1602
+ * even though this base implementation itself is synchronous, so that
1603
+ * subclasses that need to request an adapter to confirm availability
1604
+ * can override it without a static-side type conflict.
1605
+ */
1606
+ static getUnsupportedReason(): string | undefined | Promise<string | undefined>;
1607
+ /**
1608
+ * Check if the adapter is a software/fallback renderer (call after getWebGPUDevice)
1609
+ */
1610
+ static isFallbackAdapter(): boolean;
1611
+ /**
1612
+ * Get adapter info (call after getWebGPUDevice)
1613
+ */
1614
+ static getAdapterInfo(): GPUAdapterInfo | null;
1615
+ /**
1616
+ * Async check if WebGPU is actually usable with hardware acceleration
1617
+ * Returns false for software renderers like SwiftShader
1618
+ */
1619
+ static isAvailable(allowSoftware?: boolean): Promise<boolean>;
1620
+ /**
1621
+ * Detect if adapter is a software renderer
1622
+ */
1623
+ private static detectSoftwareRenderer;
1624
+ /**
1625
+ * Get or create WebGPU device (shared)
1626
+ */
1627
+ static getWebGPUDevice(): Promise<GPUDevice | null>;
1628
+ /**
1629
+ * WebGPU errors are async (error scopes). See discussion in
1630
+ * webgpu.ts for why try/catch alone misses these.
1631
+ */
1632
+ protected runGuarded<T>(device: GPUDevice, fn: () => T | Promise<T>): Promise<T>;
1633
+ }
1634
+
1635
+ /**
1636
+ * Flow-guided blur using line integral convolution along edge tangents
1637
+ * This is the blur used in FDoG for coherent line drawing
1638
+ *
1639
+ * The blur is computed by integrating pixel values along the flow direction,
1640
+ * weighted by a Gaussian kernel. This produces blur that follows edge contours
1641
+ * rather than blurring across them.
1642
+ */
1643
+
1644
+ interface FlowGuidedBlurStrategy {
1645
+ setFlowField(flowField: FlowField): void;
1646
+ }
1647
+ /**
1648
+ * Configuration for flow-guided blur
1649
+ */
1650
+ interface CPUFlowGuidedBlurConfig {
1651
+ /**
1652
+ * Kernel size multiplier for flow-aligned LIC (default: 6)
1653
+ */
1654
+ kernelSizeMultiplier: number;
1655
+ /**
1656
+ * Step size for line integral convolution (default: 1.0)
1657
+ * Smaller values give smoother integration but cost more
1658
+ */
1659
+ stepSize: number;
1660
+ }
1661
+ declare class CPUFlowGuidedBlur extends BaseCPUStrategy implements BlurStrategy, FlowGuidedBlurStrategy {
1662
+ private flowField;
1663
+ private config;
1664
+ constructor(flowField: FlowField, config?: Partial<CPUFlowGuidedBlurConfig>);
1665
+ /** CPU is always available */
1666
+ static isSupported(): Promise<boolean>;
1667
+ dispose(): void;
1668
+ /**
1669
+ * Update the flow field (e.g., when processing a new image)
1670
+ */
1671
+ setFlowField(flowField: FlowField): void;
1672
+ blur(input: ChannelImage, sigma: number): Promise<ChannelImage>;
1673
+ /**
1674
+ * Sample along the flow direction using line integral convolution
1675
+ *
1676
+ * This follows the tangent field in both directions from the starting point,
1677
+ * accumulating weighted samples to produce a blur along the edge direction.
1678
+ */
1679
+ private sampleAlongFlow;
1680
+ }
1681
+ /**
1682
+ * WebGL2-accelerated flow-guided blur
1683
+ * Uses line integral convolution along edge tangent directions
1684
+ */
1685
+ declare class WebGLFlowGuidedBlur extends BaseWebGLStrategy implements BlurStrategy, FlowGuidedBlurStrategy {
1686
+ private config;
1687
+ private flowField;
1688
+ private resources;
1689
+ private currentWidth;
1690
+ private currentHeight;
1691
+ private framebuffer;
1692
+ private textures;
1693
+ private flowTexture;
1694
+ constructor(flowField: FlowField, config?: Partial<GLGPUBlurConfig>);
1695
+ /**
1696
+ * Same check as WebGLIsotropicBlur: a real, hardware-accelerated WebGL2
1697
+ * context with float render targets, excluding software rasterizers.
1698
+ */
1699
+ static isSupported(): Promise<boolean>;
1700
+ private initResources;
1701
+ private ensureTextureSize;
1702
+ /**
1703
+ * Update the flow field (e.g., when processing a new image)
1704
+ */
1705
+ setFlowField(flowField: FlowField): void;
1706
+ blur(input: ChannelImage, sigma: number): Promise<ChannelImage>;
1707
+ dispose(): void;
1708
+ }
1709
+ /**
1710
+ * Configuration for WebGL blur
1711
+ */
1712
+ interface GLGPUBlurConfig {
1713
+ /** Kernel size multiplier relative to sigma (default: 6) */
1714
+ kernelSizeMultiplier: number;
1715
+ /** Maximum kernel size (default: 63, limited by shader uniform array) */
1716
+ maxKernelSize: number;
1717
+ }
1718
+ /**
1719
+ * Configuration for WebGPU blur
1720
+ */
1721
+ interface GLGPUBlurConfig {
1722
+ /** Kernel size multiplier relative to sigma (default: 6) */
1723
+ kernelSizeMultiplier: number;
1724
+ /** Maximum kernel size (default: 127) */
1725
+ maxKernelSize: number;
1726
+ }
1727
+ /**
1728
+ * WebGPU-accelerated flow-guided blur
1729
+ */
1730
+ declare class WebGPUFlowGuidedBlur extends BaseWebGPUStrategy implements BlurStrategy, FlowGuidedBlurStrategy {
1731
+ private config;
1732
+ private flowField;
1733
+ private resources;
1734
+ private kernelBuffer;
1735
+ private currentKernelSize;
1736
+ private flowTexture;
1737
+ private flowFieldWidth;
1738
+ private flowFieldHeight;
1739
+ private flowDirty;
1740
+ private static readonly CPU_BAKE_ROWS_PER_CHUNK;
1741
+ private maxTileBytes;
1742
+ private static readonly TILE_MEMORY_SAFETY_FACTOR;
1743
+ constructor(flowField: FlowField, config?: Partial<GLGPUBlurConfig>);
1744
+ /**
1745
+ * Confirms an adapter is actually obtainable, not just that
1746
+ * `navigator.gpu` exists as an API surface.
1747
+ */
1748
+ static isSupported(): Promise<boolean>;
1749
+ private initResources;
1750
+ /**
1751
+ * Textures are bound by maxTextureDimension2D (typically 8192-16384),
1752
+ * not the storage-buffer binding limit. That ceiling still exists,
1753
+ * and silently exceeding it is exactly the failure mode this fix is
1754
+ * closing off. Throw a clear, catchable error instead, so the
1755
+ * FlowGuidedBlur wrapper's fallback logic gets a chance to demote to
1756
+ * WebGL/CPU rather than the caller getting corrupted output.
1757
+ */
1758
+ private assertWithinTextureLimits;
1759
+ /**
1760
+ * (Re)builds the flow-field texture for the given dimensions if it's
1761
+ * missing, stale (setFlowField() was called), or the wrong size. Built
1762
+ * in row-chunks rather than one Float32Array(width*height*2) for the
1763
+ * whole image, so preparing this for a large image doesn't itself blow
1764
+ * up JS heap before any GPU work happens.
1765
+ */
1766
+ private bakeFlowTexture;
1767
+ private getFlowTexture;
1768
+ /**
1769
+ * Update the flow field (e.g., when processing a new image). Marks the
1770
+ * cached flow texture dirty rather than rebuilding immediately. The
1771
+ * next blur() call rebuilds it against the dimensions that call actually
1772
+ * needs.
1773
+ */
1774
+ setFlowField(flowField: FlowField): void;
1775
+ /**
1776
+ * MEMORY: the output/readback path is processed in row-band tiles
1777
+ * bounded by `maxTileBytes`, not one whole-image buffer
1778
+ */
1779
+ blur(input: ChannelImage, sigma: number): Promise<ChannelImage>;
1780
+ dispose(): void;
1781
+ }
1782
+ type FlowGuidedBlurConfig = CPUFlowGuidedBlurConfig | GLGPUBlurConfig;
1783
+ /**
1784
+ * Backend-agnostic flow-guided blur. Same per-algorithm backend selection
1785
+ * and single-retry fallback as `IsotropicBlur`
1786
+ *
1787
+ * One addition here: the flow field is mutable,
1788
+ * so it has to be tracked on the wrapper too. A
1789
+ * fallback needs to construct the next backend with the *current* flow
1790
+ * field, not the one from construction time.
1791
+ */
1792
+ declare class FlowGuidedBlur implements BlurStrategy, FlowGuidedBlurStrategy {
1793
+ private instance;
1794
+ private currentCtor;
1795
+ private config;
1796
+ private flowField;
1797
+ private failedBackends;
1798
+ private constructor();
1799
+ private static readonly candidates;
1800
+ static create(flowField: FlowField, config?: Partial<FlowGuidedBlurConfig>): Promise<FlowGuidedBlur>;
1801
+ get backend(): "webgpu" | "webgl" | "cpu";
1802
+ dispose(): void;
1803
+ blur(input: ChannelImage, sigma: number): Promise<ChannelImage>;
1804
+ /**
1805
+ * Update the flow field (e.g., when processing a new frame). Stored on
1806
+ * the wrapper too, so a later backend fallback hands the new instance
1807
+ * the current flow field rather than a stale one from construction time.
1808
+ */
1809
+ setFlowField(flowField: FlowField): void;
1810
+ private demoteAndFindNext;
1811
+ }
1812
+
1813
+ declare class EdgeAwareBlur<TConfig> implements BlurStrategy {
1814
+ private filter;
1815
+ private toConfig;
1816
+ constructor(filter: EdgeAwareFilterCore<TConfig>, toConfig: (sigma: number) => TConfig);
1817
+ blur(input: ChannelImage, sigma: number): Promise<ChannelImage>;
1818
+ get backend(): "webgpu" | "webgl" | "cpu";
1819
+ dispose(): void;
1820
+ }
1821
+
1822
+ declare class GradientAlignedBlur implements BlurStrategy {
1823
+ private instance;
1824
+ private currentCtor;
1825
+ private flowField;
1826
+ private config;
1827
+ private failedBackends;
1828
+ private constructor();
1829
+ private static readonly candidates;
1830
+ static create(flowField: FlowField, config?: Partial<GradientAlignedBlurConfig>): Promise<GradientAlignedBlur>;
1831
+ get backend(): "webgpu" | "webgl" | "cpu";
1832
+ dispose(): void;
1833
+ blur(input: ChannelImage, sigma: number): Promise<ChannelImage>;
1834
+ /**
1835
+ * Propagates to whatever backend is currently running, and is also
1836
+ * remembered for any future backend constructed by demoteAndFindNext()
1837
+ * (fallback instances are built fresh via `new Ctor(config)`, so the
1838
+ * current flow field has to be threaded through `config` each time
1839
+ * rather than mutated on an existing instance).
1840
+ */
1841
+ setFlowField(flowField: FlowField): void;
1842
+ private demoteAndFindNext;
1843
+ }
1844
+
1845
+ type index$6_CPUFlowGuidedBlur = CPUFlowGuidedBlur;
1846
+ declare const index$6_CPUFlowGuidedBlur: typeof CPUFlowGuidedBlur;
1847
+ type index$6_EdgeAwareBlur<TConfig> = EdgeAwareBlur<TConfig>;
1848
+ declare const index$6_EdgeAwareBlur: typeof EdgeAwareBlur;
1849
+ type index$6_FlowGuidedBlur = FlowGuidedBlur;
1850
+ declare const index$6_FlowGuidedBlur: typeof FlowGuidedBlur;
1851
+ type index$6_FlowGuidedBlurConfig = FlowGuidedBlurConfig;
1852
+ type index$6_GradientAlignedBlur = GradientAlignedBlur;
1853
+ declare const index$6_GradientAlignedBlur: typeof GradientAlignedBlur;
1854
+ type index$6_IsotropicBlur = IsotropicBlur;
1855
+ declare const index$6_IsotropicBlur: typeof IsotropicBlur;
1856
+ type index$6_WebGLFlowGuidedBlur = WebGLFlowGuidedBlur;
1857
+ declare const index$6_WebGLFlowGuidedBlur: typeof WebGLFlowGuidedBlur;
1858
+ type index$6_WebGPUFlowGuidedBlur = WebGPUFlowGuidedBlur;
1859
+ declare const index$6_WebGPUFlowGuidedBlur: typeof WebGPUFlowGuidedBlur;
1860
+ declare namespace index$6 {
1861
+ export { index$6_CPUFlowGuidedBlur as CPUFlowGuidedBlur, index$6_EdgeAwareBlur as EdgeAwareBlur, index$6_FlowGuidedBlur as FlowGuidedBlur, index$6_GradientAlignedBlur as GradientAlignedBlur, index$6_IsotropicBlur as IsotropicBlur, index$6_WebGLFlowGuidedBlur as WebGLFlowGuidedBlur, index$6_WebGPUFlowGuidedBlur as WebGPUFlowGuidedBlur };
1862
+ export type { index$6_FlowGuidedBlurConfig as FlowGuidedBlurConfig };
1863
+ }
1864
+
1865
+ /**
1866
+ * Edge Tangent Flow computer that automatically resolves to the best
1867
+ * supported backend, with graceful single-retry fallback if that backend
1868
+ * fails after selection (driver crash, lost context, etc).
1869
+ *
1870
+ */
1871
+ declare class EdgeTangentFlowComputer implements ETFComputer {
1872
+ private instance;
1873
+ private currentCtor;
1874
+ private failedBackends;
1875
+ private constructor();
1876
+ private static readonly candidates;
1877
+ static create(): Promise<EdgeTangentFlowComputer>;
1878
+ /**
1879
+ * Which backend is actually running right now. Can change over the
1880
+ * life of this instance if a fallback occurs mid-session.
1881
+ */
1882
+ get backend(): "webgpu" | "webgl" | "cpu";
1883
+ dispose(): void;
1884
+ /**
1885
+ * Compute an Edge Tangent Flow. The returned FlowField carries its own
1886
+ * magnitude/anisotropy (see interfaces/base.ts)
1887
+ */
1888
+ compute(input: ChannelImage, config?: Partial<ETFConfig>, sigmaC?: number): Promise<FlowField>;
1889
+ computeMultiChannel(inputs: ChannelImage[], config?: Partial<ETFConfig>, sigmaC?: number): Promise<FlowField>;
1890
+ callWithFallback<T>(op: (computer: ETFComputer) => Promise<T>): Promise<T>;
1891
+ private demoteAndFindNext;
1892
+ }
1893
+
1894
+ /**
1895
+ * Preprocessing module for XDoG/FDoG
1896
+ *
1897
+ * Provides filters to prepare images before line detection.
1898
+ * These help reduce noise and texture while preserving important edges.
1899
+ *
1900
+ * Section 3.2 of the paper discusses the importance of bilateral
1901
+ * preprocessing for "indication" - attenuating weak edges while
1902
+ * preserving strong edges.
1903
+ */
1904
+
1905
+ /**
1906
+ * Bilateral Filter
1907
+ *
1908
+ * Edge-preserving smoothing filter that averages pixels based on both
1909
+ * spatial proximity AND intensity similarity. This smooths out texture
1910
+ * (like grass) while keeping strong edges (like the car outline) sharp.
1911
+ *
1912
+ * This is the recommended preprocessing for most images.
1913
+ *
1914
+ * As mentioned in Section 3.2, bilateral filtering can serve as a
1915
+ * "prioritization mechanism" for indication - attenuating weak edges
1916
+ * while supporting strong edges.
1917
+ *
1918
+ * CPU is always available (BaseCPUStrategy.isSupported() / dispose() /
1919
+ * backend all apply unchanged). This is the universal fallback.
1920
+ */
1921
+ declare class BilateralFilter$3 extends BaseCPUStrategy implements EdgeAwareFilterCore<BilateralFilterConfig> {
1922
+ apply(input: ChannelImage, config: Partial<BilateralFilterConfig>): Promise<ChannelImage>;
1923
+ }
1924
+ /**
1925
+ * Median Filter
1926
+ *
1927
+ * Replaces each pixel with the median of its neighborhood.
1928
+ * Excellent for removing salt-and-pepper noise and small texture details.
1929
+ */
1930
+ declare class MedianFilter$3 extends BaseCPUStrategy implements EdgeAwareFilterCore<MedianFilterConfig> {
1931
+ apply(input: ChannelImage, config: Partial<MedianFilterConfig>): Promise<ChannelImage>;
1932
+ }
1933
+ /**
1934
+ * Kuwahara Filter
1935
+ *
1936
+ * Artistic smoothing filter that creates a painterly effect.
1937
+ * Divides the neighborhood into 4 quadrants, finds the one with
1938
+ * lowest variance, and uses its mean. Creates flat regions with
1939
+ * preserved edges - great for a more stylized look.
1940
+ */
1941
+ declare class KuwaharaFilter$3 extends BaseCPUStrategy implements EdgeAwareFilterCore<KuwaharaFilterConfig> {
1942
+ apply(input: ChannelImage, config: Partial<KuwaharaFilterConfig>): Promise<ChannelImage>;
1943
+ }
1944
+ /**
1945
+ * Gaussian Blur
1946
+ *
1947
+ * Simple Gaussian smoothing. Less edge-preserving than bilateral,
1948
+ * but faster. Good for very noisy images or when used with small sigma.
1949
+ */
1950
+ declare class GaussianBlur$2 extends BaseCPUStrategy implements EdgeAwareFilterCore<GaussianConfig> {
1951
+ apply(input: ChannelImage, config: Partial<GaussianConfig>): Promise<ChannelImage>;
1952
+ }
1953
+ /**
1954
+ * Contrast Enhancement
1955
+ *
1956
+ * Stretches the histogram to use the full 0-1 range.
1957
+ * Can help make edges more distinct before processing.
1958
+ */
1959
+ declare class ContrastEnhancer$2 extends BaseCPUStrategy implements EdgeAwareFilterCore<ContrastEnhancementConfig> {
1960
+ apply(input: ChannelImage, config: Partial<ContrastEnhancementConfig>): Promise<ChannelImage>;
1961
+ }
1962
+ /**
1963
+ * Quantize to reduce color levels
1964
+ *
1965
+ * Reduces the number of intensity levels, creating a posterized effect.
1966
+ * Can help reduce noise by grouping similar intensities together.
1967
+ */
1968
+ declare class Quantizer$2 extends BaseCPUStrategy implements EdgeAwareFilterCore<QuantizerConfig> {
1969
+ apply(input: ChannelImage, config: Partial<QuantizerConfig>): Promise<ChannelImage>;
1970
+ }
1971
+ /**
1972
+ * Computes local variance as texture detection preprocessing
1973
+ *
1974
+ * STANDALONE PREPROCESSING: This class only detects texture.
1975
+ * It does NOT perform edge detection.
1976
+ *
1977
+ * Input: ChannelImage (typically grayscale image)
1978
+ * Output: ChannelImage with same dimensions where each pixel value
1979
+ * represents texture strength (0 = pure structure, 1 = pure texture)
1980
+ *
1981
+ * The output can be:
1982
+ * 1. Passed to your XDoG/FDoG/HDoG implementation to modulate parameters
1983
+ * 2. Combined with other texture detection methods (Spectral, Patch-based)
1984
+ * 3. Visualized for debugging
1985
+ * 4. Processed through additional preprocessing steps
1986
+ *
1987
+ * Example:
1988
+ * ```
1989
+ * const filter = new LocalVarianceFilter({
1990
+ * windowRadius: 2,
1991
+ * normalizeByGradient: true,
1992
+ * });
1993
+ *
1994
+ * const textureMap = filter.apply(grayImage);
1995
+ * // textureMap.data[i] = texture strength at pixel i
1996
+ * // Now use textureMap with your own edge detection
1997
+ * ```
1998
+ */
1999
+ declare class LocalVarianceFilter implements EdgeAwareFilterCore<LocalVarianceConfig> {
2000
+ /** CPU-only. No WebGL/WebGPU counterparts for this yet. */
2001
+ readonly backend: "cpu";
2002
+ defaultConfig: LocalVarianceConfig;
2003
+ dispose(): void;
2004
+ /**
2005
+ * Process using separable convolution (faster for large windows)
2006
+ * Variance = E[X^2] - E[X]^2
2007
+ * Compute box blur of X and X^2 separately, then combine
2008
+ */
2009
+ apply(image: ChannelImage, config: Partial<LocalVarianceConfig>): Promise<ChannelImage>;
2010
+ /**
2011
+ * Fast box blur using separable convolution + a sliding-window running sum.
2012
+ *
2013
+ * @remarks
2014
+ * Each pass is O(width * height): the window sum is updated incrementally
2015
+ * as it slides one pixel over (`sum += incoming - outgoing`) rather than
2016
+ * being re-summed from scratch at every position, so cost no longer grows
2017
+ * with `radius`. Edge pixels use clamp-to-edge boundary handling.
2018
+ *
2019
+ * Trade-off: because each sum is derived from the previous one instead of
2020
+ * being recomputed from scratch, floating-point error can accumulate along
2021
+ * a scan line, unlike the resum-per-pixel approach this replaces. This is
2022
+ * negligible in practice for 0-1 normalized pixel values and the small
2023
+ * radii (1-4) this filter supports.
2024
+ *
2025
+ * @private
2026
+ */
2027
+ private boxBlur;
2028
+ /**
2029
+ * Compute gradient map using Sobel filter (separable for efficiency)
2030
+ * @private
2031
+ */
2032
+ private computeGradientMap;
2033
+ }
2034
+ /**
2035
+ * Preset preprocessing pipelines for common use cases
2036
+ */
2037
+ declare const EdgeAwareFilterPresets: {
2038
+ /**
2039
+ * Light preprocessing - minimal smoothing
2040
+ * Good for: Clean studio photos, illustrations
2041
+ */
2042
+ light: (input: ChannelImage) => Promise<ChannelImage>;
2043
+ /**
2044
+ * Standard preprocessing - balanced smoothing
2045
+ * Good for: Most outdoor photos, portraits
2046
+ */
2047
+ standard: (input: ChannelImage) => Promise<ChannelImage>;
2048
+ /**
2049
+ * Heavy preprocessing - aggressive noise removal
2050
+ * Good for: Very textured images (grass, foliage, fabric)
2051
+ */
2052
+ heavy: (input: ChannelImage) => Promise<ChannelImage>;
2053
+ /**
2054
+ * Artistic preprocessing - painterly smoothing
2055
+ * Good for: Stylized/artistic output
2056
+ */
2057
+ artistic: (input: ChannelImage) => Promise<ChannelImage>;
2058
+ /**
2059
+ * Photo preprocessing - for photos with grass/nature
2060
+ * Good for: Landscape, outdoor scenes
2061
+ */
2062
+ nature: (input: ChannelImage) => Promise<ChannelImage>;
2063
+ };
2064
+
2065
+ declare const cpu_EdgeAwareFilterPresets: typeof EdgeAwareFilterPresets;
2066
+ type cpu_LocalVarianceFilter = LocalVarianceFilter;
2067
+ declare const cpu_LocalVarianceFilter: typeof LocalVarianceFilter;
2068
+ declare namespace cpu {
2069
+ export {
2070
+ BilateralFilter$3 as BilateralFilter,
2071
+ ContrastEnhancer$2 as ContrastEnhancer,
2072
+ cpu_EdgeAwareFilterPresets as EdgeAwareFilterPresets,
2073
+ GaussianBlur$2 as GaussianBlur,
2074
+ KuwaharaFilter$3 as KuwaharaFilter,
2075
+ cpu_LocalVarianceFilter as LocalVarianceFilter,
2076
+ MedianFilter$3 as MedianFilter,
2077
+ Quantizer$2 as Quantizer,
2078
+ };
2079
+ }
2080
+
2081
+ declare abstract class ResilientEdgeAwareFilter<TOptions, TImage extends FilterImage = ChannelImage> implements EdgeAwareFilterCore<TOptions, TImage> {
2082
+ private readonly candidates;
2083
+ private readonly config;
2084
+ private readonly failedBackends;
2085
+ private instance;
2086
+ private currentCtor;
2087
+ /**
2088
+ * Subclasses resolve their instance via `resolve()` *before* calling
2089
+ * this (in their own async static `create()`), then hand the result in
2090
+ * here. The constructor itself stays synchronous, as constructors must.
2091
+ */
2092
+ protected constructor(candidates: readonly EdgeAwareFilterCtor<TOptions, TImage>[], resolved: {
2093
+ instance: EdgeAwareFilterCore<TOptions, TImage>;
2094
+ ctor: EdgeAwareFilterCtor<TOptions, TImage>;
2095
+ }, config: Partial<TOptions>);
2096
+ /**
2097
+ * Try each candidate in order, skipping unsupported ones. If a
2098
+ * candidate reports supported but throws on construction anyway
2099
+ * (isSupported() lied), move on to the next.
2100
+ */
2101
+ protected static resolve<TOptions, TImage extends FilterImage = ChannelImage>(candidates: readonly EdgeAwareFilterCtor<TOptions, TImage>[], config: Partial<TOptions>): Promise<{
2102
+ instance: EdgeAwareFilterCore<TOptions, TImage>;
2103
+ ctor: EdgeAwareFilterCtor<TOptions, TImage>;
2104
+ }>;
2105
+ get backend(): "webgpu" | "webgl" | "cpu";
2106
+ dispose(): void;
2107
+ apply(input: TImage, options: Partial<TOptions>): Promise<TImage>;
2108
+ private demoteAndFindNext;
2109
+ }
2110
+
2111
+ /**
2112
+ * WebGL-Accelerated Preprocessing Module for XDoG/FDoG
2113
+ *
2114
+ * High-performance GPU implementations of image preprocessing filters.
2115
+ * Achieves 50-100x speedup over CPU implementations for large images.
2116
+ */
2117
+
2118
+ declare class BilateralFilterWebGL extends BaseWebGLStrategy implements EdgeAwareFilterCore<BilateralFilterConfig> {
2119
+ static isSupported(): Promise<boolean>;
2120
+ static getUnsupportedReason(): Promise<string | undefined>;
2121
+ apply(input: ChannelImage, config: Partial<BilateralFilterConfig>): Promise<ChannelImage>;
2122
+ }
2123
+ declare class GaussianBlurWebGL extends BaseWebGLStrategy implements EdgeAwareFilterCore<GaussianConfig> {
2124
+ static isSupported(): Promise<boolean>;
2125
+ static getUnsupportedReason(): Promise<string | undefined>;
2126
+ apply(input: ChannelImage, config: Partial<GaussianConfig>): Promise<ChannelImage>;
2127
+ }
2128
+ declare class MedianFilterWebGL extends BaseWebGLStrategy implements EdgeAwareFilterCore<MedianFilterConfig> {
2129
+ static isSupported(): Promise<boolean>;
2130
+ static getUnsupportedReason(): Promise<string | undefined>;
2131
+ apply(input: ChannelImage, config?: Partial<MedianFilterConfig>): Promise<ChannelImage>;
2132
+ }
2133
+ declare class KuwaharaFilterWebGL extends BaseWebGLStrategy implements EdgeAwareFilterCore<KuwaharaFilterConfig> {
2134
+ static isSupported(): Promise<boolean>;
2135
+ static getUnsupportedReason(): Promise<string | undefined>;
2136
+ apply(input: ChannelImage, config?: Partial<KuwaharaFilterConfig>): Promise<ChannelImage>;
2137
+ }
2138
+ declare class ContrastEnhancerWebGL extends BaseWebGLStrategy implements EdgeAwareFilterCore<ContrastEnhancementConfig> {
2139
+ static isSupported(): Promise<boolean>;
2140
+ static getUnsupportedReason(): Promise<string | undefined>;
2141
+ apply(input: ChannelImage, config: Partial<ContrastEnhancementConfig>): Promise<ChannelImage>;
2142
+ }
2143
+ declare class QuantizerWebGL extends BaseWebGLStrategy implements EdgeAwareFilterCore<QuantizerConfig> {
2144
+ static isSupported(): Promise<boolean>;
2145
+ static getUnsupportedReason(): Promise<string | undefined>;
2146
+ apply(input: ChannelImage, config: Partial<QuantizerConfig>): Promise<ChannelImage>;
2147
+ }
2148
+ /**
2149
+ * Check if WebGL 2.0 is available
2150
+ */
2151
+ declare function isWebGLAvailable(): boolean;
2152
+ /**
2153
+ * Cleanup all WebGL resources
2154
+ */
2155
+ declare function disposeWebGL(): void;
2156
+
2157
+ type webgl_BilateralFilterWebGL = BilateralFilterWebGL;
2158
+ declare const webgl_BilateralFilterWebGL: typeof BilateralFilterWebGL;
2159
+ type webgl_ContrastEnhancerWebGL = ContrastEnhancerWebGL;
2160
+ declare const webgl_ContrastEnhancerWebGL: typeof ContrastEnhancerWebGL;
2161
+ type webgl_GaussianBlurWebGL = GaussianBlurWebGL;
2162
+ declare const webgl_GaussianBlurWebGL: typeof GaussianBlurWebGL;
2163
+ type webgl_KuwaharaFilterWebGL = KuwaharaFilterWebGL;
2164
+ declare const webgl_KuwaharaFilterWebGL: typeof KuwaharaFilterWebGL;
2165
+ type webgl_MedianFilterWebGL = MedianFilterWebGL;
2166
+ declare const webgl_MedianFilterWebGL: typeof MedianFilterWebGL;
2167
+ type webgl_QuantizerWebGL = QuantizerWebGL;
2168
+ declare const webgl_QuantizerWebGL: typeof QuantizerWebGL;
2169
+ declare const webgl_disposeWebGL: typeof disposeWebGL;
2170
+ declare const webgl_isWebGLAvailable: typeof isWebGLAvailable;
2171
+ declare namespace webgl {
2172
+ export {
2173
+ BilateralFilterWebGL as BilateralFilter,
2174
+ webgl_BilateralFilterWebGL as BilateralFilterWebGL,
2175
+ ContrastEnhancerWebGL as ContrastEnhancer,
2176
+ webgl_ContrastEnhancerWebGL as ContrastEnhancerWebGL,
2177
+ GaussianBlurWebGL as GaussianBlur,
2178
+ webgl_GaussianBlurWebGL as GaussianBlurWebGL,
2179
+ KuwaharaFilterWebGL as KuwaharaFilter,
2180
+ webgl_KuwaharaFilterWebGL as KuwaharaFilterWebGL,
2181
+ MedianFilterWebGL as MedianFilter,
2182
+ webgl_MedianFilterWebGL as MedianFilterWebGL,
2183
+ QuantizerWebGL as Quantizer,
2184
+ webgl_QuantizerWebGL as QuantizerWebGL,
2185
+ webgl_disposeWebGL as disposeWebGL,
2186
+ webgl_isWebGLAvailable as isWebGLAvailable,
2187
+ };
2188
+ }
2189
+
2190
+ /**
2191
+ * WebGPU-accelerated preprocessing module for XDoG/FDoG
2192
+ *
2193
+ * Even faster than WebGL implementations
2194
+ */
2195
+
2196
+ /**
2197
+ * Deeper async check: confirms an adapter is actually obtainable, not
2198
+ * just that `navigator.gpu` exists.
2199
+ */
2200
+ declare function getWebGPUUnsupportedReason(): Promise<string | undefined>;
2201
+ /** Release the cached device. Mainly useful for tests / hot reload. */
2202
+ declare function disposeWebGPU(): void;
2203
+ declare function clearShaderCaches(): void;
2204
+ /**
2205
+ * The `rowOffset` field lets a single dispatch cover only a band of rows
2206
+ * of a much taller image (see the chunking loop in `process()` below).
2207
+ * `spatialWeights` is a precomputed (2*radius+1)^2 lookup table for the
2208
+ * spatial term of the bilateral weight, which depends only on (dx, dy)
2209
+ * and is identical for every pixel. Computing it on the CPU once instead
2210
+ * of calling `exp()` for it on every shader invocation roughly halves the
2211
+ * transcendental-function work in the inner loop.
2212
+ */
2213
+ declare class GPUBilateralFilter extends BaseWebGPUStrategy implements EdgeAwareFilterCore<BilateralFilterConfig> {
2214
+ static isSupported(): Promise<boolean>;
2215
+ static getUnsupportedReason(): Promise<string | undefined>;
2216
+ apply(input: ChannelImage, config: Partial<BilateralFilterConfig>): Promise<ChannelImage>;
2217
+ }
2218
+ declare class GPUMedianFilter extends BaseWebGPUStrategy implements EdgeAwareFilterCore<MedianFilterConfig> {
2219
+ static isSupported(): Promise<boolean>;
2220
+ static getUnsupportedReason(): Promise<string | undefined>;
2221
+ apply(input: ChannelImage, config: Partial<MedianFilterConfig>): Promise<ChannelImage>;
2222
+ }
2223
+ declare class GPUKuwaharaFilter extends BaseWebGPUStrategy implements EdgeAwareFilterCore<KuwaharaFilterConfig> {
2224
+ static isSupported(): Promise<boolean>;
2225
+ static getUnsupportedReason(): Promise<string | undefined>;
2226
+ apply(input: ChannelImage, config: Partial<KuwaharaFilterConfig>): Promise<ChannelImage>;
2227
+ }
2228
+ declare class GPUGaussianBlur extends BaseWebGPUStrategy implements EdgeAwareFilterCore<GaussianConfig> {
2229
+ static isSupported(): Promise<boolean>;
2230
+ static getUnsupportedReason(): Promise<string | undefined>;
2231
+ apply(input: ChannelImage, config: Partial<GaussianConfig>): Promise<ChannelImage>;
2232
+ }
2233
+ declare class GPUContrastEnhancer extends BaseWebGPUStrategy implements EdgeAwareFilterCore<ContrastEnhancementConfig> {
2234
+ static isSupported(): Promise<boolean>;
2235
+ static getUnsupportedReason(): Promise<string | undefined>;
2236
+ /**
2237
+ * The CPU version sorts every pixel to find exact percentiles. Sorting
2238
+ * is a poor fit for a GPU compute pass, so this builds a 256-bin
2239
+ * histogram instead (one atomicAdd per pixel), reads the 1KB histogram
2240
+ * back to the CPU to locate the percentile bins, then runs a second,
2241
+ * fully GPU-resident pass to apply the stretch. This trades a small
2242
+ * amount of precision (bin width 1/255) for O(n) work instead of an
2243
+ * O(n log n) sort, at the cost of one small CPU/GPU sync point.
2244
+ *
2245
+ * The two GPU round-trips (histogram pass, then stretch pass) are each
2246
+ * wrapped in their own runGuarded scope rather than one scope spanning
2247
+ * both. The CPU-side histogram bucketing that happens between them
2248
+ * isn't GPU work, so it shouldn't sit inside a WebGPU error scope.
2249
+ */
2250
+ apply(input: ChannelImage, config: Partial<ContrastEnhancementConfig>): Promise<ChannelImage>;
2251
+ }
2252
+ declare class GPUQuantizer extends BaseWebGPUStrategy implements EdgeAwareFilterCore<QuantizerConfig> {
2253
+ static isSupported(): Promise<boolean>;
2254
+ static getUnsupportedReason(): Promise<string | undefined>;
2255
+ apply(input: ChannelImage, config: Partial<QuantizerConfig>): Promise<ChannelImage>;
2256
+ }
2257
+ /**
2258
+ * Preset preprocessing pipelines for common use cases.
2259
+ * async GPU equivalents of `PreprocessingPresets` in cpu.ts.
2260
+ */
2261
+ declare const GPUPreprocessingPresets: {
2262
+ /** Light preprocessing - minimal smoothing. Good for clean studio photos, illustrations. */
2263
+ light: (input: ChannelImage) => Promise<ChannelImage>;
2264
+ /** Standard preprocessing - balanced smoothing. Good for most outdoor photos, portraits. */
2265
+ standard: (input: ChannelImage) => Promise<ChannelImage>;
2266
+ /** Heavy preprocessing - aggressive noise removal. Good for very textured images. */
2267
+ heavy: (input: ChannelImage) => Promise<ChannelImage>;
2268
+ /** Artistic preprocessing - painterly smoothing. Good for stylized/artistic output. */
2269
+ artistic: (input: ChannelImage) => Promise<ChannelImage>;
2270
+ /** Photo preprocessing - for photos with grass/nature. Good for landscape, outdoor scenes. */
2271
+ nature: (input: ChannelImage) => Promise<ChannelImage>;
2272
+ };
2273
+
2274
+ type webgpu_GPUBilateralFilter = GPUBilateralFilter;
2275
+ declare const webgpu_GPUBilateralFilter: typeof GPUBilateralFilter;
2276
+ type webgpu_GPUContrastEnhancer = GPUContrastEnhancer;
2277
+ declare const webgpu_GPUContrastEnhancer: typeof GPUContrastEnhancer;
2278
+ type webgpu_GPUGaussianBlur = GPUGaussianBlur;
2279
+ declare const webgpu_GPUGaussianBlur: typeof GPUGaussianBlur;
2280
+ type webgpu_GPUKuwaharaFilter = GPUKuwaharaFilter;
2281
+ declare const webgpu_GPUKuwaharaFilter: typeof GPUKuwaharaFilter;
2282
+ type webgpu_GPUMedianFilter = GPUMedianFilter;
2283
+ declare const webgpu_GPUMedianFilter: typeof GPUMedianFilter;
2284
+ declare const webgpu_GPUPreprocessingPresets: typeof GPUPreprocessingPresets;
2285
+ type webgpu_GPUQuantizer = GPUQuantizer;
2286
+ declare const webgpu_GPUQuantizer: typeof GPUQuantizer;
2287
+ declare const webgpu_clearShaderCaches: typeof clearShaderCaches;
2288
+ declare const webgpu_disposeWebGPU: typeof disposeWebGPU;
2289
+ declare const webgpu_getWebGPUUnsupportedReason: typeof getWebGPUUnsupportedReason;
2290
+ declare namespace webgpu {
2291
+ export {
2292
+ webgpu_GPUBilateralFilter as GPUBilateralFilter,
2293
+ webgpu_GPUContrastEnhancer as GPUContrastEnhancer,
2294
+ webgpu_GPUGaussianBlur as GPUGaussianBlur,
2295
+ webgpu_GPUKuwaharaFilter as GPUKuwaharaFilter,
2296
+ webgpu_GPUMedianFilter as GPUMedianFilter,
2297
+ webgpu_GPUPreprocessingPresets as GPUPreprocessingPresets,
2298
+ webgpu_GPUQuantizer as GPUQuantizer,
2299
+ webgpu_clearShaderCaches as clearShaderCaches,
2300
+ webgpu_disposeWebGPU as disposeWebGPU,
2301
+ webgpu_getWebGPUUnsupportedReason as getWebGPUUnsupportedReason,
2302
+ };
2303
+ }
2304
+
2305
+ /**
2306
+ * Composed Preprocessing Module for XDoG/FDoG
2307
+ *
2308
+ * This module is the single entry point the rest of the codebase should
2309
+ * import from. Each exported class resolves its OWN best-supported
2310
+ * backend independently (WebGPU > WebGL > CPU), the first time it's
2311
+ * created:
2312
+ *
2313
+ * BilateralFilter.create(...) // may end up WebGPU on this device
2314
+ * MedianFilter.create(...) // may end up WebGL on this device, if
2315
+ * // e.g. it needs a storage texture format
2316
+ * // WebGPU can't provide here
2317
+ *
2318
+ * A device can support WebGPU for one algorithm and not another, so
2319
+ * resolution happens per class, not once globally for the whole module.
2320
+ * This follows the same pattern used for BlurStrategy/ETFComputer.
2321
+ *
2322
+ * If a backend fails mid-session (driver crash, lost context), each
2323
+ * instance demotes itself to the next supported candidate once and
2324
+ * retries the call that failed; that shared retry/demote machinery lives
2325
+ * in `ResilientEdgeAwareFilter`, not duplicated per filter.
2326
+ */
2327
+
2328
+ interface BackendOptions {
2329
+ /** Force CPU even if WebGL/WebGPU are available. Default: false. */
2330
+ forceCPU?: boolean;
2331
+ }
2332
+ declare function pickCandidates<TParams, TImage extends FilterImage = ChannelImage>(candidates: readonly EdgeAwareFilterCtor<TParams, TImage>[], options?: BackendOptions): readonly EdgeAwareFilterCtor<TParams, TImage>[];
2333
+ /**
2334
+ * Edge-preserving smoothing filter. Resolves the best supported backend
2335
+ * at creation time; falls back once if that backend fails later.
2336
+ */
2337
+ declare class BilateralFilter$2 extends ResilientEdgeAwareFilter<Partial<BilateralFilterConfig>> {
2338
+ private static readonly candidates;
2339
+ private constructor();
2340
+ static create(config?: Partial<BilateralFilterConfig>, options?: BackendOptions): Promise<BilateralFilter$2>;
2341
+ }
2342
+ /**
2343
+ * Median filter for salt-and-pepper noise removal.
2344
+ */
2345
+ declare class MedianFilter$2 extends ResilientEdgeAwareFilter<Partial<MedianFilterConfig>> {
2346
+ private static readonly candidates;
2347
+ private constructor();
2348
+ static create(config?: Partial<MedianFilterConfig>, options?: BackendOptions): Promise<MedianFilter$2>;
2349
+ }
2350
+ /**
2351
+ * Kuwahara filter for a painterly, stylized effect.
2352
+ */
2353
+ declare class KuwaharaFilter$2 extends ResilientEdgeAwareFilter<Partial<KuwaharaFilterConfig>> {
2354
+ private static readonly candidates;
2355
+ private constructor();
2356
+ static create(config?: Partial<KuwaharaFilterConfig>, options?: BackendOptions): Promise<KuwaharaFilter$2>;
2357
+ }
2358
+ /**
2359
+ * Separable Isotropic blur.
2360
+ */
2361
+ declare class IsotropicBlurFilter extends ResilientEdgeAwareFilter<IsotropicBlurConfig> {
2362
+ private static readonly candidates;
2363
+ private constructor();
2364
+ static create(config: Partial<IsotropicBlurConfig>, options?: BackendOptions): Promise<IsotropicBlurFilter>;
2365
+ }
2366
+ /**
2367
+ * Separable Gaussian blur.
2368
+ */
2369
+ declare class GaussianBlur$1 extends ResilientEdgeAwareFilter<GaussianConfig> {
2370
+ private static readonly candidates;
2371
+ private constructor();
2372
+ static create(config: GaussianConfig, options?: BackendOptions): Promise<GaussianBlur$1>;
2373
+ }
2374
+ declare class ContrastEnhancer$1 extends ResilientEdgeAwareFilter<ContrastEnhancementConfig> {
2375
+ private static readonly candidates;
2376
+ private constructor();
2377
+ static create(blackPoint?: number, whitePoint?: number, options?: BackendOptions): Promise<ContrastEnhancer$1>;
2378
+ }
2379
+ /**
2380
+ * Posterize/quantize intensity levels.
2381
+ */
2382
+ declare class Quantizer$1 extends ResilientEdgeAwareFilter<QuantizerConfig> {
2383
+ private static readonly candidates;
2384
+ private constructor();
2385
+ static create(config: QuantizerConfig, options?: BackendOptions): Promise<Quantizer$1>;
2386
+ }
2387
+ declare const PreprocessingPresets$1: {
2388
+ /**
2389
+ * Light preprocessing - minimal smoothing
2390
+ * Good for: Clean studio photos, illustrations
2391
+ */
2392
+ light: (input: ChannelImage) => Promise<ChannelImage>;
2393
+ /**
2394
+ * Standard preprocessing - balanced smoothing
2395
+ * Good for: Most outdoor photos, portraits
2396
+ */
2397
+ standard: (input: ChannelImage) => Promise<ChannelImage>;
2398
+ /**
2399
+ * Heavy preprocessing - aggressive noise removal
2400
+ * Good for: Very textured images (grass, foliage, fabric)
2401
+ */
2402
+ heavy: (input: ChannelImage) => Promise<ChannelImage>;
2403
+ /**
2404
+ * Artistic preprocessing - painterly smoothing
2405
+ * Good for: Stylized/artistic output
2406
+ */
2407
+ artistic: (input: ChannelImage) => Promise<ChannelImage>;
2408
+ /**
2409
+ * Photo preprocessing - for photos with grass/nature
2410
+ * Good for: Landscape, outdoor scenes
2411
+ */
2412
+ nature: (input: ChannelImage) => Promise<ChannelImage>;
2413
+ };
2414
+
2415
+ /**
2416
+ * Helpers shared by the multi-channel edge-aware filters (bilateral, median, ...)
2417
+ * that are independent of any one filter's parameters: image validation,
2418
+ * channel-weight resolution, cloning, and RGBA packing for the GPU backends.
2419
+ *
2420
+ * (The Kuwahara filter has private copies of cloneImage/packRGBA/unpackRGBA in
2421
+ * its own shared.ts; these are the same functions made generic over the color
2422
+ * space, so it can switch to them whenever convenient.)
2423
+ */
2424
+
2425
+ /**
2426
+ * hsv / hsl are excluded by the filters that average or compare channel
2427
+ * values arithmetically: their hue channel is circular, so means and
2428
+ * differences are wrong across the 0/1 wrap. Convert to rgb / linear-rgb /
2429
+ * lab first.
2430
+ */
2431
+ type NonCircularColorSpace = Exclude<ColorSpace, 'hsv' | 'hsl'>;
2432
+
2433
+ /**
2434
+ * Shared types and parameter handling for the multi-channel bilateral filter
2435
+ * (CPU / WebGL / WebGPU backends).
2436
+ *
2437
+ * Each output pixel is a weighted mean of its (2r+1)x(2r+1) neighborhood,
2438
+ * with weight
2439
+ *
2440
+ * w(p, q) = exp(-|p - q|^2 / (2 sigmaSpatial^2))
2441
+ * * exp(-D(p, q) / (2 sigmaRange^2))
2442
+ *
2443
+ * where D is the *joint* weighted squared distance across all channels,
2444
+ *
2445
+ * D(p, q) = sum_c channelWeights[c] * (I_c(p) - I_c(q))^2.
2446
+ *
2447
+ * Using one joint range weight (rather than filtering each channel on its
2448
+ * own) means every channel blends the same neighbors, so an edge in any
2449
+ * channel protects all of them and there is no color fringing.
2450
+ *
2451
+ * Out-of-image samples use clamp-to-edge, matching the other filters.
2452
+ * Alpha, if present, is passed through unfiltered.
2453
+ */
2454
+
2455
+ type BilateralColorSpace = NonCircularColorSpace;
2456
+ type BilateralImage = MultiChannelImage<BilateralColorSpace>;
2457
+ interface MultiChannelBilateralConfig extends BilateralFilterConfig {
2458
+ /**
2459
+ * Per-channel weight in the joint range distance (one entry per channel,
2460
+ * all >= 0). Default: 1 for every channel.
2461
+ *
2462
+ * `sigmaRange` is expressed in the image's native channel units, so choose
2463
+ * it (and these weights) with the color space in mind:
2464
+ * - gray / rgb / linear-rgb are in [0, 1]; the default 0.1 is sensible.
2465
+ * - lab is stored in native units (L 0-100, a/b ~ +-128); with equal
2466
+ * weights a sigmaRange around 5-15 is a typical starting point.
2467
+ * A weight of 0 makes that channel ignored when judging similarity (it is
2468
+ * still smoothed).
2469
+ */
2470
+ channelWeights?: number[];
2471
+ }
2472
+
2473
+ /**
2474
+ * Multi-channel bilateral filter that picks the best available backend
2475
+ * (WebGPU -> WebGL -> CPU) and falls back at runtime if one fails.
2476
+ */
2477
+ declare class BilateralFilter$1 extends ResilientEdgeAwareFilter<MultiChannelBilateralConfig, BilateralImage> {
2478
+ private static readonly candidates;
2479
+ private constructor();
2480
+ static create(config: Partial<MultiChannelBilateralConfig>, options?: BackendOptions): Promise<BilateralFilter$1>;
2481
+ }
2482
+
2483
+ /**
2484
+ * Shared types and parameter handling for the multi-channel Kuwahara filter
2485
+ * (CPU / WebGL / WebGPU backends).
2486
+ *
2487
+ * The filter splits the (2r+1)x(2r+1) window around each pixel into four
2488
+ * overlapping (r+1)x(r+1) quadrants, and outputs the per-channel mean of the
2489
+ * quadrant whose *combined* variance is lowest. For multi-channel images the
2490
+ * combined variance is the weighted sum of per-channel variances, so all
2491
+ * channels agree on one quadrant (no color fringing from picking a different
2492
+ * region per channel).
2493
+ */
2494
+
2495
+ /**
2496
+ * hsv / hsl are excluded: their hue channel is circular, so the plain
2497
+ * arithmetic mean this filter computes is wrong across the 0/1 wrap.
2498
+ * Convert to rgb / linear-rgb / lab first.
2499
+ */
2500
+ type KuwaharaColorSpace = Exclude<ColorSpace, 'hsv' | 'hsl'>;
2501
+ type KuwaharaImage = MultiChannelImage<KuwaharaColorSpace>;
2502
+ interface MultiChannelKuwaharaConfig extends KuwaharaFilterConfig {
2503
+ /**
2504
+ * Per-channel weight in the quadrant-selection variance (one entry per
2505
+ * channel, all >= 0). Default: 1 for every channel.
2506
+ *
2507
+ * Only affects which quadrant wins; the output mean is always computed for
2508
+ * every channel. Note that Lab is stored in native units (L 0-100,
2509
+ * a/b ~ +-128), so with equal weights the variance is already dominated by
2510
+ * L and a/b; adjust weights if you want different behavior.
2511
+ */
2512
+ channelWeights?: number[];
2513
+ }
2514
+
2515
+ /**
2516
+ * Multi-channel Kuwahara filter that picks the best available backend
2517
+ * (WebGPU -> WebGL -> CPU) and falls back at runtime if one fails.
2518
+ */
2519
+ declare class KuwaharaFilter$1 extends ResilientEdgeAwareFilter<MultiChannelKuwaharaConfig, KuwaharaImage> {
2520
+ private static readonly candidates;
2521
+ private constructor();
2522
+ static create(config: Partial<MultiChannelKuwaharaConfig>, options?: BackendOptions): Promise<KuwaharaFilter$1>;
2523
+ }
2524
+
2525
+ /**
2526
+ * Shared types and parameter handling for the multi-channel median filter
2527
+ * (CPU / WebGL / WebGPU backends).
2528
+ *
2529
+ * Each output value is the median of the (2r+1)x(2r+1) neighborhood, taken
2530
+ * independently per channel (a "marginal" median). The output is therefore
2531
+ * always an actual input value, per channel, but the three channels of one
2532
+ * output pixel may come from different source pixels, so on strongly
2533
+ * colored edges it can produce colors that were not in the input. If that
2534
+ * matters, run it in a space where the channels are decorrelated (lab) or
2535
+ * use a vector median instead.
2536
+ *
2537
+ * Out-of-image samples use clamp-to-edge, so the window always holds exactly
2538
+ * (2r+1)^2 samples and the median is the exact middle element. Alpha, if
2539
+ * present, is passed through unfiltered.
2540
+ */
2541
+
2542
+ /**
2543
+ * hsv / hsl are excluded: their hue channel is circular, so an ordering-based
2544
+ * statistic over it is meaningless across the 0/1 wrap.
2545
+ */
2546
+ type MedianColorSpace = NonCircularColorSpace;
2547
+ type MedianImage = MultiChannelImage<MedianColorSpace>;
2548
+ /** No extra options beyond the single-channel config (`radius`). */
2549
+ type MultiChannelMedianConfig = MedianFilterConfig;
2550
+
2551
+ /**
2552
+ * Multi-channel median filter that picks the best available backend
2553
+ * (WebGPU -> WebGL -> CPU) and falls back at runtime if one fails.
2554
+ */
2555
+ declare class MedianFilter$1 extends ResilientEdgeAwareFilter<MultiChannelMedianConfig, MedianImage> {
2556
+ private static readonly candidates;
2557
+ private constructor();
2558
+ static create(config: Partial<MultiChannelMedianConfig>, options?: BackendOptions): Promise<MedianFilter$1>;
2559
+ }
2560
+
2561
+ type index$5_BilateralColorSpace = BilateralColorSpace;
2562
+ type index$5_BilateralImage = BilateralImage;
2563
+ type index$5_KuwaharaColorSpace = KuwaharaColorSpace;
2564
+ type index$5_KuwaharaImage = KuwaharaImage;
2565
+ type index$5_MedianColorSpace = MedianColorSpace;
2566
+ type index$5_MedianImage = MedianImage;
2567
+ type index$5_MultiChannelBilateralConfig = MultiChannelBilateralConfig;
2568
+ type index$5_MultiChannelKuwaharaConfig = MultiChannelKuwaharaConfig;
2569
+ type index$5_MultiChannelMedianConfig = MultiChannelMedianConfig;
2570
+ declare namespace index$5 {
2571
+ export { BilateralFilter$1 as BilateralFilter, KuwaharaFilter$1 as KuwaharaFilter, MedianFilter$1 as MedianFilter };
2572
+ export type { index$5_BilateralColorSpace as BilateralColorSpace, index$5_BilateralImage as BilateralImage, index$5_KuwaharaColorSpace as KuwaharaColorSpace, index$5_KuwaharaImage as KuwaharaImage, index$5_MedianColorSpace as MedianColorSpace, index$5_MedianImage as MedianImage, index$5_MultiChannelBilateralConfig as MultiChannelBilateralConfig, index$5_MultiChannelKuwaharaConfig as MultiChannelKuwaharaConfig, index$5_MultiChannelMedianConfig as MultiChannelMedianConfig };
2573
+ }
2574
+
2575
+ type index$4_BackendOptions = BackendOptions;
2576
+ type index$4_IsotropicBlurFilter = IsotropicBlurFilter;
2577
+ declare const index$4_IsotropicBlurFilter: typeof IsotropicBlurFilter;
2578
+ declare const index$4_cpu: typeof cpu;
2579
+ declare const index$4_disposeWebGL: typeof disposeWebGL;
2580
+ declare const index$4_disposeWebGPU: typeof disposeWebGPU;
2581
+ declare const index$4_isWebGLAvailable: typeof isWebGLAvailable;
2582
+ declare const index$4_pickCandidates: typeof pickCandidates;
2583
+ declare const index$4_webgl: typeof webgl;
2584
+ declare const index$4_webgpu: typeof webgpu;
2585
+ declare namespace index$4 {
2586
+ export { BilateralFilter$2 as BilateralFilter, ContrastEnhancer$1 as ContrastEnhancer, GaussianBlur$1 as GaussianBlur, index$4_IsotropicBlurFilter as IsotropicBlurFilter, KuwaharaFilter$2 as KuwaharaFilter, MedianFilter$2 as MedianFilter, PreprocessingPresets$1 as PreprocessingPresets, Quantizer$1 as Quantizer, index$4_cpu as cpu, index$4_disposeWebGL as disposeWebGL, index$4_disposeWebGPU as disposeWebGPU, index$4_isWebGLAvailable as isWebGLAvailable, index$5 as multiChannel, index$4_pickCandidates as pickCandidates, index$4_webgl as webgl, index$4_webgpu as webgpu };
2587
+ export type { index$4_BackendOptions as BackendOptions };
2588
+ }
2589
+
2590
+ /**
2591
+ * Epsilon parameter estimation
2592
+ *
2593
+ * XDoG/FDoG/ADoG threshold their continuous sharpened response against a
2594
+ * scalar `epsilon`. A fixed epsilon under-serves one tone extreme or the
2595
+ * other on high-dynamic-range input.
2596
+ *
2597
+ * Why epsilon should track local tone (from processor.ts's Eq. 7):
2598
+ * S(x) = (1+p)*blur1(x) - p*blur2(x). In flat regions blur1(x) ≈ blur2(x)
2599
+ * ≈ local brightness, so S(x) itself sits near local tone there. A flat
2600
+ * epsilon tuned for midtones crushes bright regions to white and dark
2601
+ * regions to black. For epsilon to threshold something meaningful
2602
+ * everywhere, it has to move with local tone -- lower in dark
2603
+ * neighborhoods, higher in light ones.
2604
+ *
2605
+ * Both `toneAdaptiveEstimate` and `localBaselineEstimate` below are
2606
+ * principled for epsilon specifically: tone tracking approximates S(x),
2607
+ * and local-baseline tracking reads it more directly. See shared.ts for
2608
+ * the mechanics, and p.ts/phi.ts for why a *different* signal (not tone)
2609
+ * is the principled choice for those parameters instead.
2610
+ */
2611
+
2612
+ declare function toneAdaptiveEstimate$2(input: ChannelImage, options: Omit<ToneAdaptiveOptions, 'low' | 'high'> & {
2613
+ epsilonDark: number;
2614
+ epsilonLight: number;
2615
+ }): Promise<ChannelImage>;
2616
+ declare function toneAdaptiveEstimateAuto$2(input: ChannelImage, options: Omit<ToneAdaptiveAutoOptions, 'higherInLight'> & {
2617
+ denserInDark?: boolean;
2618
+ }): Promise<ChannelImage>;
2619
+ /**
2620
+ * Recommended default: epsilon as the local baseline of the sharpened
2621
+ * response. `sigma` should track the DoG's own sigma (this is what
2622
+ * `computeSharpening()` actually produces in flat regions).
2623
+ */
2624
+ declare function localBaselineEstimate(input: ChannelImage, options: LocalBaselineOptions): Promise<ChannelImage>;
2625
+ /**
2626
+ * Spatially-varying epsilon map for ADoG specifically. Unlike the generic
2627
+ * epsilon.localBaselineEstimate (principled for XDoG's S(x) ≈ localTone),
2628
+ * ADoG's flat-region response is I(x) * (1-p(x)) = I(x) * (1-τ) * tanh(s * I(x)),
2629
+ * bounded by (1-τ) rather than 1 (see Eq. 4/5). This pre-scales the input
2630
+ * by that closed form before handing it to the same blur/offset/
2631
+ * contrastMargin machinery shared.localBaselineEstimate already provides.
2632
+ */
2633
+ declare function adogLocalBaselineEstimate(input: ChannelImage, options: LocalBaselineOptions & {
2634
+ tau: number;
2635
+ s: number;
2636
+ }): Promise<ChannelImage>;
2637
+
2638
+ declare const epsilon_adogLocalBaselineEstimate: typeof adogLocalBaselineEstimate;
2639
+ declare const epsilon_localBaselineEstimate: typeof localBaselineEstimate;
2640
+ declare namespace epsilon {
2641
+ export {
2642
+ epsilon_adogLocalBaselineEstimate as adogLocalBaselineEstimate,
2643
+ epsilon_localBaselineEstimate as localBaselineEstimate,
2644
+ toneAdaptiveEstimate$2 as toneAdaptiveEstimate,
2645
+ toneAdaptiveEstimateAuto$2 as toneAdaptiveEstimateAuto,
2646
+ };
2647
+ }
2648
+
2649
+ /**
2650
+ * p (sharpening strength) parameter estimation
2651
+ *
2652
+ * p multiplies the edge term in Eq. 7: S(x) = blur1(x) + p*D(x), where
2653
+ * D(x) = blur1(x) - blur2(x). D(x) is ~0 in flat regions regardless of
2654
+ * brightness, and grows only where there's real gradient structure. So a
2655
+ * spatially-varying p should track *gradient magnitude*, not tone --
2656
+ * `magnitudeAdaptiveEstimate` below is the principled default.
2657
+ *
2658
+ * `toneAdaptiveEstimate`/`toneAdaptiveEstimateAuto` are also exposed, but
2659
+ * unlike epsilon.ts's use of the same technique, they're NOT derived from
2660
+ * anything -- there's no equation tying p to brightness. Use only if you
2661
+ * deliberately want a brightness-driven look and know that's the choice
2662
+ * you're making.
2663
+ *
2664
+ * If using FDoG with an ETF already computed, prefer its
2665
+ * `confidenceWeighting.pByMagnitude` (../../interfaces/dog.js) instead --
2666
+ * same idea, smoothed/refined magnitude rather than a raw gradient.
2667
+ */
2668
+
2669
+ /** Recommended default. p(x) = pWeak + (pStrong - pWeak) * normalizedGradientMagnitude(x)^gamma */
2670
+ declare function magnitudeAdaptiveEstimate(input: ChannelImage, options: Omit<MagnitudeAdaptiveOptions, 'low' | 'high'> & {
2671
+ pWeak: number;
2672
+ pStrong: number;
2673
+ }): Promise<ChannelImage>;
2674
+ /** Stylistic only -- NOT derived from Eq. 7. See module comment. */
2675
+ declare function toneAdaptiveEstimate$1(input: ChannelImage, options: Omit<ToneAdaptiveOptions, 'low' | 'high'> & {
2676
+ pDark: number;
2677
+ pLight: number;
2678
+ }): Promise<ChannelImage>;
2679
+ /** Stylistic only -- NOT derived from Eq. 7. See module comment. */
2680
+ declare function toneAdaptiveEstimateAuto$1(input: ChannelImage, options: ToneAdaptiveAutoOptions): Promise<ChannelImage>;
2681
+
2682
+ declare const p_magnitudeAdaptiveEstimate: typeof magnitudeAdaptiveEstimate;
2683
+ declare namespace p {
2684
+ export {
2685
+ p_magnitudeAdaptiveEstimate as magnitudeAdaptiveEstimate,
2686
+ toneAdaptiveEstimate$1 as toneAdaptiveEstimate,
2687
+ toneAdaptiveEstimateAuto$1 as toneAdaptiveEstimateAuto,
2688
+ };
2689
+ }
2690
+
2691
+ /**
2692
+ * phi (soft-threshold steepness) parameter estimation
2693
+ *
2694
+ * phi controls tanh steepness of the soft threshold (low phi = gradual
2695
+ * pencil shading, high phi = near step function). No equation ties it to
2696
+ * brightness, but local variance is a plausible signal: a neighborhood
2697
+ * that already has real detail is a reasonable candidate for hard edges;
2698
+ * a flat neighborhood, for soft shading -- independent of tone.
2699
+ * `varianceAdaptiveEstimate` below is the principled default.
2700
+ *
2701
+ * `toneAdaptiveEstimate`/`toneAdaptiveEstimateAuto` are exposed as a
2702
+ * labeled stylistic option only (same caveat as p.ts) -- not derived from
2703
+ * anything.
2704
+ *
2705
+ * Note: `HardThresholdStrategy` (ADoG/FDoG's default) ignores `phi`
2706
+ * entirely -- a spatially-varying phi only matters under
2707
+ * `SoftThresholdStrategy`.
2708
+ */
2709
+
2710
+ /** Recommended default. phi(x) = phiSoft + (phiHard - phiSoft) * normalizedVariance(x)^gamma */
2711
+ declare function varianceAdaptiveEstimate(input: ChannelImage, options: Omit<VarianceAdaptiveOptions, 'low' | 'high'> & {
2712
+ phiSoft: number;
2713
+ phiHard: number;
2714
+ }): Promise<ChannelImage>;
2715
+ /** Stylistic only -- not derived from anything. See module comment. */
2716
+ declare function toneAdaptiveEstimate(input: ChannelImage, options: Omit<ToneAdaptiveOptions, 'low' | 'high'> & {
2717
+ phiDark: number;
2718
+ phiLight: number;
2719
+ }): Promise<ChannelImage>;
2720
+ /** Stylistic only -- not derived from anything. See module comment. */
2721
+ declare function toneAdaptiveEstimateAuto(input: ChannelImage, options: ToneAdaptiveAutoOptions): Promise<ChannelImage>;
2722
+
2723
+ declare const phi_toneAdaptiveEstimate: typeof toneAdaptiveEstimate;
2724
+ declare const phi_toneAdaptiveEstimateAuto: typeof toneAdaptiveEstimateAuto;
2725
+ declare const phi_varianceAdaptiveEstimate: typeof varianceAdaptiveEstimate;
2726
+ declare namespace phi {
2727
+ export {
2728
+ phi_toneAdaptiveEstimate as toneAdaptiveEstimate,
2729
+ phi_toneAdaptiveEstimateAuto as toneAdaptiveEstimateAuto,
2730
+ phi_varianceAdaptiveEstimate as varianceAdaptiveEstimate,
2731
+ };
2732
+ }
2733
+
2734
+ declare const index$3_epsilon: typeof epsilon;
2735
+ declare const index$3_p: typeof p;
2736
+ declare const index$3_phi: typeof phi;
2737
+ declare namespace index$3 {
2738
+ export {
2739
+ index$3_epsilon as epsilon,
2740
+ index$3_p as p,
2741
+ index$3_phi as phi,
2742
+ };
2743
+ }
2744
+
2745
+ /**
2746
+ * Composed Preprocessing Module for XDoG/FDoG
2747
+ *
2748
+ * This module is the single entry point the rest of the codebase should
2749
+ * import from. It no longer does its own backend resolution (WebGPU >
2750
+ * WebGL > CPU, demote-on-failure, etc.) — that machinery lives once in
2751
+ * `ResilientEdgeAwareFilter` and is exercised through the
2752
+ * `EdgeAwareFilterCore`-shaped classes exported from `filters/filters.js`
2753
+ * (`BilateralFilter`, `MedianFilter`, `KuwaharaFilter`, `GaussianBlur`,
2754
+ * `ContrastEnhancer`, `Quantizer`).
2755
+ *
2756
+ * Every class here is a thin adapter from that `apply(input, params)`
2757
+ * shape to the simpler `Preprocessor` shape (`process(input)`, no
2758
+ * per-call params) that the rest of this pipeline expects: it remembers
2759
+ * the config passed to `create()` and forwards it into `apply()` on
2760
+ * every `process()` call. This is exactly the pattern `IsotropicBlur`
2761
+ * (blur/isotropic.ts) already uses to wrap `IsotropicBlurFilter`.
2762
+ */
2763
+
2764
+ /**
2765
+ * Edge-preserving smoothing filter. Backend resolution and mid-session
2766
+ * fallback are handled entirely by the underlying
2767
+ * `BilateralEdgeAwareFilter`; this class just remembers the config.
2768
+ */
2769
+ declare class BilateralFilter implements Preprocessor {
2770
+ private readonly filter;
2771
+ private readonly config;
2772
+ private constructor();
2773
+ static create(config?: Partial<BilateralFilterConfig>, options?: BackendOptions): Promise<BilateralFilter>;
2774
+ get backend(): "webgpu" | "webgl" | "cpu";
2775
+ dispose(): void;
2776
+ process(input: ChannelImage): Promise<ChannelImage>;
2777
+ }
2778
+ /**
2779
+ * Median filter for salt-and-pepper noise removal.
2780
+ */
2781
+ declare class MedianFilter implements Preprocessor {
2782
+ private readonly filter;
2783
+ private readonly config;
2784
+ private constructor();
2785
+ static create(config?: Partial<MedianFilterConfig>, options?: BackendOptions): Promise<MedianFilter>;
2786
+ get backend(): "webgpu" | "webgl" | "cpu";
2787
+ dispose(): void;
2788
+ process(input: ChannelImage): Promise<ChannelImage>;
2789
+ }
2790
+ /**
2791
+ * Kuwahara filter for a painterly, stylized effect.
2792
+ */
2793
+ declare class KuwaharaFilter implements Preprocessor {
2794
+ private readonly filter;
2795
+ private readonly config;
2796
+ private constructor();
2797
+ static create(config?: Partial<KuwaharaFilterConfig>, options?: BackendOptions): Promise<KuwaharaFilter>;
2798
+ get backend(): "webgpu" | "webgl" | "cpu";
2799
+ dispose(): void;
2800
+ process(input: ChannelImage): Promise<ChannelImage>;
2801
+ }
2802
+ /**
2803
+ * Separable Gaussian blur.
2804
+ */
2805
+ declare class GaussianBlur implements Preprocessor {
2806
+ private readonly filter;
2807
+ private readonly config;
2808
+ private constructor();
2809
+ static create(sigma?: number, options?: BackendOptions): Promise<GaussianBlur>;
2810
+ get backend(): "webgpu" | "webgl" | "cpu";
2811
+ dispose(): void;
2812
+ process(input: ChannelImage): Promise<ChannelImage>;
2813
+ }
2814
+ /**
2815
+ * Black/white point contrast stretch.
2816
+ */
2817
+ declare class ContrastEnhancer implements Preprocessor {
2818
+ private readonly filter;
2819
+ private readonly config;
2820
+ private constructor();
2821
+ static create(blackPoint?: number, whitePoint?: number, options?: BackendOptions): Promise<ContrastEnhancer>;
2822
+ get backend(): "webgpu" | "webgl" | "cpu";
2823
+ dispose(): void;
2824
+ process(input: ChannelImage): Promise<ChannelImage>;
2825
+ }
2826
+ /**
2827
+ * Posterize/quantize intensity levels.
2828
+ */
2829
+ declare class Quantizer implements Preprocessor {
2830
+ private readonly filter;
2831
+ private readonly config;
2832
+ private constructor();
2833
+ static create(levels?: number, options?: BackendOptions): Promise<Quantizer>;
2834
+ get backend(): "webgpu" | "webgl" | "cpu";
2835
+ dispose(): void;
2836
+ process(input: ChannelImage): Promise<ChannelImage>;
2837
+ }
2838
+ declare class LocalVariance implements Preprocessor {
2839
+ private readonly filter;
2840
+ private readonly config;
2841
+ private constructor();
2842
+ static create(config: Partial<LocalVarianceConfig>): Promise<LocalVariance>;
2843
+ get backend(): "cpu";
2844
+ dispose(): void;
2845
+ process(input: ChannelImage): Promise<ChannelImage>;
2846
+ }
2847
+ declare const PreprocessingPresets: {
2848
+ /**
2849
+ * Light preprocessing - minimal smoothing
2850
+ * Good for: Clean studio photos, illustrations
2851
+ */
2852
+ light: (input: ChannelImage) => Promise<ChannelImage>;
2853
+ /**
2854
+ * Standard preprocessing - balanced smoothing
2855
+ * Good for: Most outdoor photos, portraits
2856
+ */
2857
+ standard: (input: ChannelImage) => Promise<ChannelImage>;
2858
+ /**
2859
+ * Heavy preprocessing - aggressive noise removal
2860
+ * Good for: Very textured images (grass, foliage, fabric)
2861
+ */
2862
+ heavy: (input: ChannelImage) => Promise<ChannelImage>;
2863
+ /**
2864
+ * Artistic preprocessing - painterly smoothing
2865
+ * Good for: Stylized/artistic output
2866
+ */
2867
+ artistic: (input: ChannelImage) => Promise<ChannelImage>;
2868
+ /**
2869
+ * Photo preprocessing - for photos with grass/nature
2870
+ * Good for: Landscape, outdoor scenes
2871
+ */
2872
+ nature: (input: ChannelImage) => Promise<ChannelImage>;
2873
+ };
2874
+ declare class PreprocessingPipeline {
2875
+ private readonly options?;
2876
+ private operations;
2877
+ constructor(options?: BackendOptions | undefined);
2878
+ bilateral(config?: Partial<BilateralFilterConfig>): Promise<this>;
2879
+ median(config?: Partial<MedianFilterConfig>): Promise<this>;
2880
+ kuwahara(config?: Partial<KuwaharaFilterConfig>): Promise<this>;
2881
+ gaussian(sigma?: number): Promise<this>;
2882
+ contrast(blackPoint?: number, whitePoint?: number): Promise<this>;
2883
+ quantize(levels?: number): Promise<this>;
2884
+ /**
2885
+ * Add an arbitrary custom preprocessing strategy to the pipeline.
2886
+ * Bring your own backend selection if needed.
2887
+ */
2888
+ use(preprocessor: Preprocessor): this;
2889
+ apply(input: ChannelImage): Promise<ChannelImage>;
2890
+ /** Disposes every staged operation's resources and clears the pipeline. */
2891
+ clear(): this;
2892
+ }
2893
+
2894
+ type index$2_BackendOptions = BackendOptions;
2895
+ type index$2_BilateralFilter = BilateralFilter;
2896
+ declare const index$2_BilateralFilter: typeof BilateralFilter;
2897
+ type index$2_ContrastEnhancer = ContrastEnhancer;
2898
+ declare const index$2_ContrastEnhancer: typeof ContrastEnhancer;
2899
+ type index$2_GaussianBlur = GaussianBlur;
2900
+ declare const index$2_GaussianBlur: typeof GaussianBlur;
2901
+ type index$2_KuwaharaFilter = KuwaharaFilter;
2902
+ declare const index$2_KuwaharaFilter: typeof KuwaharaFilter;
2903
+ type index$2_LocalVariance = LocalVariance;
2904
+ declare const index$2_LocalVariance: typeof LocalVariance;
2905
+ type index$2_MedianFilter = MedianFilter;
2906
+ declare const index$2_MedianFilter: typeof MedianFilter;
2907
+ type index$2_PreprocessingPipeline = PreprocessingPipeline;
2908
+ declare const index$2_PreprocessingPipeline: typeof PreprocessingPipeline;
2909
+ declare const index$2_PreprocessingPresets: typeof PreprocessingPresets;
2910
+ type index$2_Quantizer = Quantizer;
2911
+ declare const index$2_Quantizer: typeof Quantizer;
2912
+ declare const index$2_disposeWebGL: typeof disposeWebGL;
2913
+ declare const index$2_disposeWebGPU: typeof disposeWebGPU;
2914
+ declare const index$2_isWebGLAvailable: typeof isWebGLAvailable;
2915
+ declare namespace index$2 {
2916
+ export { index$2_BilateralFilter as BilateralFilter, index$2_ContrastEnhancer as ContrastEnhancer, index$2_GaussianBlur as GaussianBlur, index$2_KuwaharaFilter as KuwaharaFilter, index$2_LocalVariance as LocalVariance, index$2_MedianFilter as MedianFilter, index$2_PreprocessingPipeline as PreprocessingPipeline, index$2_PreprocessingPresets as PreprocessingPresets, index$2_Quantizer as Quantizer, index$2_disposeWebGL as disposeWebGL, index$2_disposeWebGPU as disposeWebGPU, index$2_isWebGLAvailable as isWebGLAvailable, index$3 as parameterEstimation };
2917
+ export type { index$2_BackendOptions as BackendOptions };
2918
+ }
2919
+
2920
+ declare function isWebGLComputeSupported(): boolean;
2921
+ declare function isWebGPUSupported(): Promise<boolean>;
2922
+
2923
+ /**
2924
+ * Create a new grayscale image with given dimensions
2925
+ */
2926
+ declare function createChannelImage(width: number, height: number): ChannelImage;
2927
+ /**
2928
+ * Clone a grayscale image
2929
+ */
2930
+ declare function cloneChannelImage(image: ChannelImage): ChannelImage;
2931
+ /**
2932
+ * Get pixel value with bounds checking (clamps to edge)
2933
+ */
2934
+ declare function getPixel(image: ChannelImage, x: number, y: number): number;
2935
+ /**
2936
+ * Get pixel value with bilinear interpolation for sub-pixel sampling
2937
+ */
2938
+ declare function getPixelBilinear(image: ChannelImage, x: number, y: number): number;
2939
+ /**
2940
+ * Set pixel value
2941
+ */
2942
+ declare function setPixel(image: ChannelImage, x: number, y: number, value: number): void;
2943
+ /**
2944
+ * Get pixel index for coordinates
2945
+ */
2946
+ declare function getIndex(width: number, x: number, y: number): number;
2947
+ /**
2948
+ * Create a zero-filled multi-channel image in the given color space
2949
+ */
2950
+ declare function createMultiChannelImage<S extends ColorSpace>(space: S, width: number, height: number, withAlpha?: boolean): MultiChannelImage<S>;
2951
+ /**
2952
+ * Deep-copy a multi-channel image
2953
+ */
2954
+ declare function cloneMultiChannelImage<S extends ColorSpace>(image: MultiChannelImage<S>): MultiChannelImage<S>;
2955
+ /**
2956
+ * Zero-copy single-channel view: shares its buffer with `image.channels[c]`,
2957
+ * so writes through the view are visible in the source (and vice versa).
2958
+ */
2959
+ declare function channelView(image: MultiChannelImage, c: number): ChannelImage;
2960
+ /**
2961
+ * Zero-copy views of every channel (not including alpha)
2962
+ */
2963
+ declare function channelViews(image: MultiChannelImage): ChannelImage[];
2964
+ /**
2965
+ * Assemble a multi-channel image from independent ChannelImages. Planes are
2966
+ * adopted, not copied. Validates channel count and dimensions.
2967
+ */
2968
+ declare function fromChannelImages<S extends ColorSpace>(space: S, channels: ChannelImage[], alpha?: Float32Array): MultiChannelImage<S>;
2969
+ /**
2970
+ * Convert RGB image to grayscale using luminance formula
2971
+ */
2972
+ declare function rgbToGrayscale(rgb: RGBImage$1): ChannelImage;
2973
+ /**
2974
+ * Convert ImageData (from canvas) to grayscale image
2975
+ * Assumes values are in 0-255 range, normalizes to 0-1
2976
+ */
2977
+ declare function imageDataToLuminance(imageData: ImageData): ChannelImage;
2978
+ /**
2979
+ * Convert grayscale image to ImageData (for canvas display)
2980
+ * Assumes input is in 0-1 range
2981
+ *
2982
+ * @param alpha Optional per-pixel alpha (0-255), one entry per pixel in
2983
+ * the same row-major order as `gray.data`. Omit to get a fully opaque
2984
+ * image (alpha = 255 everywhere), which matches this function's original
2985
+ * behavior for callers that don't care about transparency.
2986
+ */
2987
+ declare function luminanceToImageData(gray: ChannelImage, alpha?: Uint8ClampedArray): ImageData;
2988
+
2989
+ /**
2990
+ * Normalize a 2D vector
2991
+ */
2992
+ declare function normalizeVec2(v: Vec2): Vec2;
2993
+ /**
2994
+ * Compute dot product of two vectors
2995
+ */
2996
+ declare function dotVec2(a: Vec2, b: Vec2): number;
2997
+ /**
2998
+ * Rotate vector 90 degrees counter-clockwise (perpendicular)
2999
+ */
3000
+ declare function perpendicular(v: Vec2): Vec2;
3001
+ /**
3002
+ * Generate 1D Gaussian kernel
3003
+ * @param sigma Standard deviation
3004
+ * @param size Kernel size (should be odd)
3005
+ * @returns Normalized Gaussian kernel
3006
+ */
3007
+ declare function generateGaussianKernel(sigma: number, size: number): Float32Array;
3008
+ /**
3009
+ * Clamp a value to a range
3010
+ */
3011
+ declare function clamp(value: number, min: number, max: number): number;
3012
+ /**
3013
+ * Linear interpolation
3014
+ */
3015
+ declare function lerp(a: number, b: number, t: number): number;
3016
+
3017
+ /**
3018
+ * Color space conversion utilities
3019
+ *
3020
+ * Converts MultiChannelImages between color spaces (gray, rgb, linear-rgb,
3021
+ * lab, hsv, hsl) and prepares them as independent ChannelImages for
3022
+ * multi-channel Edge Tangent Flow. Kept separate from the ETF/structure-tensor
3023
+ * math so that the ETF backends stay color-agnostic: they only ever see
3024
+ * ChannelImage[].
3025
+ *
3026
+ * Images are stored in each space's native units (see ColorSpace in
3027
+ * interfaces/base.ts). Normalizing for gradient computation is a separate,
3028
+ * explicit step: see toFlowChannels().
3029
+ */
3030
+
3031
+ type Triple = [number, number, number];
3032
+ /**
3033
+ * Convert an image to another color space. Returns the input unchanged when it
3034
+ * is already in the target space; otherwise returns a new image (alpha plane,
3035
+ * if any, is shared by reference since conversions never modify it).
3036
+ *
3037
+ * Conversions route through sRGB. Out-of-gamut results (e.g. Lab -> RGB) are
3038
+ * clamped to [0, 1]. Converting to 'gray' is lossy and uses Rec. 601 luma on
3039
+ * the gamma-encoded values, matching rgbToGrayscale().
3040
+ */
3041
+ declare function convertColorSpace<T extends ColorSpace>(image: MultiChannelImage, target: T): MultiChannelImage<T>;
3042
+ /**
3043
+ * Which color space to decompose an image into before computing a
3044
+ * multi-channel Edge Tangent Flow. Only spaces whose channels are all linear
3045
+ * scalars qualify: HSV/HSL hue is circular, so plain per-channel gradients
3046
+ * would be wrong at the wrap-around.
3047
+ */
3048
+ type FlowColorSpace = 'rgb' | 'lab';
3049
+ /**
3050
+ * Prepare an image for multi-channel ETF: convert to `space` if needed, then
3051
+ * return three ChannelImages each in roughly [0, 1].
3052
+ *
3053
+ * - 'rgb': zero-copy views of the sRGB planes.
3054
+ * - 'lab': new planes. L is divided by 100; a and b are mapped via
3055
+ * (v + 128) / 255. This keeps chroma from dominating or being drowned out
3056
+ * by L purely because of differing native scales.
3057
+ */
3058
+ declare function toFlowChannels(image: MultiChannelImage, space: FlowColorSpace): [ChannelImage, ChannelImage, ChannelImage];
3059
+ /**
3060
+ * Three zero-copy ChannelImage views of an RGB image's planes, in [0, 1].
3061
+ * Writes through a view affect the source image.
3062
+ */
3063
+ declare function splitRGBChannels(rgb: RGBImage$1): [ChannelImage, ChannelImage, ChannelImage];
3064
+ /**
3065
+ * CIE Lab's L, a, b as independent ChannelImages normalized to [0, 1]
3066
+ * (see toFlowChannels). Input RGB is assumed to be sRGB in [0, 1].
3067
+ */
3068
+ declare function rgbToLabChannels(rgb: RGBImage$1): [ChannelImage, ChannelImage, ChannelImage];
3069
+ /**
3070
+ * Convert a single sRGB pixel (each component in [0, 1]) to CIE Lab.
3071
+ * L is in [0, 100]; a and b are roughly in [-128, 127] but are not clamped.
3072
+ */
3073
+ declare function srgbToLab(r: number, g: number, b: number): Triple;
3074
+ /**
3075
+ * Convert a single CIE Lab pixel (D65) to sRGB, clamped to [0, 1].
3076
+ */
3077
+ declare function labToSrgb(l: number, a: number, b: number): Triple;
3078
+ declare function rgbToHsl(r: number, g: number, b: number): Triple;
3079
+ declare function hslToRgb(h: number, s: number, l: number): Triple;
3080
+ declare function rgbToHsv(r: number, g: number, b: number): Triple;
3081
+ declare function hsvToRgb(h: number, s: number, v: number): Triple;
3082
+ /**
3083
+ * Canvas ImageData (0-255, RGBA) -> planar sRGB image in [0, 1].
3084
+ * Alpha is dropped unless `keepAlpha` is set.
3085
+ */
3086
+ declare function imageDataToRGB$1(imageData: ImageData, keepAlpha?: boolean): RGBImage$1;
3087
+ /**
3088
+ * Planar sRGB image -> canvas ImageData. Uses the image's alpha plane when
3089
+ * present, otherwise fully opaque.
3090
+ */
3091
+ declare function rgbToImageData$1(rgb: RGBImage$1): ImageData;
3092
+
3093
+ type color_FlowColorSpace = FlowColorSpace;
3094
+ declare const color_convertColorSpace: typeof convertColorSpace;
3095
+ declare const color_hslToRgb: typeof hslToRgb;
3096
+ declare const color_hsvToRgb: typeof hsvToRgb;
3097
+ declare const color_labToSrgb: typeof labToSrgb;
3098
+ declare const color_rgbToHsl: typeof rgbToHsl;
3099
+ declare const color_rgbToHsv: typeof rgbToHsv;
3100
+ declare const color_rgbToLabChannels: typeof rgbToLabChannels;
3101
+ declare const color_splitRGBChannels: typeof splitRGBChannels;
3102
+ declare const color_srgbToLab: typeof srgbToLab;
3103
+ declare const color_toFlowChannels: typeof toFlowChannels;
3104
+ declare namespace color {
3105
+ export { color_convertColorSpace as convertColorSpace, color_hslToRgb as hslToRgb, color_hsvToRgb as hsvToRgb, imageDataToRGB$1 as imageDataToRGB, color_labToSrgb as labToSrgb, color_rgbToHsl as rgbToHsl, color_rgbToHsv as rgbToHsv, rgbToImageData$1 as rgbToImageData, color_rgbToLabChannels as rgbToLabChannels, color_splitRGBChannels as splitRGBChannels, color_srgbToLab as srgbToLab, color_toFlowChannels as toFlowChannels };
3106
+ export type { color_FlowColorSpace as FlowColorSpace };
3107
+ }
3108
+
3109
+ /**
3110
+ * Image utility functions
3111
+ */
3112
+
3113
+ /**
3114
+ * Reads a value that may be a scalar (uniform) or a per-pixel ChannelImage.
3115
+ */
3116
+ declare function at(value: number | ChannelImage, i: number): number;
3117
+
3118
+ declare const index$1_at: typeof at;
3119
+ declare const index$1_channelView: typeof channelView;
3120
+ declare const index$1_channelViews: typeof channelViews;
3121
+ declare const index$1_clamp: typeof clamp;
3122
+ declare const index$1_cloneChannelImage: typeof cloneChannelImage;
3123
+ declare const index$1_cloneMultiChannelImage: typeof cloneMultiChannelImage;
3124
+ declare const index$1_color: typeof color;
3125
+ declare const index$1_createChannelImage: typeof createChannelImage;
3126
+ declare const index$1_createMultiChannelImage: typeof createMultiChannelImage;
3127
+ declare const index$1_dotVec2: typeof dotVec2;
3128
+ declare const index$1_fromChannelImages: typeof fromChannelImages;
3129
+ declare const index$1_generateGaussianKernel: typeof generateGaussianKernel;
3130
+ declare const index$1_getIndex: typeof getIndex;
3131
+ declare const index$1_getPixel: typeof getPixel;
3132
+ declare const index$1_getPixelBilinear: typeof getPixelBilinear;
3133
+ declare const index$1_imageDataToLuminance: typeof imageDataToLuminance;
3134
+ declare const index$1_isWebGLComputeSupported: typeof isWebGLComputeSupported;
3135
+ declare const index$1_isWebGPUSupported: typeof isWebGPUSupported;
3136
+ declare const index$1_lerp: typeof lerp;
3137
+ declare const index$1_luminanceToImageData: typeof luminanceToImageData;
3138
+ declare const index$1_normalizeVec2: typeof normalizeVec2;
3139
+ declare const index$1_perpendicular: typeof perpendicular;
3140
+ declare const index$1_rgbToGrayscale: typeof rgbToGrayscale;
3141
+ declare const index$1_setPixel: typeof setPixel;
3142
+ declare namespace index$1 {
3143
+ export {
3144
+ index$1_at as at,
3145
+ index$1_channelView as channelView,
3146
+ index$1_channelViews as channelViews,
3147
+ index$1_clamp as clamp,
3148
+ index$1_cloneChannelImage as cloneChannelImage,
3149
+ index$1_cloneMultiChannelImage as cloneMultiChannelImage,
3150
+ index$1_color as color,
3151
+ index$1_createChannelImage as createChannelImage,
3152
+ index$1_createMultiChannelImage as createMultiChannelImage,
3153
+ index$1_dotVec2 as dotVec2,
3154
+ index$1_fromChannelImages as fromChannelImages,
3155
+ index$1_generateGaussianKernel as generateGaussianKernel,
3156
+ index$1_getIndex as getIndex,
3157
+ index$1_getPixel as getPixel,
3158
+ index$1_getPixelBilinear as getPixelBilinear,
3159
+ index$1_imageDataToLuminance as imageDataToLuminance,
3160
+ index$1_isWebGLComputeSupported as isWebGLComputeSupported,
3161
+ index$1_isWebGPUSupported as isWebGPUSupported,
3162
+ index$1_lerp as lerp,
3163
+ index$1_luminanceToImageData as luminanceToImageData,
3164
+ index$1_normalizeVec2 as normalizeVec2,
3165
+ index$1_perpendicular as perpendicular,
3166
+ index$1_rgbToGrayscale as rgbToGrayscale,
3167
+ index$1_setPixel as setPixel,
3168
+ };
3169
+ }
3170
+
3171
+ /**
3172
+ * Base interface for all extension strategies
3173
+ */
3174
+ interface ExtensionStrategy<TConfig, TInput, TOutput> {
3175
+ apply(input: TInput, config?: Partial<TConfig>): Promise<TOutput>;
3176
+ }
3177
+ /**
3178
+ * RGB image representation for color operations
3179
+ */
3180
+ interface RGBImage {
3181
+ r: Float32Array;
3182
+ g: Float32Array;
3183
+ b: Float32Array;
3184
+ width: number;
3185
+ height: number;
3186
+ }
3187
+ /**
3188
+ * Result from a DoG processor (either XDoG or FDoG)
3189
+ */
3190
+ interface DoGResult {
3191
+ /** The final processed image */
3192
+ image: ChannelImage;
3193
+ /** The sharpened image before thresholding (if available) */
3194
+ sharpened?: ChannelImage;
3195
+ /** Edge tangent flow (only from FDoG) */
3196
+ etf?: FlowField;
3197
+ /** The original grayscale input */
3198
+ originalGray?: ChannelImage;
3199
+ /** The original color input (if provided) */
3200
+ originalColor?: RGBImage;
3201
+ }
3202
+
3203
+ /**
3204
+ * Anti-aliasing configuration
3205
+ *
3206
+ * From Section 4.3: "Since many of the examples in this paper use the ETF
3207
+ * field to compute coherent edges, we can easily re-use the ETF to apply
3208
+ * a very small line integral convolution along the field"
3209
+ */
3210
+ interface AntiAliasingConfig {
3211
+ /**
3212
+ * Integration sigma along the flow direction (default: 1.0)
3213
+ * - 0.5-2 pixels: Standard anti-aliasing
3214
+ * - >2: Stylistic smoothing effect
3215
+ */
3216
+ sigma: number;
3217
+ /**
3218
+ * Step size for LIC sampling (default: 0.5)
3219
+ */
3220
+ stepSize: number;
3221
+ }
3222
+ /**
3223
+ * Anti-Aliasing Strategy
3224
+ *
3225
+ * Applies line integral convolution along the edge tangent flow
3226
+ * to produce image-coherent and visually pleasing anti-aliasing.
3227
+ *
3228
+ * @example
3229
+ * ```typescript
3230
+ * const fdog = new FDoG({ ... });
3231
+ * const result = await fdog.processDetailed(input);
3232
+ *
3233
+ * const aa = new AntiAliasingStrategy();
3234
+ * const smoothed = await aa.apply({
3235
+ * image: result.result,
3236
+ * etf: result.etf
3237
+ * }, { sigma: 1.5 });
3238
+ * ```
3239
+ */
3240
+ declare class AntiAliasingStrategy implements ExtensionStrategy<AntiAliasingConfig, {
3241
+ image: ChannelImage;
3242
+ etf: FlowField;
3243
+ }, ChannelImage> {
3244
+ private config;
3245
+ constructor(config?: Partial<AntiAliasingConfig>);
3246
+ apply(input: {
3247
+ image: ChannelImage;
3248
+ etf: FlowField;
3249
+ }, configOverride?: Partial<AntiAliasingConfig>): Promise<ChannelImage>;
3250
+ /**
3251
+ * Create anti-aliasing with preset intensity
3252
+ */
3253
+ static withPreset(preset: 'subtle' | 'standard' | 'stylistic'): AntiAliasingStrategy;
3254
+ }
3255
+
3256
+ /**
3257
+ * Color Retention Extension - Extensible Architecture
3258
+ *
3259
+ * Provides a composable, hook-based system for combining stylized XDoG/FDoG
3260
+ * output with original colors. Developers can inject custom logic at every
3261
+ * stage of the pipeline.
3262
+ *
3263
+ * Pipeline stages:
3264
+ * 1. Mask Transform: Modify the stylized mask before blending
3265
+ * 2. Color Transform: Pre-process the original color
3266
+ * 3. Blend Function: Combine mask and color (the core operation)
3267
+ * 4. Post-Process: Final adjustments to the output
3268
+ *
3269
+ * Based on Section 5.2 of the XDoG paper.
3270
+ */
3271
+
3272
+ /**
3273
+ * RGBA color tuple (values in 0-1 range)
3274
+ */
3275
+ type Color = [r: number, g: number, b: number];
3276
+ /**
3277
+ * Pixel context provided to all hook functions
3278
+ * Contains spatial and neighborhood information for advanced effects
3279
+ */
3280
+ interface PixelContext {
3281
+ /** Current pixel x coordinate */
3282
+ x: number;
3283
+ /** Current pixel y coordinate */
3284
+ y: number;
3285
+ /** Linear index into the image array */
3286
+ index: number;
3287
+ /** Image width */
3288
+ width: number;
3289
+ /** Image height */
3290
+ height: number;
3291
+ /** Normalized x coordinate (0-1) */
3292
+ u: number;
3293
+ /** Normalized v coordinate (0-1) */
3294
+ v: number;
3295
+ /**
3296
+ * Sample the original color at an offset from current pixel
3297
+ * Useful for blur, sharpen, or texture effects
3298
+ */
3299
+ sampleColor: (dx: number, dy: number) => Color;
3300
+ /**
3301
+ * Sample the mask at an offset from current pixel
3302
+ */
3303
+ sampleMask: (dx: number, dy: number) => number;
3304
+ /**
3305
+ * Get a value from the shared state (for multi-pass effects)
3306
+ */
3307
+ getState: <T>(key: string) => T | undefined;
3308
+ /**
3309
+ * Set a value in the shared state
3310
+ */
3311
+ setState: <T>(key: string, value: T) => void;
3312
+ }
3313
+ /**
3314
+ * Transform the stylized mask value before blending
3315
+ *
3316
+ * @param mask - Original mask value (0 = edge, 1 = background)
3317
+ * @param ctx - Pixel context with spatial info and sampling functions
3318
+ * @returns Transformed mask value
3319
+ *
3320
+ * @example
3321
+ * ```typescript
3322
+ * // Increase edge thickness by expanding dark regions
3323
+ * const thickenEdges: MaskTransformFn = (mask, ctx) => {
3324
+ * // Sample neighbors and take minimum (expand dark)
3325
+ * let min = mask;
3326
+ * for (let dy = -1; dy <= 1; dy++) {
3327
+ * for (let dx = -1; dx <= 1; dx++) {
3328
+ * min = Math.min(min, ctx.sampleMask(dx, dy));
3329
+ * }
3330
+ * }
3331
+ * return min;
3332
+ * };
3333
+ * ```
3334
+ */
3335
+ type MaskTransformFn = (mask: number, ctx: PixelContext) => number;
3336
+ /**
3337
+ * Transform the original color before blending
3338
+ *
3339
+ * @param color - Original RGB color
3340
+ * @param mask - Current mask value (after mask transform)
3341
+ * @param ctx - Pixel context
3342
+ * @returns Transformed color
3343
+ *
3344
+ * @example
3345
+ * ```typescript
3346
+ * // Boost saturation in non-edge areas
3347
+ * const boostSaturation: ColorTransformFn = (color, mask, ctx) => {
3348
+ * const [h, s, l] = rgbToHsl(...color);
3349
+ * const boostedS = s * (1 + 0.3 * mask); // More saturation where mask is light
3350
+ * return hslToRgb(h, Math.min(1, boostedS), l);
3351
+ * };
3352
+ * ```
3353
+ */
3354
+ type ColorTransformFn = (color: Color, mask: number, ctx: PixelContext) => Color;
3355
+ /**
3356
+ * Core blend function that combines mask and color
3357
+ *
3358
+ * @param color - Transformed color
3359
+ * @param mask - Transformed mask value
3360
+ * @param ctx - Pixel context
3361
+ * @returns Blended output color
3362
+ *
3363
+ * @example
3364
+ * ```typescript
3365
+ * // Simple multiply blend
3366
+ * const multiply: BlendFn = (color, mask) => {
3367
+ * return [color[0] * mask, color[1] * mask, color[2] * mask];
3368
+ * };
3369
+ *
3370
+ * // Screen blend for lighter result
3371
+ * const screen: BlendFn = (color, mask) => {
3372
+ * return [
3373
+ * 1 - (1 - color[0]) * (1 - mask),
3374
+ * 1 - (1 - color[1]) * (1 - mask),
3375
+ * 1 - (1 - color[2]) * (1 - mask),
3376
+ * ];
3377
+ * };
3378
+ * ```
3379
+ */
3380
+ type BlendFn = (color: Color, mask: number, ctx: PixelContext) => Color;
3381
+ /**
3382
+ * Post-process the blended result
3383
+ *
3384
+ * @param color - Blended color
3385
+ * @param originalColor - Original input color (for reference)
3386
+ * @param mask - Final mask value
3387
+ * @param ctx - Pixel context
3388
+ * @returns Final output color
3389
+ *
3390
+ * @example
3391
+ * ```typescript
3392
+ * // Add vignette effect
3393
+ * const vignette: PostProcessFn = (color, original, mask, ctx) => {
3394
+ * const dist = Math.sqrt((ctx.u - 0.5) ** 2 + (ctx.v - 0.5) ** 2);
3395
+ * const vignette = 1 - Math.min(1, dist * 1.2);
3396
+ * return [color[0] * vignette, color[1] * vignette, color[2] * vignette];
3397
+ * };
3398
+ * ```
3399
+ */
3400
+ type PostProcessFn = (color: Color, originalColor: Color, mask: number, ctx: PixelContext) => Color;
3401
+ /**
3402
+ * Global pre-processing hook (runs once before pixel iteration)
3403
+ * Useful for computing histograms, statistics, or initializing state
3404
+ */
3405
+ type PreProcessHook = (stylized: ChannelImage, originalColor: RGBImage$1, state: Map<string, unknown>) => void;
3406
+ /**
3407
+ * Global post-processing hook (runs once after pixel iteration)
3408
+ * Useful for normalization, filtering, or multi-pass effects
3409
+ */
3410
+ type GlobalPostProcessHook = (output: RGBImage$1, state: Map<string, unknown>) => RGBImage$1;
3411
+ /**
3412
+ * Full configuration for the color retention pipeline
3413
+ */
3414
+ interface ColorRetentionConfig {
3415
+ /**
3416
+ * Mask transformation function
3417
+ * Default: identity (no change)
3418
+ */
3419
+ maskTransform?: MaskTransformFn;
3420
+ /**
3421
+ * Color transformation function
3422
+ * Default: identity (no change)
3423
+ */
3424
+ colorTransform?: ColorTransformFn;
3425
+ /**
3426
+ * Core blend function (required or use preset)
3427
+ */
3428
+ blend: BlendFn;
3429
+ /**
3430
+ * Post-processing function
3431
+ * Default: identity (no change)
3432
+ */
3433
+ postProcess?: PostProcessFn;
3434
+ /**
3435
+ * Global pre-processing hook
3436
+ */
3437
+ preProcess?: PreProcessHook;
3438
+ /**
3439
+ * Global post-processing hook
3440
+ */
3441
+ globalPostProcess?: GlobalPostProcessHook;
3442
+ /**
3443
+ * Chain multiple mask transforms (applied in order)
3444
+ */
3445
+ maskTransformChain?: MaskTransformFn[];
3446
+ /**
3447
+ * Chain multiple color transforms (applied in order)
3448
+ */
3449
+ colorTransformChain?: ColorTransformFn[];
3450
+ /**
3451
+ * Chain multiple post-process functions (applied in order)
3452
+ */
3453
+ postProcessChain?: PostProcessFn[];
3454
+ }
3455
+ /**
3456
+ * Extensible Color Retention Strategy
3457
+ *
3458
+ * A fully customizable pipeline for combining stylized edges with colors.
3459
+ * Every stage can be overridden with custom functions.
3460
+ *
3461
+ * @example Basic usage with preset
3462
+ * ```typescript
3463
+ * const strategy = ColorRetentionStrategy.preset('coloredEdges');
3464
+ * const result = await strategy.apply({ stylized, originalColor });
3465
+ * ```
3466
+ *
3467
+ * @example Custom blend function
3468
+ * ```typescript
3469
+ * const strategy = new ColorRetentionStrategy({
3470
+ * blend: (color, mask) => {
3471
+ * // Custom logic here
3472
+ * return [color[0] * mask, color[1] * mask, color[2] * mask];
3473
+ * }
3474
+ * });
3475
+ * ```
3476
+ *
3477
+ * @example Full pipeline customization
3478
+ * ```typescript
3479
+ * const strategy = new ColorRetentionStrategy({
3480
+ * maskTransform: (mask) => Math.pow(mask, 0.8), // Gamma adjust
3481
+ * colorTransform: (color, mask) => boostSaturation(color, 1.2),
3482
+ * blend: BlendFunctions.multiply,
3483
+ * postProcess: (color, orig, mask, ctx) => addVignette(color, ctx),
3484
+ * });
3485
+ * ```
3486
+ *
3487
+ * @example Chaining multiple transforms
3488
+ * ```typescript
3489
+ * const strategy = new ColorRetentionStrategy({
3490
+ * maskTransformChain: [
3491
+ * MaskTransforms.gamma(0.8),
3492
+ * MaskTransforms.threshold(0.1, 0.9),
3493
+ * ],
3494
+ * colorTransformChain: [
3495
+ * ColorTransforms.saturation(1.2),
3496
+ * ColorTransforms.brightness(0.1),
3497
+ * ],
3498
+ * blend: BlendFunctions.coloredEdges(),
3499
+ * });
3500
+ * ```
3501
+ */
3502
+ declare class ColorRetentionStrategy {
3503
+ private config;
3504
+ constructor(config: ColorRetentionConfig);
3505
+ apply(input: {
3506
+ stylized: ChannelImage;
3507
+ originalColor: RGBImage$1;
3508
+ }, configOverride?: Partial<ColorRetentionConfig>): Promise<RGBImage$1>;
3509
+ private buildMaskTransformChain;
3510
+ private buildColorTransformChain;
3511
+ private buildPostProcessChain;
3512
+ private createPixelContext;
3513
+ /**
3514
+ * Create a strategy from a preset
3515
+ */
3516
+ static preset(name: keyof typeof Presets): ColorRetentionStrategy;
3517
+ /**
3518
+ * Create a strategy with just a blend function
3519
+ */
3520
+ static withBlend(blend: BlendFn): ColorRetentionStrategy;
3521
+ /**
3522
+ * Builder pattern for constructing complex pipelines
3523
+ */
3524
+ static builder(): ColorRetentionBuilder;
3525
+ }
3526
+ /**
3527
+ * Fluent builder for constructing color retention pipelines
3528
+ *
3529
+ * @example
3530
+ * ```typescript
3531
+ * const strategy = ColorRetentionStrategy.builder()
3532
+ * .maskTransform(MaskTransforms.gamma(0.8))
3533
+ * .maskTransform(MaskTransforms.clamp(0.05, 0.95))
3534
+ * .colorTransform(ColorTransforms.saturation(1.2))
3535
+ * .blend(BlendFunctions.multiply)
3536
+ * .postProcess(PostProcessors.vignette(0.3))
3537
+ * .build();
3538
+ * ```
3539
+ */
3540
+ declare class ColorRetentionBuilder {
3541
+ private maskTransforms;
3542
+ private colorTransforms;
3543
+ private postProcesses;
3544
+ private blendFn?;
3545
+ private preProcessHook?;
3546
+ private globalPostProcessHook?;
3547
+ maskTransform(fn: MaskTransformFn): this;
3548
+ colorTransform(fn: ColorTransformFn): this;
3549
+ blend(fn: BlendFn): this;
3550
+ postProcess(fn: PostProcessFn): this;
3551
+ preProcess(fn: PreProcessHook): this;
3552
+ globalPostProcess(fn: GlobalPostProcessHook): this;
3553
+ build(): ColorRetentionStrategy;
3554
+ }
3555
+ /**
3556
+ * Collection of common blend functions
3557
+ */
3558
+ declare const BlendFunctions$1: {
3559
+ /**
3560
+ * Simple multiply: color * mask
3561
+ * White mask = full color, black mask = black
3562
+ */
3563
+ multiply: BlendFn;
3564
+ /**
3565
+ * Screen blend: 1 - (1-color) * (1-mask)
3566
+ * Creates lighter results
3567
+ */
3568
+ screen: BlendFn;
3569
+ /**
3570
+ * Overlay blend: combines multiply and screen
3571
+ */
3572
+ overlay: BlendFn;
3573
+ /**
3574
+ * Soft light blend: gentler than overlay
3575
+ */
3576
+ softLight: BlendFn;
3577
+ /**
3578
+ * Colored edges: black lines on colored background
3579
+ * Most common use case for line art + color
3580
+ */
3581
+ coloredEdges: (edgeStrength?: number) => BlendFn;
3582
+ /**
3583
+ * Tinted lines: edges take on underlying color
3584
+ */
3585
+ tintedLines: (darkness?: number) => BlendFn;
3586
+ /**
3587
+ * Luminosity replacement in HSL space
3588
+ */
3589
+ luminosity: BlendFn;
3590
+ /**
3591
+ * Linear interpolation between color and grayscale edge
3592
+ */
3593
+ lerp: (edgeColor?: Color) => BlendFn;
3594
+ /**
3595
+ * Preserve hue and saturation, replace value (HSV)
3596
+ */
3597
+ valueReplace: BlendFn;
3598
+ };
3599
+ /**
3600
+ * Collection of mask transformation functions
3601
+ */
3602
+ declare const MaskTransforms: {
3603
+ /**
3604
+ * Gamma correction for mask
3605
+ */
3606
+ gamma: (gamma: number) => MaskTransformFn;
3607
+ /**
3608
+ * Clamp mask to range
3609
+ */
3610
+ clamp: (min: number, max: number) => MaskTransformFn;
3611
+ /**
3612
+ * Remap mask from [inMin, inMax] to [outMin, outMax]
3613
+ */
3614
+ remap: (inMin: number, inMax: number, outMin?: number, outMax?: number) => MaskTransformFn;
3615
+ /**
3616
+ * Invert the mask
3617
+ */
3618
+ invert: () => MaskTransformFn;
3619
+ /**
3620
+ * Apply contrast adjustment
3621
+ */
3622
+ contrast: (amount: number) => MaskTransformFn;
3623
+ /**
3624
+ * Threshold with soft edges
3625
+ */
3626
+ softThreshold: (threshold: number, softness?: number) => MaskTransformFn;
3627
+ /**
3628
+ * Hard threshold (binary)
3629
+ */
3630
+ threshold: (threshold: number) => MaskTransformFn;
3631
+ /**
3632
+ * Quantize to N levels
3633
+ */
3634
+ quantize: (levels: number) => MaskTransformFn;
3635
+ /**
3636
+ * Morphological dilation (expand dark/edge regions)
3637
+ */
3638
+ dilate: (radius?: number) => MaskTransformFn;
3639
+ /**
3640
+ * Morphological erosion (shrink dark/edge regions)
3641
+ */
3642
+ erode: (radius?: number) => MaskTransformFn;
3643
+ /**
3644
+ * Gaussian blur approximation
3645
+ */
3646
+ blur: (radius?: number) => MaskTransformFn;
3647
+ /**
3648
+ * Add noise to mask
3649
+ */
3650
+ noise: (amount: number, seed?: number) => MaskTransformFn;
3651
+ };
3652
+ /**
3653
+ * Collection of color transformation functions
3654
+ */
3655
+ declare const ColorTransforms: {
3656
+ /**
3657
+ * Adjust saturation
3658
+ */
3659
+ saturation: (factor: number) => ColorTransformFn;
3660
+ /**
3661
+ * Adjust brightness
3662
+ */
3663
+ brightness: (amount: number) => ColorTransformFn;
3664
+ /**
3665
+ * Adjust contrast
3666
+ */
3667
+ contrast: (amount: number) => ColorTransformFn;
3668
+ /**
3669
+ * Shift hue
3670
+ */
3671
+ hueShift: (degrees: number) => ColorTransformFn;
3672
+ /**
3673
+ * Desaturate based on mask (less saturation in edge areas)
3674
+ */
3675
+ maskBasedDesaturate: (factor?: number) => ColorTransformFn;
3676
+ /**
3677
+ * Apply a color matrix transformation
3678
+ */
3679
+ colorMatrix: (matrix: number[][]) => ColorTransformFn;
3680
+ /**
3681
+ * Sepia tone
3682
+ */
3683
+ sepia: (intensity?: number) => ColorTransformFn;
3684
+ /**
3685
+ * Warm/cool temperature adjustment
3686
+ */
3687
+ temperature: (warmth: number) => ColorTransformFn;
3688
+ };
3689
+ /**
3690
+ * Collection of post-processing functions
3691
+ */
3692
+ declare const PostProcessors: {
3693
+ /**
3694
+ * Add vignette effect
3695
+ */
3696
+ vignette: (strength?: number, radius?: number) => PostProcessFn;
3697
+ /**
3698
+ * Add film grain
3699
+ */
3700
+ grain: (amount?: number, seed?: number) => PostProcessFn;
3701
+ /**
3702
+ * Blend with original color
3703
+ */
3704
+ blendOriginal: (amount: number) => PostProcessFn;
3705
+ /**
3706
+ * Clamp output to valid range
3707
+ */
3708
+ clampOutput: () => PostProcessFn;
3709
+ /**
3710
+ * Posterize (reduce color levels)
3711
+ */
3712
+ posterize: (levels: number) => PostProcessFn;
3713
+ /**
3714
+ * Edge-aware sharpening
3715
+ */
3716
+ sharpenEdges: (amount?: number) => PostProcessFn;
3717
+ };
3718
+ /**
3719
+ * Pre-built configurations for common use cases
3720
+ */
3721
+ declare const Presets: Record<string, ColorRetentionConfig>;
3722
+
3723
+ type colorRetention_BlendFn = BlendFn;
3724
+ type colorRetention_Color = Color;
3725
+ type colorRetention_ColorRetentionBuilder = ColorRetentionBuilder;
3726
+ declare const colorRetention_ColorRetentionBuilder: typeof ColorRetentionBuilder;
3727
+ type colorRetention_ColorRetentionConfig = ColorRetentionConfig;
3728
+ type colorRetention_ColorRetentionStrategy = ColorRetentionStrategy;
3729
+ declare const colorRetention_ColorRetentionStrategy: typeof ColorRetentionStrategy;
3730
+ type colorRetention_ColorTransformFn = ColorTransformFn;
3731
+ declare const colorRetention_ColorTransforms: typeof ColorTransforms;
3732
+ type colorRetention_GlobalPostProcessHook = GlobalPostProcessHook;
3733
+ type colorRetention_MaskTransformFn = MaskTransformFn;
3734
+ declare const colorRetention_MaskTransforms: typeof MaskTransforms;
3735
+ type colorRetention_PixelContext = PixelContext;
3736
+ type colorRetention_PostProcessFn = PostProcessFn;
3737
+ declare const colorRetention_PostProcessors: typeof PostProcessors;
3738
+ type colorRetention_PreProcessHook = PreProcessHook;
3739
+ declare const colorRetention_Presets: typeof Presets;
3740
+ declare namespace colorRetention {
3741
+ export { BlendFunctions$1 as BlendFunctions, colorRetention_ColorRetentionBuilder as ColorRetentionBuilder, colorRetention_ColorRetentionStrategy as ColorRetentionStrategy, colorRetention_ColorTransforms as ColorTransforms, colorRetention_MaskTransforms as MaskTransforms, colorRetention_PostProcessors as PostProcessors, colorRetention_Presets as Presets };
3742
+ export type { colorRetention_BlendFn as BlendFn, colorRetention_Color as Color, colorRetention_ColorRetentionConfig as ColorRetentionConfig, colorRetention_ColorTransformFn as ColorTransformFn, colorRetention_GlobalPostProcessHook as GlobalPostProcessHook, colorRetention_MaskTransformFn as MaskTransformFn, colorRetention_PixelContext as PixelContext, colorRetention_PostProcessFn as PostProcessFn, colorRetention_PreProcessHook as PreProcessHook };
3743
+ }
3744
+
3745
+ /**
3746
+ * Hatching texture specification
3747
+ */
3748
+ interface HatchTexture {
3749
+ /** Grayscale texture data (tiled as needed) */
3750
+ data: ChannelImage;
3751
+ /** Rotation angle in radians (0 = horizontal) */
3752
+ rotation: number;
3753
+ }
3754
+ /**
3755
+ * Hatching configuration
3756
+ *
3757
+ * From Section 5.1: "Our hatching approach is based on the concept of
3758
+ * tonal art maps, where layers of strokes add up to achieve a desired tone"
3759
+ */
3760
+ interface HatchingConfig {
3761
+ /**
3762
+ * Threshold levels for creating masks (ascending order)
3763
+ * Each level creates a separate tone band
3764
+ * Default: [0.3, 0.5, 0.7] creates 4 bands
3765
+ */
3766
+ thresholdLevels: number[];
3767
+ /**
3768
+ * Hatching textures for each band (darkest to lightest)
3769
+ * Should have length = thresholdLevels.length + 1
3770
+ */
3771
+ textures?: HatchTexture[];
3772
+ /**
3773
+ * Background/paper texture (optional)
3774
+ */
3775
+ paperTexture?: ChannelImage;
3776
+ /**
3777
+ * Sharpening strength for threshold masks (default: 20)
3778
+ */
3779
+ p: number;
3780
+ /**
3781
+ * Smoothness of threshold transitions (default: 10)
3782
+ * Lower values = softer transitions between bands
3783
+ * Higher values = sharper band boundaries
3784
+ */
3785
+ phi: number;
3786
+ /**
3787
+ * Whether to use cumulative (tonal art map) style (default: true)
3788
+ * When true: darker areas accumulate more hatching layers
3789
+ * When false: each band is independent
3790
+ */
3791
+ cumulative: boolean;
3792
+ }
3793
+ /**
3794
+ * Hatching Strategy
3795
+ *
3796
+ * Creates tonal art maps by computing multiple threshold levels from a
3797
+ * sharpened XDoG/FDoG image and using them as masks for hatching textures.
3798
+ *
3799
+ * The key insight from tonal art maps is that darker tones are achieved by
3800
+ * ACCUMULATING hatching layers - dark areas have all hatching layers active,
3801
+ * while light areas have none.
3802
+ *
3803
+ * @example
3804
+ * ```typescript
3805
+ * const xdog = new XDoG({ p: 20 });
3806
+ * const { sharpened } = await xdog.processDetailed(input);
3807
+ *
3808
+ * const hatching = new HatchingStrategy({
3809
+ * thresholdLevels: [0.25, 0.5, 0.75],
3810
+ * textures: [darkHatch, medHatch, lightHatch, white],
3811
+ * });
3812
+ * const result = await hatching.apply({ sharpened, original: input });
3813
+ * ```
3814
+ */
3815
+ declare class HatchingStrategy implements ExtensionStrategy<HatchingConfig, {
3816
+ sharpened: ChannelImage;
3817
+ original?: ChannelImage;
3818
+ }, ChannelImage> {
3819
+ private config;
3820
+ constructor(config?: Partial<HatchingConfig>);
3821
+ /**
3822
+ * Generate cumulative threshold masks for tonal art maps
3823
+ *
3824
+ * For tonal art maps, we generate masks where:
3825
+ * - Mask 0 (darkest hatching): active where input < levels[0]
3826
+ * - Mask 1: active where input < levels[1]
3827
+ * - Mask N (lightest): active everywhere (or where input < 1.0)
3828
+ *
3829
+ * Each darker mask is a SUBSET of the lighter masks, creating the
3830
+ * cumulative effect where dark areas have more hatching.
3831
+ */
3832
+ generateMasks(sharpened: ChannelImage, configOverride?: Partial<HatchingConfig>): ChannelImage[];
3833
+ apply(input: {
3834
+ sharpened: ChannelImage;
3835
+ original?: ChannelImage;
3836
+ }, configOverride?: Partial<HatchingConfig>): Promise<ChannelImage>;
3837
+ /**
3838
+ * Sample a texture with tiling and rotation
3839
+ */
3840
+ private sampleTexture;
3841
+ /**
3842
+ * Generate a simple procedural hatching texture
3843
+ *
3844
+ * Creates parallel lines at the specified spacing and thickness.
3845
+ * The rotation parameter rotates the SAMPLING, not the line pattern itself.
3846
+ */
3847
+ static generateHatchTexture(width: number, height: number, spacing: number, thickness: number, rotation?: number): HatchTexture;
3848
+ /**
3849
+ * Generate a cross-hatching texture (two overlapping line patterns)
3850
+ */
3851
+ static generateCrossHatchTexture(width: number, height: number, spacing: number, thickness: number, angle1?: number, angle2?: number): HatchTexture;
3852
+ }
3853
+
3854
+ /**
3855
+ * Natural media style presets
3856
+ */
3857
+ type NaturalMediaStyle = 'pencilShading' | 'pastel' | 'charcoal' | 'dryBrush';
3858
+ /**
3859
+ * Natural media configuration
3860
+ *
3861
+ * From Section 5.2: Parameters for various natural media looks
3862
+ */
3863
+ interface NaturalMediaConfig {
3864
+ /** Base style preset */
3865
+ style: NaturalMediaStyle;
3866
+ /** Override sigma for edge detection */
3867
+ sigma?: number;
3868
+ /** Override p for edge emphasis */
3869
+ p?: number;
3870
+ /** Override phi for threshold sharpness */
3871
+ phi?: number;
3872
+ /** Override epsilon for threshold level */
3873
+ epsilon?: number;
3874
+ /** For FDoG: structure tensor smoothing */
3875
+ sigmaC?: number;
3876
+ /** For FDoG: flow-aligned smoothing */
3877
+ sigmaM?: number;
3878
+ /** For FDoG: anti-aliasing */
3879
+ sigmaA?: number;
3880
+ /** Use flow-based processing (FDoG) */
3881
+ useFlow?: boolean;
3882
+ }
3883
+ /**
3884
+ * Natural Media Strategy
3885
+ *
3886
+ * Provides preset parameter configurations for pencil, pastel, charcoal,
3887
+ * and other natural media styles as described in Section 5.2.
3888
+ *
3889
+ * @example
3890
+ * ```typescript
3891
+ * const naturalMedia = new NaturalMediaStrategy({ style: 'pastel' });
3892
+ * const result = await naturalMedia.apply(input);
3893
+ * ```
3894
+ */
3895
+ declare class NaturalMediaStrategy implements ExtensionStrategy<NaturalMediaConfig, ChannelImage, ChannelImage> {
3896
+ private config;
3897
+ /**
3898
+ * Style presets from Section 5.2 and Table A.1
3899
+ *
3900
+ * Note on epsilon values:
3901
+ * - epsilon is the threshold for white vs black transition (0-1 range)
3902
+ * - Values ABOVE epsilon become white, values BELOW follow soft threshold
3903
+ * - For natural media effects, we want lower epsilon values to preserve
3904
+ * more tonal variation and avoid all-white output
3905
+ */
3906
+ static readonly PRESETS: Record<NaturalMediaStyle, Partial<FDoGConfig> & {
3907
+ useFlow: boolean;
3908
+ }>;
3909
+ constructor(config?: Partial<NaturalMediaConfig>);
3910
+ /**
3911
+ * Get the resolved configuration for the current style
3912
+ */
3913
+ getResolvedConfig(): Partial<FDoGConfig> & {
3914
+ useFlow: boolean;
3915
+ };
3916
+ apply(input: ChannelImage, configOverride?: Partial<NaturalMediaConfig>): Promise<ChannelImage>;
3917
+ /**
3918
+ * Create strategy for a specific style
3919
+ */
3920
+ static forStyle(style: NaturalMediaStyle): NaturalMediaStrategy;
3921
+ }
3922
+
3923
+ /**
3924
+ * Multi-Scale Strategy Types and Implementation
3925
+ *
3926
+ * Refactored to use function-based blending, allowing users to either:
3927
+ * 1. Use the provided blend functions (average, min, max, multiply)
3928
+ * 2. Supply their own custom blend function
3929
+ */
3930
+
3931
+ /**
3932
+ * Context provided to blend functions for each pixel
3933
+ */
3934
+ interface BlendContext {
3935
+ /** Pixel values from each layer at the current position */
3936
+ values: number[];
3937
+ /** Normalized weights for each layer (sum to 1.0) */
3938
+ weights: number[];
3939
+ /** Current pixel x coordinate */
3940
+ x: number;
3941
+ /** Current pixel y coordinate */
3942
+ y: number;
3943
+ /** Image width */
3944
+ width: number;
3945
+ /** Image height */
3946
+ height: number;
3947
+ }
3948
+ /**
3949
+ * Function type for blending multiple layer values into a single output value.
3950
+ *
3951
+ * @param ctx - Context containing pixel values, weights, and position info
3952
+ * @returns The blended output value (should be in 0-1 range)
3953
+ *
3954
+ * @example Custom blend function
3955
+ * ```typescript
3956
+ * const softMin: BlendFunction = (ctx) => {
3957
+ * // Soft minimum using negative log-sum-exp
3958
+ * const k = 10; // sharpness parameter
3959
+ * const sumExp = ctx.values.reduce((sum, v) => sum + Math.exp(-k * v), 0);
3960
+ * return -Math.log(sumExp / ctx.values.length) / k;
3961
+ * };
3962
+ * ```
3963
+ */
3964
+ type BlendFunction = (ctx: BlendContext) => number;
3965
+ /**
3966
+ * Weighted average blend - smoothly combines all layers
3967
+ *
3968
+ * Best for: Balanced multi-scale results, general purpose
3969
+ */
3970
+ declare const blendAverage: BlendFunction;
3971
+ /**
3972
+ * Minimum blend - takes the darkest value at each pixel
3973
+ *
3974
+ * Best for: Preserving fine details, ensuring all edges are captured
3975
+ * Since edges are dark (0) on white (1), min keeps all detected edges
3976
+ */
3977
+ declare const blendMin: BlendFunction;
3978
+ /**
3979
+ * Maximum blend - takes the brightest value at each pixel
3980
+ *
3981
+ * Best for: Abstract styles where only strong edges should appear
3982
+ * Removes edges that don't appear in all scales
3983
+ */
3984
+ declare const blendMax: BlendFunction;
3985
+ /**
3986
+ * Multiply blend - multiplies all layer values together
3987
+ *
3988
+ * Best for: Strong edge emphasis, high contrast results
3989
+ * Areas that are dark in any layer become very dark
3990
+ */
3991
+ declare const blendMultiply: BlendFunction;
3992
+ /**
3993
+ * Screen blend - inverse of multiply, brightens the result
3994
+ *
3995
+ * Best for: Lighter, more ethereal line drawings
3996
+ */
3997
+ declare const blendScreen: BlendFunction;
3998
+ /**
3999
+ * Soft light blend - subtle contrast enhancement
4000
+ *
4001
+ * Best for: Natural-looking multi-scale combination
4002
+ */
4003
+ declare const blendSoftLight: BlendFunction;
4004
+ /**
4005
+ * Overlay blend - combines multiply and screen based on base value
4006
+ *
4007
+ * Best for: High contrast results that preserve both highlights and shadows
4008
+ */
4009
+ declare const blendOverlay: BlendFunction;
4010
+ /**
4011
+ * Geometric mean blend - multiplicative average, less extreme than multiply
4012
+ *
4013
+ * Best for: Balanced darkening that respects layer weights
4014
+ */
4015
+ declare const blendGeometricMean: BlendFunction;
4016
+ /**
4017
+ * Harmonic mean blend - emphasizes smaller values more than arithmetic mean
4018
+ *
4019
+ * Best for: Preserving fine details while still allowing averaging
4020
+ */
4021
+ declare const blendHarmonicMean: BlendFunction;
4022
+ /**
4023
+ * Median blend - selects the middle value, robust to outliers
4024
+ *
4025
+ * Best for: Noise-resistant combination when layer count is odd
4026
+ */
4027
+ declare const blendMedian: BlendFunction;
4028
+ /**
4029
+ * Soft min blend - smooth approximation of minimum using log-sum-exp
4030
+ *
4031
+ * Best for: Capturing all edges with smoother transitions than hard min
4032
+ */
4033
+ declare const blendSoftMin: BlendFunction;
4034
+ /**
4035
+ * Soft max blend - smooth approximation of maximum using log-sum-exp
4036
+ *
4037
+ * Best for: Selecting dominant edges with smoother transitions than hard max
4038
+ */
4039
+ declare const blendSoftMax: BlendFunction;
4040
+ /**
4041
+ * Difference blend - absolute difference between layers (best with 2 layers)
4042
+ *
4043
+ * Best for: Highlighting scale-dependent features, edge comparison
4044
+ */
4045
+ declare const blendDifference: BlendFunction;
4046
+ /**
4047
+ * Priority blend - uses fine scale unless coarse scale has strong edges
4048
+ *
4049
+ * Best for: Detail preservation with fallback to coarse structure
4050
+ * Assumes layers ordered fine-to-coarse (first = finest detail)
4051
+ */
4052
+ declare const blendPriority: BlendFunction;
4053
+ /**
4054
+ * Collection of all built-in blend functions for easy access
4055
+ */
4056
+ declare const BlendFunctions: Record<string, BlendFunction>;
4057
+ /**
4058
+ * Type representing the names of built-in blend functions
4059
+ */
4060
+ type BuiltinBlendMode = keyof typeof BlendFunctions;
4061
+ /**
4062
+ * Configuration for a single scale layer
4063
+ */
4064
+ interface MultiScaleLayer {
4065
+ /** Pre-configured XDoG or FDoG processor instance */
4066
+ processor: DoGImplementation;
4067
+ /** Weight for blending (will be normalized) */
4068
+ weight: number;
4069
+ }
4070
+ /**
4071
+ * Multi-scale configuration
4072
+ */
4073
+ interface MultiScaleConfig {
4074
+ /** Layer specifications with processor instances */
4075
+ layers: MultiScaleLayer[];
4076
+ /**
4077
+ * Blend function for combining layers.
4078
+ *
4079
+ * Can be either:
4080
+ * - A built-in blend function from BlendFunctions (e.g., BlendFunctions.min)
4081
+ * - A custom BlendFunction
4082
+ *
4083
+ * @example Using built-in
4084
+ * ```typescript
4085
+ * { layers: [...], blend: BlendFunctions.average }
4086
+ * ```
4087
+ *
4088
+ * @example Using custom function
4089
+ * ```typescript
4090
+ * {
4091
+ * layers: [...],
4092
+ * blend: (ctx) => {
4093
+ * // Custom logic using ctx.values, ctx.weights, ctx.x, ctx.y
4094
+ * return Math.min(...ctx.values) * 0.8 + ctx.values[0] * 0.2;
4095
+ * }
4096
+ * }
4097
+ * ```
4098
+ */
4099
+ blend: BlendFunction;
4100
+ }
4101
+ /**
4102
+ * Multi-Scale Strategy
4103
+ *
4104
+ * Combines XDoG/FDoG results at different scales for scale-space
4105
+ * edge detection. Accepts pre-configured processor instances, giving
4106
+ * developers full control over each layer's configuration.
4107
+ *
4108
+ * From Section 3.1 (Abstraction): Different σ values capture different
4109
+ * levels of detail.
4110
+ *
4111
+ * @example Using built-in blend function
4112
+ * ```typescript
4113
+ * const multiScale = new MultiScaleStrategy({
4114
+ * layers: [
4115
+ * { processor: new XDoG({ sigma: 0.5, p: 30 }), weight: 1 },
4116
+ * { processor: new FDoG({ sigma: 2.0, sigmaM: 4.0 }), weight: 2 },
4117
+ * ],
4118
+ * blend: BlendFunctions.min,
4119
+ * });
4120
+ * const result = await multiScale.apply(input);
4121
+ * ```
4122
+ *
4123
+ * @example Using custom blend function
4124
+ * ```typescript
4125
+ * const multiScale = new MultiScaleStrategy({
4126
+ * layers: [
4127
+ * { processor: new XDoG({ sigma: 0.4, p: 20 }), weight: 2 },
4128
+ * { processor: new FDoG({ sigma: 1.6, sigmaM: 4.0 }), weight: 1 },
4129
+ * ],
4130
+ * blend: (ctx) => {
4131
+ * // Weighted geometric mean
4132
+ * let logSum = 0;
4133
+ * for (let i = 0; i < ctx.values.length; i++) {
4134
+ * logSum += ctx.weights[i] * Math.log(ctx.values[i] + 0.001);
4135
+ * }
4136
+ * return Math.exp(logSum);
4137
+ * },
4138
+ * });
4139
+ * ```
4140
+ *
4141
+ * @example Position-dependent blending
4142
+ * ```typescript
4143
+ * const vignetteBlend: BlendFunction = (ctx) => {
4144
+ * // Use fine details in center, coarse at edges
4145
+ * const cx = ctx.width / 2, cy = ctx.height / 2;
4146
+ * const dist = Math.sqrt((ctx.x - cx) ** 2 + (ctx.y - cy) ** 2);
4147
+ * const maxDist = Math.sqrt(cx ** 2 + cy ** 2);
4148
+ * const t = dist / maxDist; // 0 at center, 1 at corners
4149
+ *
4150
+ * // Interpolate between first layer (fine) and last layer (coarse)
4151
+ * return ctx.values[0] * (1 - t) + ctx.values[ctx.values.length - 1] * t;
4152
+ * };
4153
+ * ```
4154
+ */
4155
+ declare class MultiScaleStrategy implements ExtensionStrategy<MultiScaleConfig, ChannelImage, ChannelImage> {
4156
+ private config;
4157
+ constructor(config: MultiScaleConfig);
4158
+ apply(input: ChannelImage, configOverride?: Partial<Pick<MultiScaleConfig, 'blend'>>): Promise<ChannelImage>;
4159
+ private blendLayers;
4160
+ /**
4161
+ * Create a preset multi-scale configuration
4162
+ */
4163
+ static withPreset(preset: 'detailed' | 'balanced' | 'abstract'): MultiScaleStrategy;
4164
+ /**
4165
+ * Get the configured layers (useful for inspection/debugging)
4166
+ */
4167
+ getLayers(): ReadonlyArray<MultiScaleLayer>;
4168
+ /**
4169
+ * Get the blend function
4170
+ */
4171
+ getBlendFunction(): BlendFunction;
4172
+ }
4173
+ /**
4174
+ * Creates a weighted percentile blend function
4175
+ *
4176
+ * @param percentile - Value from 0 to 1 (0 = min, 0.5 = median, 1 = max)
4177
+ * @returns A blend function that selects the given percentile
4178
+ *
4179
+ * @example
4180
+ * ```typescript
4181
+ * const medianBlend = createPercentileBlend(0.5);
4182
+ * const multiScale = new MultiScaleStrategy({
4183
+ * layers: [...],
4184
+ * blend: medianBlend,
4185
+ * });
4186
+ * ```
4187
+ */
4188
+ declare function createPercentileBlend(percentile: number): BlendFunction;
4189
+ /**
4190
+ * Creates a blend function that interpolates between two other blend functions
4191
+ * based on a spatial mask or gradient
4192
+ *
4193
+ * @param blendA - First blend function
4194
+ * @param blendB - Second blend function
4195
+ * @param mixer - Function that returns interpolation factor (0 = use A, 1 = use B)
4196
+ * @returns Combined blend function
4197
+ *
4198
+ * @example Radial gradient between min and average
4199
+ * ```typescript
4200
+ * const radialBlend = createMixedBlend(
4201
+ * BlendFunctions.min,
4202
+ * BlendFunctions.average,
4203
+ * (ctx) => {
4204
+ * const cx = ctx.width / 2, cy = ctx.height / 2;
4205
+ * const dist = Math.hypot(ctx.x - cx, ctx.y - cy);
4206
+ * const maxDist = Math.hypot(cx, cy);
4207
+ * return dist / maxDist;
4208
+ * }
4209
+ * );
4210
+ * ```
4211
+ */
4212
+ declare function createMixedBlend(blendA: BlendFunction, blendB: BlendFunction, mixer: (ctx: BlendContext) => number): BlendFunction;
4213
+ /**
4214
+ * Creates a blend function that applies gamma correction to another blend
4215
+ *
4216
+ * @param baseBlend - The base blend function
4217
+ * @param gamma - Gamma value (< 1 brightens, > 1 darkens)
4218
+ * @returns Gamma-corrected blend function
4219
+ */
4220
+ declare function createGammaCorrectedBlend(baseBlend: BlendFunction, gamma: number): BlendFunction;
4221
+
4222
+ type multiScale_BlendContext = BlendContext;
4223
+ type multiScale_BlendFunction = BlendFunction;
4224
+ declare const multiScale_BlendFunctions: typeof BlendFunctions;
4225
+ type multiScale_BuiltinBlendMode = BuiltinBlendMode;
4226
+ type multiScale_MultiScaleConfig = MultiScaleConfig;
4227
+ type multiScale_MultiScaleLayer = MultiScaleLayer;
4228
+ type multiScale_MultiScaleStrategy = MultiScaleStrategy;
4229
+ declare const multiScale_MultiScaleStrategy: typeof MultiScaleStrategy;
4230
+ declare const multiScale_blendAverage: typeof blendAverage;
4231
+ declare const multiScale_blendDifference: typeof blendDifference;
4232
+ declare const multiScale_blendGeometricMean: typeof blendGeometricMean;
4233
+ declare const multiScale_blendHarmonicMean: typeof blendHarmonicMean;
4234
+ declare const multiScale_blendMax: typeof blendMax;
4235
+ declare const multiScale_blendMedian: typeof blendMedian;
4236
+ declare const multiScale_blendMin: typeof blendMin;
4237
+ declare const multiScale_blendMultiply: typeof blendMultiply;
4238
+ declare const multiScale_blendOverlay: typeof blendOverlay;
4239
+ declare const multiScale_blendPriority: typeof blendPriority;
4240
+ declare const multiScale_blendScreen: typeof blendScreen;
4241
+ declare const multiScale_blendSoftLight: typeof blendSoftLight;
4242
+ declare const multiScale_blendSoftMax: typeof blendSoftMax;
4243
+ declare const multiScale_blendSoftMin: typeof blendSoftMin;
4244
+ declare const multiScale_createGammaCorrectedBlend: typeof createGammaCorrectedBlend;
4245
+ declare const multiScale_createMixedBlend: typeof createMixedBlend;
4246
+ declare const multiScale_createPercentileBlend: typeof createPercentileBlend;
4247
+ declare namespace multiScale {
4248
+ export { multiScale_BlendFunctions as BlendFunctions, multiScale_MultiScaleStrategy as MultiScaleStrategy, multiScale_blendAverage as blendAverage, multiScale_blendDifference as blendDifference, multiScale_blendGeometricMean as blendGeometricMean, multiScale_blendHarmonicMean as blendHarmonicMean, multiScale_blendMax as blendMax, multiScale_blendMedian as blendMedian, multiScale_blendMin as blendMin, multiScale_blendMultiply as blendMultiply, multiScale_blendOverlay as blendOverlay, multiScale_blendPriority as blendPriority, multiScale_blendScreen as blendScreen, multiScale_blendSoftLight as blendSoftLight, multiScale_blendSoftMax as blendSoftMax, multiScale_blendSoftMin as blendSoftMin, multiScale_createGammaCorrectedBlend as createGammaCorrectedBlend, multiScale_createMixedBlend as createMixedBlend, multiScale_createPercentileBlend as createPercentileBlend };
4249
+ export type { multiScale_BlendContext as BlendContext, multiScale_BlendFunction as BlendFunction, multiScale_BuiltinBlendMode as BuiltinBlendMode, multiScale_MultiScaleConfig as MultiScaleConfig, multiScale_MultiScaleLayer as MultiScaleLayer };
4250
+ }
4251
+
4252
+ /**
4253
+ * Convert ImageData to RGBImage
4254
+ */
4255
+ declare function imageDataToRGB(imageData: ImageData): RGBImage;
4256
+ /**
4257
+ * Convert RGBImage to ImageData
4258
+ */
4259
+ declare function rgbToImageData(rgb: RGBImage): ImageData;
4260
+ /**
4261
+ * Convert grayscale to RGB (same value in all channels)
4262
+ */
4263
+ declare function grayscaleToRGB(gray: ChannelImage): RGBImage;
4264
+
4265
+ /**
4266
+ * XDoG/FDoG Extensions Module
4267
+ *
4268
+ * Provides composable strategy patterns for extending XDoG/FDoG output:
4269
+ * - Hatching: Multiple threshold masks for tonal art maps
4270
+ * - Natural Media: Pencil, pastel, charcoal effects via parameter tuning
4271
+ * - Anti-aliasing: LIC pass along edge tangent flow
4272
+ * - Color Retention: Modulating stylized output with source colors
4273
+ * - Multi-scale: Combining results at different σ values
4274
+ *
4275
+ * Based on Sections 4.3, 5.1, 5.2 of:
4276
+ * "XDoG: An eXtended difference-of-Gaussians compendium including
4277
+ * advanced image stylization" by Winnemöller et al. (2012)
4278
+ *
4279
+ * Design Philosophy:
4280
+ * - Each extension is a standalone strategy that can be composed
4281
+ * - Developers control XDoG vs FDoG choice and parameters
4282
+ * - Extensions accept pre-processed results or raw images
4283
+ * - Chainable pipeline architecture
4284
+ */
4285
+
4286
+ type index_AntiAliasingConfig = AntiAliasingConfig;
4287
+ type index_AntiAliasingStrategy = AntiAliasingStrategy;
4288
+ declare const index_AntiAliasingStrategy: typeof AntiAliasingStrategy;
4289
+ type index_BlendContext = BlendContext;
4290
+ type index_BlendFunction = BlendFunction;
4291
+ type index_BuiltinBlendMode = BuiltinBlendMode;
4292
+ type index_Color = Color;
4293
+ type index_ColorRetentionConfig = ColorRetentionConfig;
4294
+ type index_ColorTransformFn = ColorTransformFn;
4295
+ type index_DoGResult = DoGResult;
4296
+ type index_ExtensionStrategy<TConfig, TInput, TOutput> = ExtensionStrategy<TConfig, TInput, TOutput>;
4297
+ type index_HatchTexture = HatchTexture;
4298
+ type index_HatchingConfig = HatchingConfig;
4299
+ type index_HatchingStrategy = HatchingStrategy;
4300
+ declare const index_HatchingStrategy: typeof HatchingStrategy;
4301
+ type index_MaskTransformFn = MaskTransformFn;
4302
+ type index_MultiScaleConfig = MultiScaleConfig;
4303
+ type index_MultiScaleLayer = MultiScaleLayer;
4304
+ type index_NaturalMediaConfig = NaturalMediaConfig;
4305
+ type index_NaturalMediaStrategy = NaturalMediaStrategy;
4306
+ declare const index_NaturalMediaStrategy: typeof NaturalMediaStrategy;
4307
+ type index_NaturalMediaStyle = NaturalMediaStyle;
4308
+ type index_PostProcessFn = PostProcessFn;
4309
+ declare const index_colorRetention: typeof colorRetention;
4310
+ declare const index_grayscaleToRGB: typeof grayscaleToRGB;
4311
+ declare const index_imageDataToRGB: typeof imageDataToRGB;
4312
+ declare const index_multiScale: typeof multiScale;
4313
+ declare const index_rgbToImageData: typeof rgbToImageData;
4314
+ declare namespace index {
4315
+ export { index_AntiAliasingStrategy as AntiAliasingStrategy, index_HatchingStrategy as HatchingStrategy, index_NaturalMediaStrategy as NaturalMediaStrategy, index_colorRetention as colorRetention, index_grayscaleToRGB as grayscaleToRGB, index_imageDataToRGB as imageDataToRGB, index_multiScale as multiScale, index_rgbToImageData as rgbToImageData };
4316
+ export type { index_AntiAliasingConfig as AntiAliasingConfig, index_BlendContext as BlendContext, index_BlendFunction as BlendFunction, index_BuiltinBlendMode as BuiltinBlendMode, index_Color as Color, index_ColorRetentionConfig as ColorRetentionConfig, index_ColorTransformFn as ColorTransformFn, index_DoGResult as DoGResult, index_ExtensionStrategy as ExtensionStrategy, index_HatchTexture as HatchTexture, index_HatchingConfig as HatchingConfig, index_MaskTransformFn as MaskTransformFn, index_MultiScaleConfig as MultiScaleConfig, index_MultiScaleLayer as MultiScaleLayer, index_NaturalMediaConfig as NaturalMediaConfig, index_NaturalMediaStyle as NaturalMediaStyle, index_PostProcessFn as PostProcessFn };
4317
+ }
4318
+
4319
+ export { DEFAULT_BILATERAL_CONFIG, DEFAULT_CONTRAST_ENHANCEMENT_CONFIG, DEFAULT_ETF_CONFIG, DEFAULT_GAUSSIAN_CONFIG, DEFAULT_GRADIENT_ALIGNED_BLUR_CONFIG, DEFAULT_ISOTROPIC_BLUR_CONFIG, DEFAULT_KUWAHARA_CONFIG, DEFAULT_MEDIAN_CONFIG, DEFAULT_QUANTIZER_CONFIG, DoGProcessor, EdgeTangentFlowComputer, ThresholdModes, applyCustomThreshold, index$6 as blur, index$7 as dog, index as extensions, index$4 as filters, index$2 as preprocess, threshold, index$1 as utilities };
4320
+ export type { ADoGConfig, ADoGProcessingResult, ADogConfigParamType, AntiAliasingConfig, BackendOptions, BilateralFilterConfig, BlendFunction, BlurStrategy, ChannelImage, ColorRetentionConfig, ColorTransformFn, ContrastEnhancementConfig, DoGConfig, DoGImplementation, DoGResult, DogConfigParamType, ETFConfig, ExtensionStrategy, FDoGConfidenceWeightingConfig, FDoGConfig, FDogConfidenceWeightConfigParamType, FDogConfigParamType, FlowField, FlowGuidedBlurConfig, GradientAlignedBlurConfig, HDoGConfig, HDoGProcessingResult, HDogConfigParamType, HatchTexture, HatchingConfig, IsotropicBlurConfig, KuwaharaFilterConfig, LocalBaselineOptions, LocalVarianceConfig, MagnitudeAdaptiveOptions, MaskTransformFn, MedianFilterConfig, MultiScaleConfig, MultiScaleLayer, NaturalMediaConfig, NaturalMediaStyle, ParamRange, PostProcessFn, Preprocessor, QuantizerConfig, RGBImage$1 as RGBImage, ThresholdConfig, ThresholdStrategy, ToneAdaptiveAutoOptions, ToneAdaptiveOptions, VarianceAdaptiveOptions, Vec2, XDoGConfig };