FAQ (Frequently Asked Questions)
Common issues and their solutions.
WASM Loading Fails in Node.js
Symptom
Error: Could not load WASM module or similar.
Cause
The .wasm binary is not found relative to index.js.
Fix
Ensure build-wasm/index.wasm is present alongside index.js in the installed package:
ls node_modules/img2num/build-wasm/
If missing, reinstall:
npm uninstall img2num
npm install img2num
Bundler Configuration
If the .wasm file exists but loading still fails, your bundler may need explicit *.wasm asset handling.
Include WASM files as assets in vite.config.js:
export default defineConfig({
assetsInclude: ["**/*.wasm"],
});
If you encounter any problems, please open an issue so we can document the solution.
Blurry or Over-Smoothed Output with Bilateral Filter
If the result appears over-smoothed (loss of edge detail), reduce the spatial standard deviation
(sigma_spatial / ).
If the result is too noisy or insufficiently smoothed, increase it.
Note that bilateral filtering depends on both spatial and range parameters:
sigma_spatial() controls geometric smoothingsigma_range() controls intensity similarity sensitivity
Both parameters may need to be adjusted per image depending on texture and noise levels.
The default Img2Num bilateral filter parameters are tuned for general natural images and typically produce balanced results.
While fixed parameters work well in most cases, adaptive smoothing strategies are commonly used in image processing literature to account for variation in noise level and edge density across images (Marr & Hildreth, 1980; Canny, 1986).
Jagged / Noisy SVG Paths
Increase min_area to filter out tiny contours, or increase sigma_spatial to smooth noise before clustering.
K-Means Runs Slow in the Browser
K-means can take seconds on large images. Try:
- Lowering
num_colors - Lowering
max_iter - Using a smaller source image for development
Memory Errors (OOM)
The WASM heap is fixed at compile time. Very large images may exceed it. Consider:
- Downscaling the input image
- Splitting the image into tiles
Missing CIE LAB Output
Make sure color_space = 0 (default). color_space = 1 uses sRGB which may produce different cluster boundaries.