# Industrial Image Anomaly Detection via Self-Supervised Learning with Feature Enhancement Assistance
## 3 Materials and Methods
### Pseudo-Anomaly Image and Label Generation  
Within the framework of self-supervised learning, in which reliance on manually labeled data is unnecessary, models can be trained by automatically generating pseudo-labels based on the structure and characteristics of the data itself. Therefore, an effective strategy involves training the model to discern between normal and abnormal patterns by generating pseudo-abnormal images. In this way, the model is able to learn the intrinsic features of normal samples and identify samples that deviate significantly from these features as abnormal, thereby facilitating effective anomaly detection. Inspired by [PERSON] [22] and MemSeg [42], we introduce an effective anomaly simulation strategy to assist self-supervised learning training. We utilize Perlin noise and the Describable Textures Dataset (DTD) [43] for anomaly simulation. Perlin noise is an algorithm used to generate natural, continuous, and controlled random textures and shapes, widely applied in computer graphics, game development, and art creation. It produces textures with natural variations and details, enhancing the realism of generated images or shapes, which is essential for simulating anomalies. The DTD is a texture image dataset, which consists of images depicting various texture classes. We generate the simulated exception as shown in Figure 2 with the following steps:  
Figure 1: The model framework diagram of the proposed method consists of two main parts as follows: the upper half is for the proxy task of self-supervised training, and the lower half is for anomaly detection. The self-supervised training section comprises a feature extractor, a multi-scale feature aggregation module, an encoder, and a classifier. The classifier’s outputs, denoted as 0, 1, and 2, respectively, represent normal, texture class anomalies, and structural anomalies, as defined in Equation (4). The anomaly detection section includes a feature extractor and a multi-scale feature aggregation module with the same parameters as those in the upper section, as well as a multivariate Gaussian modeling component. 1. A random two-dimensional Perlin noise \(P\) is first generated and randomly rotated to increase diversity. Subsequently, the noise is binarized using a set threshold to obtain the original anomaly mask \(M_{\text{P}}\). For the normal image \(I\), we obtain the foreground mask \(M_{IF}\) of the input image through threshold binarization. This ensures that our simulated anomalies are generated on the detected target rather than in the background, avoiding unnecessary noise. The simulated anomaly mask \(M\) is obtained by multiplying the foreground mask with the Perlin mask, as shown in Figure 2a. \[M=M_{IF}\odot M_{P}.\] (1) 2. The foreground of the anomaly block \(I_{AF}\) is obtained by multiplying the anomaly source image \(I_{S}\) and the simulated anomaly mask \(M\) on an element-by-element multiplication: \[I_{AF}=\lambda(M\otimes I_{S})+(1-\lambda)(M\otimes I).\] (2)  
A transparency factor \(\lambda\in[0.10,0.95]\) in Equation (2) is introduced to mix the anomaly source information with the original image information, enhancing the realism of the synthetic anomaly. Like \(\odot\), \(\otimes\) is multiplied element by element and used separately to distinguish between the mask and the image. There are two types of anomaly source images--texture and structure. Texture-based anomaly source images are sourced from the DTD dataset. Structural anomaly sources are derived directly from the input images themselves, where we randomly select three of the original input images from a series of enhancement functions. These functions include gamma contrast adjustment, luminance multiplication, sharpness enhancement, hue and saturation adjustment, and affine transformation (including rotation), aimed at diversifying of the data. Subsequently, the enhanced image is divided into \(8\times 8\) grids and randomly disrupted and reordered to  
Figure 2: Anomaly generation strategy.