# Forgery Detection for Anti-Counterfeiting Patterns Using Deep Single Classifier
## 3 Deep Single Classifier for Anti-Counterfeiting Pattern Forgery Detection
### Feature Extraction Module Based on U-Net  
In this paper, a U-Net based auto-encoder is used to realize the feature extraction of the printed anti-counterfeit pattern [39]. The main idea is to restore the input printed anti-counterfeit pattern to a binary digital pattern and compare it with the original binary digital pattern input at the same time to calculate a set of similarity measures. Then, the measures are concatenated to construct the feature vector of the printed anti-counterfeit pattern image.  
As mentioned above, after the anti-counterfeiting code is generated and printed, the anti-counterfeiting pattern will be collected and stored by the industrial camera as a standard sample of the identification algorithm in practical applications. There is usually a high-resolution industrial camera and a fixed shooting environment in the collection process. However, the smartphone-captured image is prone to equipment defocusing, jitter and other fuzzy situations. In this paper, it is considered that the standard pattern images collected by the industrial camera can be used as the training sample after being artificially blurred to improve the restoration ability of the network for blurry images.  
The auto-encoder training process is shown in Figure 4. The digital pattern generated by the anti-counterfeiting code generation system is input into the auto-encoder based on U-Net in pairs with the anti-counterfeiting code collected by the industrial camera and then artificially blurred. The encoder predicts the digital pattern \(\hat{t}\) from the input blurred pattern \(x\), and it takes the mean square error of the predicted pattern \(\hat{t}\) and the input real digital pattern \(t\) as the loss item \(L_{1}\). The decoder predicts the predicted digital pattern \(\hat{t}\) again to obtain the possible print-captured pattern \(\hat{x}\). Similarly, the mean square error of \(x\) and \(\hat{x}\) is taken as the loss item \(L_{2}\). The loss function \(L\) of the whole auto-encoder is composed of two loss terms, and the expression is as follows  
\[L=L_{1}+\beta\times L_{2}=MSE\big{(}t,\hat{t}\big{)}+\beta\times MSE(x,\hat{x}) \tag{6}\]  
where \(\beta\) is the relative weight of two loss terms in the system loss function.  
In the test phase, the anti-counterfeiting pattern image \(A\) collected by the user using the mobile device and the corresponding original digital pattern image \(B\) in the database are used as a pair of network inputs. Firstly, a binary anti-counterfeiting pattern image \(C\) recovered from \(A\) is obtained, and then, it is compared with \(B\) to calculate a set of similarity metrics. Finally, the metrics is concatenated as the feature vector. In this paper, the Hamming distance and Jaccard similarity are selected to construct a two-dimensional feature vector.  
Figure 4: Training process of feature extractor in the first stage.  
Figure 3: Identification process of the proposed deep single classifier.  
For the recovered binary image \(C\) and the corresponding digital image \(B\) of the same size, set \(M_{00}\) is the number of pixels whose pixel values are both 0 at the same position in \(C\) and \(B\), \(M_{10}\) is the number of pixels whose pixel values are 255 and 0, respectively, at the same position in \(C\) and \(B\), \(M_{01}\) is the number of pixels whose pixel values are 0 and 255, respectively, at the same position in \(C\) and \(B\), and \(M_{11}\) is the number of pixels whose pixel values are both 255 at the same position in \(C\) and \(B\). Then, the Hamming distance \(H(C,B)\) and the Jaccard similarity \(J(C,B)\) can be calculated as the following formulation  
\[H(C,B)=M_{01}+M_{10} \tag{7}\]  
\[J(C,B)=\frac{M_{11}}{M_{01}+M_{10}+M_{11}} \tag{8}\]  
In addition, the feature vector for \(A\) can be constructed as  
\[F(A)=[H(C,B),\quad J(C,B)] \tag{9}\]