# Forgery Detection for Anti-Counterfeiting Patterns Using Deep Single Classifier
## 3 Deep Single Classifier for Anti-Counterfeiting Pattern Forgery Detection
### One-Class Classification Module Based on Boundary-Optimized OCSVM  
After the feature extractor training process is completed, two-dimensional feature vectors can be extracted from the anti-counterfeiting pattern images captured by mobile devices and then input into the second stage OCSVM for training and testing.  
For the above-mentioned anti-counterfeiting system, if a few forged products pass the genuine product verification, the forged labels can also be tracked through big data technology. If the number of one label appears in large numbers, it is considered that the label may be a forged product. Therefore, the boundary obtained by standard OCSVM training can be modified and expanded to improve the recognition rate of authentic products at the cost of reducing the ability to distinguish counterfeits. The specific process is as follows:  
(1) According to the standard OCSVM training process, a decision hyperplane can be generated based on the positive sample feature vector, and the expression of the hyperplane is the same as (1)  
\[w^{T}\phi(x)-\rho=0 \tag{10}\]  
where \(x\in R^{d}\) represents the normal data, its feature dimension is \(d\), and the image in the feature space is \(\phi(x)\). \(w\) and \(\rho\geq 0\) represent the normal vector and offset of the separation hyperplane, respectively.  
(2) For sample \(x_{i}(i=1,2,\ldots,N)\), set  
\[y_{i}=w^{T}\phi(x_{i})-\rho \tag{11}\]  
The used positive sample training set is input to the trained OCSVM for testing. Due to the existence of the \(v\) attribute, some of the input positive sample feature vectors may fall outside the decision boundary.  
If any sample point falls outside the decision boundary, the mathematical expression is  
\[\exists j\in[1,N],s.t.\ f(x_{j})=\text{sgn}\Big{(}w^{T}\phi\big{(}x_{j}\big{)} -\rho\Big{)}<0 \tag{12}\]  
where \(f(x)\) is the decision function of the standard OCSVM method. The sample point farthest from the decision hyperplane can be found by traversing the positive sample training set; the sample is denoted as \(x_{k}\). Correspondingly, \(y_{k}\) is the minimum value in \(y_{i}(i=1,2,\ldots,N)\)  
\[y_{min}=\min[w^{T}\phi(x_{i})-\rho]=y_{k} \tag{13}\]  
where \(y_{k}=w^{T}\phi(x_{k})-\rho<0\).  
If all sample points are located in the decision hyperplane, then \(y_{min}\) is set to zero.  
(3) Modify the decision hyperplane; the expression of the modified decision hyperplane is as follows  
\[w^{T}\phi(x)-\rho+D=0 \tag{14}\]  
where \(D\) is the expansion offset, and the expression is \[D=abs(y_{min})\times(1+d)=abs(y_{min})+d\times abs(y_{min}) \tag{15}\]  
In the formulation, \(y_{min}\) is obtained from step (2); \(d\) is the offset coefficient and is greater than zero. The first item in the expression enables all samples in the training set to fall into the decision hyperplane, and the second item improves the recognition rate of OCSVM for low-quality image sample input.  
The training set of positive samples, the boundary generated by OCSVM and the modified boundary is shown in Figure 5, where \(d_{1}\) and \(d_{2}\) are similarity metrics of the samples.