Skip to content
image-classification · basics 2D DFT Spectrum · 16×16 Patch Map WASM q8 · 22.44 MB License: Apache-2.0

Inside Moiré Detection: Spatial Frequency Sweep & Patch Sensitivity

LCD screen recapture injects periodic beat peaks into the 2D spatial frequency spectrum. Sweep synthetic moiré interference from 0% → 100% to watch high-frequency DFT energy climb and flip the DeiT-Small/16 logits, then run a 4×4 occlusion sweep (16 real passes) to locate where screen stripes drive the decision.

1 · DeiT-Small/16 ViT pipeline inside the detector

Exact parameters from onnx-community/document-moire-detector-ONNX/config.json: image_size: 224, patch_size: 16 (14×14 = 196 patches), num_hidden_layers: 12, num_attention_heads: 6, hidden_size: 384.

2 · 2D DFT Spatial Frequency & Moiré Strength Sweep (0% → 100%)

Initialising model loader…

Document preview with LCD interference

Centered 2D DFT magnitude (bright off-center peaks inside/outside dashed ring = periodic moiré waves)

High-freq DFT energy–
Mid-freq DFT energy–
0% baseline Clean–
Flip threshold–
Peak Moiré score–
NaN / invalid0
Live 0% → 100% LCD Moiré Strength Sweep vs 2D High-Frequency Energy
Moiré strength High-freq DFT Clean prob Moiré prob Verdict Latency
Run the 0% → 100% sweep to measure where periodic interference flips the ViT logit.

3 · 4×4 Patch Occlusion Sensitivity Map (16×16 ViT Patches)

Masks one 56×56 region (covering ~3.5×3.5 patches of the 14×14 ViT token grid) at a time on the current preview strength and measures how much the baseline Top-1 score drops.

Low impact Critical patch region (large drop)

Click any cell after running the 4×4 occlusion sweep.

Baseline class–
Baseline score–
Peak cell drop–
Label flips (of 16)–
Mean pass ms–

Selected 56×56 cell details appear here after running.

4×4 region occlusion sensitivity ranking (sorted by target-class probability drop)
Cell 56×56 region Occluded score Score drop Occluded Top-1 Inspect
Run the 4×4 Patch Occlusion sweep above to populate cell scores.

See inside the code

Show the code — moire-core.mjs: computeSpatialSpectrum() (2D DFT energy ratio)
Show the code — moire-core.mjs: computeOcclusionGrid() & computeOcclusionSaliency()
Show the code — moire.js: drawSpectrumCanvas() (centered 2D DFT log-magnitude plot)

References