# DataMatrix Code Recognition Method Based on Coarse Positioning of Images
## 1 Introduction
The methods for correcting DM code images mainly include using a six-parameter affine transformation formula [28] and an eight-parameter affine transformation formula [29; 30]. DM code image sampling methods mainly include binarization based on the proportion of black or white pixels in all pixels in each grid, binarization by counting the proportion of black and white pixels on the central cross-shaped symbol in the sampling grid, and binarization based on scanning the central pixel in the sampling grid. After converting the recognized DM code image into a data matrix, a codeword stream can be obtained. After error correction using the Reed-Solomon algorithm, information can be decoded. At present, research on DM code decoding mainly focuses on DM code detection and positioning, and there is relatively little research on DM code image sampling, which is basically based on simple segmentation and sampling based on the coding of DM codes. However, due to the limitations of practical application scenarios, the obtained DM code images often have problems such as wear, corrosion, geometric distortion, and strong background interference. Traditional DM code image sampling methods can no longer meet the requirements. In fact, even state-of-the-art deep learning-based recognition systems have been shown to be vulnerable to slight input perturbations, where minimal noise added to the input can lead to completely incorrect recognition results, as demonstrated in recent studies on adversarial examples in AI systems [31]. To improve the decoding ability of DM codes in complex environments, this paper attempts to start from the aspect of DM code image sampling. By dividing adaptive sampling grids and binarizing based on grid grayscale change trends, the sampling grid division and data extraction steps in the DM code image recognition process are optimized to resist problems such as wear, corrosion, geometric distortion, and strong background interference in practical application scenarios and improve the decoding ability of DM codes. The main contributions of this paper are as follows. 1. Based on the projection algorithm and the exponential weighted moving average model, an adaptive sampling grid division method is proposed to overcome the problem that the sampling grid cannot be divided when the finder pattern encounters pollution or is missing. 2. By combining the local outlier factor (LOF) algorithm and the local weighted linear regression algorithm, a binarization method based on grid grayscale change trends is proposed. It optimizes problems such as blurry DM code images, wear, corrosion, geometric distortion, and strong background interference in practical application scenarios. It reduces the quality requirements for DM code images and improves decoding capabilities in complex environments. The rest of this paper is organized as follows. Section 2 briefly introduces the related work conducted in the field of DM code decoding. Section 3 introduces the adaptive sampling grid division method after the coarse positioning of DM code images. Section 4 introduces a binarization method based on grayscale change trends after sampling grid division. Section 5 describes the experiments and result analysis. Section 6 summarizes the paper.