arXiv:2608.23299cs.CVAug 2026

Manuscript Offprint

arXiv:2608.23299

What Remains Normal? Clean Images Miss Useful Near-Defect Normal Patches for Anomaly Detection

Joongwon Chae, Runming Wang, Peiwu Qin

Abstract

Normal-only industrial anomaly detectors use patches from clean training images as normal references or reconstruction targets. This assumes that clean patches are sufficient for the normal regions encountered at test time. We test that assumption directly. On MVTec AD, admitting ground-truth-normal patches from real defect images to a DINOv2 memory candidate pool raises pixel average precision (P-AP) from 73.34 to 76.95 while keeping the encoder, test-time score, and number of stored references fixed. Patches within two patch cells of the annotated defect recover 94.70% of this gain. We then ask whether useful patches of this kind can be exposed using clean training images alone. BOUNDARYSUPPORT inserts a procedural synthetic defect to alter surrounding context, excludes every token intersecting the nominal insertion or a detected RGB change, and learns only from pixel-preserved neighboring patches. Across three paired seeds, the same principle improves P-AP in all six memory/reconstruction–dataset settings across MVTec, VisA, and Real-IAD. Matched controls identify the altered-context feature itself as the useful normal evidence: with synthetic input or selected positions fixed, altered-context features outperform their clean-view counterparts as both reconstruction targets and memory references. On MVTec memory, the final score change is also spatially selective, with larger reductions on normal patches next to defects than on mid-distance or far-normal patches in all 15 categories. Code is publicly available at https://github.com/jw-chae/boundary_support.

1 Introduction

Industrial visual anomaly detection is commonly learned from defect-free images because real defects are sparse, diverse, and expensive to annotate. Memory-based detectors store features from clean training patches and compare test patches with these references (Roth et al., 2022; Chae et al., 2026). Reconstruction-based detectors instead learn to reproduce clean feature targets and use the residual as anomaly evidence (Deng & Li, 2022; Guo et al., 2025). Strong pretrained encoders improve both families (Oquab et al., 2024), yet the normal evidence they use still comes almost entirely from clean images.

This design hides a simple assumption: clean training patches are sufficient for the normal regions that appear at test time. A detector can improve its search rule or reconstruction error only over references and targets that are actually available. If a normal test patch is poorly represented by the clean candidate set, the failure occurs before the final readout.

We therefore ask: do clean training images contain all normal patches needed to localize defects? Most patches in a defective image are still labeled normal, including patches immediately beside the defect. Their local appearance may remain normal while the surrounding image context differs from any clean training image. Because contextual encoders make dense features depend on surrounding content (Naseer et al., 2021; Darcet et al., 2024), these patches can occupy representations that clean-view features do not provide.

We test this with a matched fixed-budget diagnostic. For each donor/evaluation partition, the clean-only memory and ground-truth-assisted oracle are scored on the identical held-out defect images; any image that supplies oracle candidates is excluded from both arms for that partition. The two arms use the same frozen DINOv2 representation, the same test-time scoring rule, and the same number of references. The only change is whether mask-labeled normal patches from real defective images are allowed into the candidate pool. On MVTec AD, the matched comparison raises P-AP from 73.34 to 76.95. Increasing the reference count by 5.3% on the same candidate union reaches 76.96, only 0.01 point above the fixed-budget result. The fixed-budget memory therefore retains essentially the entire measured gain.

The useful additional patches are concentrated near defects. Restricting the oracle pool to ground-truth-normal patches within two patch cells of the annotated defect reaches 76.76 P-AP, recovering 94.70% of the fixed-budget gain. Detailed distance sweeps in the two largest-gain categories fall from near to mid to far. The gain also persists after inpainting in those categories and transfers across the tested source/target defect types, reducing the explanatory range of visible-defect leakage and exact defect memorization.

This observation motivates BOUNDARYSUPPORT. Rather than learning the synthetic core as an anomaly, BOUNDARYSUPPORT uses it to change the context around a pixel-preserved normal patch. Tokens touched by the nominal insertion or by a directly measured RGB change are excluded. Only neighboring token positions that remain outside this changed set are used as additional normal references or reconstruction targets. In the memory branch, altered-context features compete with clean candidates under the original fixed bank budget. In the reconstruction branch, the same preserved positions receive an auxiliary normal target while the original clean branch is unchanged.

Across MVTec, VisA, and Real-IAD, both branches improve P-AP in all six detector–dataset settings over three paired seeds. The main question then becomes what part of the intervention is responsible? Two matched controls answer this directly. For reconstruction, fixing the synthetic input and ring while replacing the target E(x~)pE(\tilde{x})_p with the clean-view feature E(x)pE(x)_p reverses the gain. For memory, fixing the selected positions and bank budget while replacing F(x~)pF(\tilde{x})_p with F(x)pF(x)_p lowers P-AP in 26 of 27 categories across MVTec and VisA. A final distance-resolved analysis shows that the learned score change is strongest on normal patches adjacent to real defects.

Our contributions are:

• A fixed-budget diagnostic showing that clean-only memory can miss useful normal references: adding mask-labeled normal patches from real defective images raises MVTec P-AP from 73.34 to 76.95, and a two-cell near-defect band recovers 94.70% of the gain.

• BOUNDARYSUPPORT, a clean-only intervention that changes surrounding context, excludes modified tokens, and uses only preserved neighboring features as memory references or reconstruction targets.

• Cross-paradigm and matched-control evidence showing that altered-context features are more useful localization targets/references than their clean-view counterparts, together with a spatial test linking the final score change to normal regions near defects.

References (54)