# DataMatrix Code Recognition Method Based on Coarse Positioning of Images
## 1 Introduction  
A DM code is an automatic identification barcode based on the principles of combination coding and computer image processing technology, invented by the American International Data Matrix company in 1989 [1]. A DM code is divided into two types: ECC000-140 and ECC200. ECC000-140 uses various levels of convolutional error correction methods, while ECC200 uses the Reed-Solomon algorithm for error correction. This article focuses on the ECC200 type of DM code. A complete DM code consists of the following parts [2], as shown in Figure 1.  
1. Data regions: A matrix arranged according to certain rules, containing encoded data information. Dark and light modules represent binary \"1\" and \"0\", respectively, as shown in Figure 1b. 2. Finder pattern: The finder pattern is a perimeter to the data region and is one module wide. The two adjacent sides illustrated in Figure 1c form the L boundary, and the two opposite sides illustrated in Figure 1d are made up of alternating dark and light modules. The finder pattern is used to locate and define the size of data modules, helping to determine the physical size and distortion of the barcode. Quiet zone: This is one data module wide, mainly used to separate the two-dimensional barcode from background information, as shown in Figure 1e. * 4. Alignment pattern: When the barcode symbol consists of multiple data regions, the data regions need to be divided by alignment patterns, as depicted in Figure 1f. DM code has the smallest printable size among current two-dimensional barcodes [3] and can store 30 digits in an area of 25 mm. It also has excellent error correction capabilities, with a maximum of only 20% of barcode information required for accurate identification [4]. Due to its distinctive recognition capabilities [5], strong anti-pollution ability, small size, and large coding capacity, a DM code is widely used in Direct Part Marking [6; 7; 8; 9], as shown in Figure 2. This type of barcode generation usually uses printing, photolithography, etching, impact, stamping, and other methods to encode on the surface of products or parts. However, due to the variety of barcode generation methods, the shape of code blocks may not be standard squares and the spacing between code blocks may be inconsistent. How to accurately locate and sample barcodes is an urgent research topic. Figure 1: DM code structure in red lines: (**a**) complete DM code; (**b**) data regions; (**c**) finder pattern; (**d**) finder pattern; (**e**) quiet zone; (**f**) alignment pattern. Figure 2: Application scenarios: (**a**) chip; (**b**) test tube; (**c**) microbial mass spectrometer target plate. The decoding steps of a DM code can be roughly divided into DM code image input, DM code image preprocessing, DM code detection and positioning, DM code image correction and recognition, and DM code error correction and decoding. DM code image preprocessing mainly includes image graying, image enhancement, image denoising, and image binarization. Among them, the methods of image denoising mainly include Gaussian filtering [10], median filtering [11], and mean filtering [12]; the methods of image binarization mainly include OTSU [13], local threshold [14], maximum entropy threshold [15], Bernsen [16], and histogram bimodal [17]. DM code detection and positioning mainly include coarse positioning of a DM code and precise positioning of a DM code. Among them, the methods of coarse positioning of DM codes mainly include the method of locating candidate regions of DM codes based on corner point distribution [18], the positioning method based on mathematical morphology [19], the connected component labeling method [20; 21], and the edge detection method based on the Sobel operator [22]. The methods for precise positioning of DM codes mainly include edge detection methods based on the Hough transform [23; 24; 25], edge detection methods based on the convex hull algorithm [26], and positioning methods based on the Radon transform [27].