Abstract:
Abstract: As the information carrier of agricultural product traceability system, QR code has always been a research hotspot in the agricultural field. In practical applications, the complexity of the traceability environment makes it easy for the QR code scanner to acquire locally highlighted or shaded QR code images. In the process of binarization, the target pixels of these uneven illumination QR code images are easily misjudged as background pixels or background pixels are misjudged as target pixels which cause the image information lost, resulting in lower recognition rate, this limits the inquirer to some extent. According to the selection of the threshold, the image binarization algorithms can be divided into global threshold methods and local threshold methods. By setting the segmentation threshold on the grayscale image, all the pixels in the grayscale image are divided into two categories: The target pixel and the background pixel. The gray value of the target pixel is set to 0, and the visual representation is black; the gray value of the background pixel is set to 255, and the visual representation is white. When the gray value of the pixel is greater or equal to the set segmentation threshold, it will be divided into the background pixel class; when it is smaller the set segmentation threshold, it will be divided into the target pixel class. The global threshold method represented by the Otsu algorithm is suitable for an image with a clear bimodal and uniform illumination in a gray histogram, but since the threshold is a fixed value, the fidelity is low when processing an image with uneven illumination. As a local threshold method, the Niblack algorithm can dynamically calculate the neighborhood center threshold in combination with the gray mean and variance in the neighborhood window. That is, for each pixel, the Niblack algorithm can calculate the corresponding threshold. Therefore, there is a good effect in splitting an image with uneven illumination, but the segmentation effect depends on the preset of the local window and the correction coefficient value. Since the correction coefficient and neighborhood window are fixed values selected according to experience, it is easy to cause the correction coefficient or neighborhood window used in some scenes to be unsuitable for another scene, so the original Niblack algorithm is less versatile. This paper proposes a Niblack algorithm that adaptive neighborhood window and correction coefficient. The algorithm dynamically adjusts the size of the neighborhood window according to the resolution of the QR code image, according to the gray mean and variance of the pixel points in the neighborhood window. The gray value information of the whole image is dynamically adjusted and corrected to realize adaptive binarization processing. Experiments show that compared with the original Niblack algorithm, the algorithm can more effectively segment the uneven light QR code image that the device cannot recognize. After the algorithm is processed, the recognition success rate of the unrecognizable QR code image reaches 74.2%, which is 18.4% higher than the original Niblack algorithm and is 71.7% higher than Otsu algorithm. The study has certain reference significance for the traceability of agricultural products in the uneven illumination environment.