When a used product comes back to be remanufactured, its surface is rarely clean. It carries stains, oil, oxide, polishing marks and slight warping from years of use. Visual anomaly detectors are trained to flag anything that looks unlike a pristine part, so on these returned parts, called cores, they flag almost everything. A small fatigue crack then becomes one more high-scoring patch among dozens of harmless ones. Medicine has a precise name for this failure. In high-transmission regions, a positive malaria test in a feverish child often reflects background parasite carriage rather than the cause of the fever. Dalrymple et al. estimate that only 37.7% of malaria-positive clinic fevers were actually caused by malaria, and that a positive result becomes less informative as background prevalence rises. We argue that inspection of variable cores has the same structure. Benign wear is the "background prevalence", and a detector with one fixed threshold loses precision and recall as the core's condition worsens.
This proposal has two parts. The first measures that loss directly, as a dose–response curve of defect recall against the severity of benign degradation. The second tests one specific remedy: score each image patch only against normal patches of similar condition, and set the detection threshold separately for each condition level. The remedy borrows its logic from engine diagnostics. There, hybrid fault detection used a calibrated physics model to factor out flight-condition variation before a neural network looked for faults. That raised detection from 24.5% for a pure autoencoder to nearly 100% on the C-MAPSS DS00 simulation, a simulated turbofan engine flown through climb, cruise and descent. We ask whether a learned condition model can play the same normalizing role in visual inspection, where no physics model exists.
Core Claim
Defect masking by benign product condition is a measurable, monotone effect. It is largely hidden by current benchmarks, which contain one staged defect per image on a uniform background. That is why FastFlow-era methods report 99.4% image-level AUROC on MVTec AD, while the same paper reports PatchCore at 81.1% AUROC on the RGB channels of MVTec 3D-AD, and real multi-defect infrastructure data yields only 55.11% class-weighted F2 on Sewer-ML.
Our claim is that conditioning both the nearest-neighbour reference set and the decision threshold on an estimated local condition flattens this dose–response curve. It should do so more than simply adding worn-but-acceptable parts to the normal training data. We state the comparison against that "inclusive" baseline up front, because it is the result that could kill the idea.
Research Program
The first component is a controlled masking testbed. Real returned cores with pixel-level crack labels do not exist in the file's resources. We therefore composite degradation onto existing labelled data at controlled severity: MVTec AD textures and metal objects (Bergmann et al.) and NEU hot-rolled steel (steel defect benchmark).
The degradation generator extends the procedural water-stain pipeline of Sequential PatchCore, which uses Perlin-noise shapes with a reflectance model. We add multi-layer oil films, oxide patches, abrasion texture and mild geometric warping, each with a scalar severity $s \in [0,1]$ and a coverage fraction. True defects stay where the datasets annotated them, and benign degradation is laid over and around them.
We also include a second-defect condition. One large, salient defect is pasted next to a small original one. This tests the "stopping at the first answer" failure that Dalrymple et al. describe clinically: a pipeline thresholds on the image's maximum score, or reports only the top regions, and so misses the small defect.
The primary measurement is the masking curve, defined as defect-wise recall (the instance-level metric introduced by Sequential PatchCore) at a fixed false-alarm budget per part, plotted against $s$. Its summary is the slope near high severity.
The second component is the method. A small condition encoder maps each patch to a condition descriptor $c$. It is trained only on defect-free images to regress the generator's degradation parameters, so it never sees defects. The memory bank of a PatchCore-style detector stores normal and benign-degraded patch features $f_j$ together with their descriptors $c_j$. A test patch with feature $f$ and descriptor $c$ is scored by its distance to the nearest stored features, with each stored feature weighted by condition similarity:
$$a(f,c) = \min_j \; \|f - f_j\| \,/\, w(c, c_j),$$
where $w$ is a Gaussian kernel on condition distance, floored at a small value so that unmatched conditions still contribute. Thresholds are then set by split-conformal calibration within condition strata. In plain terms, we hold out benign images, bin them by $c$, and in each bin pick the score cutoff that yields the target false-alarm rate. This makes the false-alarm rate equal across condition levels by construction, which is the direct inspection analogue of correcting for background prevalence.
For the second-defect setting we add an "explain-away" re-scoring pass. Once the most salient region has been flagged, it is excluded from image-level aggregation, and the remainder of the image is re-thresholded. This matters most for reconstruction-based detectors, where a large defect corrupts the reconstruction around it.
Baselines
The naive reference is PatchCore with a memory bank built from pristine normal images only, using a single global threshold. Every masking curve is reported relative to it.
The strongest existing competitor is the "inclusive" detector: PatchCore built sequentially in the manner of Sequential PatchCore, whose memory bank contains all benign-degraded training images. We run it both with and without that paper's filter, which discards predictions covering less than 5% of the image. It is the strongest competitor because nearest-neighbour scoring over an inclusive bank already conditions implicitly: a rusty patch can find a rusty neighbour. No reported result found on Lacuna for Sequential PatchCore's recall on the aluminum-plate data; the file gives only qualitative findings. The closest published anchor is PatchCore at 81.1% AUROC on MVTec 3D-AD RGB (benchmark). For fairness, all PatchCore variants share the same backbone, the same coreset size, the same benign training images and the same calibration split. Our method differs only in the condition weighting and the stratified thresholds.
The reconstruction competitor is Denoise AD, a diffusion model trained on normal images that treats anomalies as noise to be removed. It reports 94.1% PRO (per-region overlap) on MVTec AD, against DRAEM's 93.0%. Its authors acknowledge that it is sensitive to benign texture such as dust and surface roughness, so we expect it to show a steep masking curve. It receives the same degraded training data and an equal tuning budget of twenty configurations per method.
A supervised competitor in the style of DRAEM is trained to segment synthetic defects pasted onto our degraded backgrounds. Its PRO on MVTec AD is 93.0%, as reported in the Denoise AD paper.
Two ablations isolate the key ingredient. The first applies condition weighting but keeps a global threshold. The second keeps the inclusive bank but uses stratified thresholds. Beating the inclusive baseline means a statistically reliable gain in defect-wise recall, at matched false alarms per part, in the top severity tercile, with no loss at low severity. The gain must hold across five seeds and on degradation types the encoder never saw.
Why not just…?
Why not just put worn parts in the memory bank? This is the real threat, and we treat it as the decisive comparison rather than arguing it away. The mechanism by which it could fail is specific. A crack lying inside an oxide patch may sit close to some other benign rough texture in an unconditioned bank, so its score is pulled down. Restricting neighbours to the same condition removes these spurious matches. If the masking curves of the inclusive bank and the condition-weighted bank coincide, our method contributes nothing beyond the testbed. In that case we will report that result and recommend inclusive banks with stratified thresholds alone, since the threshold ablation separates the two effects.
Why not just filter out small detections? The 5% coverage filter from Sequential PatchCore assumes that impurities are smaller than defects. On cores the opposite is common: large oil films sit over sub-5% cracks. The file also reports that subtle texture-like defects such as NEU crazing reach only 48.58% accuracy (A Review and Benchmark on State-of-the-Art Steel Defects Detection). Our testbed deliberately includes small defects under large degradation, the regime where the filter should fail, and we report the filter as a baseline in that regime.
Why not just train a supervised segmenter on synthetic defects over synthetic wear? It may well win on degradation types it was trained on, since it learns to ignore those stains. The question is transfer. We hold out entire degradation families, such as training on stains and oxide and testing on abrasion and warping, and we test on real benign variation in Sewer-ML frames. A segmenter that loses its advantage on held-out degradation types supports the argument for condition-normalized one-class scoring. One that keeps its advantage there is a better answer than ours, and we would say so.
Proposed Experiments
The main experiment produces masking curves for every method on MVTec AD metal and texture categories and on NEU, across five severity levels, with and without a second salient defect. Metrics are defect-wise recall at one false alarm per part, PRO, and false-alarm rate per condition stratum. Equalizing that last metric is what stratified calibration is meant to deliver.
The geometric check uses MVTec 3D-AD with warping applied to the depth channel. It tests whether condition descriptors that include local curvature help where pure-RGB PatchCore sits at 81.1% AUROC.
The real-world check uses Sewer-ML (Sewer-ML). Water level and debris serve as naturally occurring condition variables. We ask whether stratifying structural-defect thresholds by those operational labels raises class-weighted F2 above 55.11% on the structural classes, without retraining the classifier. This experiment requires no synthetic data at all.
The decisive outcome comes from the first experiment. The proposal succeeds only if the condition-weighted, stratified detector has a measurably flatter recall-versus-severity slope than the inclusive PatchCore bank on held-out degradation families. If the slopes do not differ, the testbed and the masking-curve metric remain as the contribution, and the method claim is withdrawn.
References
- The contribution of non-malarial febrile illness co-infections to Plasmodium falciparum case counts in health facilities in sub-Saharan Africa
- Hybrid deep fault detection and isolation: Combining deep neural networks and system performance models
- Benchmarking Unsupervised Anomaly Detection and Localization
- Sewer-ML: A Multi-Label Sewer Defect Classification Dataset and Benchmark
- MVTec AD - A Comprehensive Real-World Dataset for Unsupervised Anomaly Detection
- A Review and Benchmark on State-of-the-Art Steel Defects Detection
- Sequential PatchCore: Anomaly Detection for Surface Inspection Using Synthetic Impurities
- Removing Anomalies as Noises for Industrial Defect Localization