# Feature Extraction and Recognition of Chinese Mitten Crab Carapace Based on Improved MobileNetV2
## 2 Materials and Methods
### Methods
#### 2.3.2 Coordinate Attention Mechanism  
In computer vision, attention mechanisms are inspired by the human brain's focus on the detailed characteristics of areas of interest, learning target details layer by layer while suppressing irrelevant information, thus significantly highlighting the features of the target area. Attention mechanism modules have been proven to enhance performance in computer vision tasks and are widely used in fields such as image classification, object detection, and image segmentation [26].  
Figure 3: Improved MobileNetV2 network structure diagram.  
To improve the feature extraction capability and focus on the important morphological features of the Chinese mitten crab traceability model, this study introduces the Coordinate Attention mechanism (CA) [27]. The CA refines the attention allocation across the spatial dimensions of the input feature map, enhancing the recognition of key morphological features on the crab carapace, such as grooves, protrusions, and textures. The structure of the CA is shown in Figure 4.  
The CA module adopts an effective method to capture channel relationships and positional information, achieving the further suppression of background noise and focusing on the key information of the crab carapace, thereby outputting refined features that more accurately represent the essence of the crab carapace. It decomposes any feature map in the convolutional layer into two different directions for feature encoding, thereby acquiring long-range dependencies in one spatial direction and precise positional information in the other. This method of directly embedding positional information into channel attention can be complementarily applied to the input feature map, thus enhancing the target representation in areas of interest. The specific steps are as follows:  
First, the crab carapace feature map is pooled along the horizontal direction (kernel \((H,1)\)) and vertical direction (kernel \((1,W)\)) to obtain the positional information of the input feature map along the x axis and y axis. The average pooling in the horizontal direction can be expressed as follows:  
\[z_{c}^{h}(h)=\frac{1}{W}\sum_{i=0}^{W}x_{c}(h,i) \tag{1}\]  
where \(z_{c}^{h}(h)\) represents the average features along the width \(W\) at a specific height \(h\). Similarly, the average pooling in the vertical direction can be expressed as follows:  
\[z_{c}^{w}(w)=\frac{1}{H}\sum_{j=0}^{H}x_{c}(j,w) \tag{2}\]  
where \(z_{c}^{w}(w)\) represents the average of features along the height \(H\) at a specific width \(w\). These two operations yield feature descriptors that capture information along the horizontal and vertical directions, respectively, with each independently summarizing the statistical information of the entire feature map.  
Secondly, the feature maps from the horizontal and vertical pooling results are concatenated and fed into a \(1\times 1\) convolution to obtain the attention feature map.  
\[f=\delta\Big{(}F_{1}\Big{(}[z^{h},z^{w}]\Big{)}\Big{)},f\in R^{C/r\times(H+W)} \tag{3}\]  
Figure 4: Schematic diagram of the Coordinate Attention mechanism.  
where \([_{\
u}]\) represents the concatenation operation along the spatial dimensions and \(\delta\) is a nonlinear activation function. The feature maps with non-linear data obtained after the activation function are then processed for feature extraction in both the horizontal and vertical directions.  
\[g^{h}=\delta(F_{h}(f^{h})),g^{w}=\delta(F_{w}(f^{w})) \tag{4}\]  
In the equation, \(g^{h}\) and \(g^{w}\) represent the attention weights along the horizontal and vertical directions, respectively.  
Finally, after processing through a 1 \(\times\) 1 convolution and a sigmoid operation, the feature map data are multiplied by the weights, which are processed horizontally and vertically to output the final features.  
\[y_{c}(i,j)=x_{c}(i,j)*g^{h}_{c}(i)*g^{w}_{c}(j) \tag{5}\]