## 3 Method
### Filter Selection  
In every image representation scheme, selecting appropriate features is an essential step because it enables feature dimension reduction and improves the efficiency of feature processing [35; 36]. As discussed, a CNN can generate an excessive number of feature maps. For example, the classic CNN model, AlexNet, has five convolutional layers, with corresponding 96, 256, 384, 384, and 256 filters within these layers [37]; when an image passes AlexNet, it will generate 1376 (\(=96+256+384+384+256\)) feature maps. When all these 1376 feature maps are input to a prediction model for repeated pattern defection, the analysis is computationally expensive, but may not be necessary because not all feature maps carry equally important information for the said task. Filter selection techniques are therefore used to determine an appropriate subset of feature maps to adequately represent input images. This appropriate subset of feature maps needs to be both concise and take hierarchical information into account.  
Figure 2: Illustration of the proposed method for efficient repeated pattern detection.  
Different from previous studies, using PCA for feature map selection, edge information is proposed for filter selection in this study. This is inspired by the fact that edge detection extracts object boundaries and visually salient edges that persevere the gist of the image and ignore weakly related information [38; 39]. Moreover, the edge detection result is binary, which makes it computationally efficient and straightforward to combine with feature maps. Specifically, the binary edge map (\([0,1]\)) can directly multiply with the feature maps to extract rich and informative features. Thus, image edge detection results are leveraged to select filters and their corresponding feature maps in the current method.  
Given a pre-trained classification CNN, the convolutional filters in the CNN are denoted as \(F=\{F_{n}|n\in N\}\), \(f_{n}\in F_{n}\), where \(N\) is a set of convolutional layers, and \(F_{n}\) is the set of convolutional filters in the \(n\)-th layer. \(f_{n}\) is one of the filters of the \(n\)-th layer, \(f_{n}\in F_{n}\). Use the same example of AlexNet as an illustration; it has 5 convolutional layers, thus \(N=5\) and \(F_{1}\) are a set of 96 filters in the first layer, \(F_{2}\) is a set of 256 filters in the second layer, and so forth. When an input image \(I\) with size \(w\times h\) passes through AlexNet, the convolutional filters will generate 1376 activated feature maps containing topology layout information of its repeated patterns.  
Assume \(B\) denotes the edge result for image \(I\), which can be obtained by any edge detector, e.g., the Canny detector [40], and \(B\) is a binary matrix with the same size of \(w\times h\) in \([0,1]\). The edge result \(B\) is used to select the filter that captures the most significant features for each convolution layer. To do so, \(B\) is first resized to \(B_{n}\), the same size of the feature maps \(f_{n,m}(I)\), for corresponding convolutional layer \(n\). The resized \(B_{n}\) is then multiplied with each of the \(M\) feature maps \(f_{n,m}(I)\) of the \(n\)-th layer as follows:  
\[f_{n,m}^{B}=B_{n}\cdot f_{n,m}(I) \tag{1}\]  
where \(\cdot\) represent the dot product. An activation map \(f_{n}^{*}\) is calculated among \(M\) feature maps of regular activated feature by  
\[f_{n}^{*}=\arg\max\left(f_{n,m}^{B}\right) \tag{2}\]  
It is worth emphasizing that only one representative filter is chosen in each convolutional layer. An example of selected filters is shown in Figure 1(a), which was obtained using a classic Canny edge detector [40]. Later in Section 5, a comparative study will be given on different pre-trained CNNs and different edge detectors for filter selection.