Slide scanning bar code identification optimization method and device and readable storage medium thereof

Through local adaptive binarization, Hough linear clustering angle correction and 39-code characteristic reconstruction strategies, barcode recognition problems caused by uneven light, angle deviation and missing in slide scanning are solved, and efficient and robust barcode recognition effect is achieved.

CN120087390APending Publication Date: 2025-06-03SHENZHEN SHENGQIANG TECH

Patent Information

Application Number
CN202510550248.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-29
Publication Date
2025-06-03

AI Technical Summary

Technical Problem

The prior art has poor barcode recognition effect in slide scanning due to uneven light, limitations of traditional binarization methods, angle deviation and lack of the previous technology, especially in complex scenarios under the 39-code encoding rule.

Method used

The local adaptive binarization algorithm is used to accelerate the calculation of dynamic thresholds with integral graphs, an angle correction method based on Hough linear clustering, and a barcode reconstruction strategy for 39-code characteristics to achieve robust barcode recognition in uneven lighting scenarios.

Benefits of technology

It significantly improves the accuracy and robustness of barcode recognition in slide scanning, can effectively deal with problems such as uneven light, angle deviation and missing, and meets the identification needs in complex scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120087390A_ABST
    Figure CN120087390A_ABST
Patent Text Reader

Abstract

The invention provides a slide scanning bar code identification optimization method and device and a readable storage medium thereof. The method comprises the following steps: carrying out image preprocessing downsampling and carrying out illumination compensation through sub-region mean value estimation; a bar code area is positioned through morphological processing, and accurate angle correction is achieved by combining a minimum enclosing rectangle and Hough straight line clustering; quickly calculating a local mean value and a standard deviation based on the integrogram, and carrying out adaptive binaryzation through a dynamic threshold formula; and after morphological operation is carried out on the binary image, according to a 39-code rule that 10 units / group contains 3 wide strips, counting the black-and-white interval width and reconstructing the bar codes in groups. According to the scheme, the problems of uneven illumination, angle deviation and bar code adhesion loss are solved, the recognition accuracy and robustness are improved, and the method is suitable for rigid carrier bar code recognition.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of computer vision and image processing, and specifically relates to an optimization method for barcode recognition in the scene of slide scanning, covering image preprocessing, barcode area positioning, angle correction, adaptive binarization, and barcode reconstruction technology. Background Art

[0002] In the fields of biomedicine and laboratory automation, slide scanning is a key link in sample information management. To achieve rapid identification of slides, 39 barcodes are usually used as the only identifier. However, there are multiple technical challenges in the actual scanning process: 1. Uneven illumination and noise interference: The non-uniformity of the instrument light source and the differences in barcode printing quality (such as uneven widths, blurred edges, as Figure 1 ) result in illumination shadows and impurities in the acquired image, seriously affecting the subsequent binarization processing effect.

[0003] 2. Limitations of traditional binarization methods: Binarization algorithms based on global thresholds (such as Otsu method, triangle method) cannot adapt to local illumination changes, and are prone to overexposure (barcode area loss) or underexposure (background impurities remaining), resulting in barcode adhesion or breakage.

[0004] 3. Angle deviation and regional positioning error: The pasted angle of the barcode on the slide may have a slight tilt. Traditional methods rely on the minimum bounding rectangle to estimate the angle, and the correction of the angle deviation of narrow barcodes (such as the absolute value is less than 0.5°) is insufficient, affecting the subsequent recognition accuracy.

[0005] 4. Barcode missing and reconstruction difficulties: Printing defects or scanning noise may cause local barcode missing. Existing technologies lack an efficient reconstruction strategy for the 39-code encoding rule (a group of 10 units, including 3 wide bars), and the recognition robustness is poor.

[0006] In the prior art, for image processing methods with uneven illumination, global illumination compensation is mostly used, and an adaptive algorithm is not designed in combination with the local features of barcodes; barcode positioning and correction rely on a single geometric feature (such as the bounding rectangle), and the processing of slight angle deviations is insufficient; the integral image acceleration technology is not fully utilized in the binarization process, and the calculation efficiency is low; and a reconstruction strategy is not designed for the specific encoding rule of 39-code, resulting in the recognition accuracy in complex scenarios being difficult to meet the actual requirements. Summary of the Invention

[0007] Embodiments of the present invention provide an optimized method, device, and readable storage medium for barcode recognition in slide scanning, aiming at the problems existing in the current technology, such as poor binarization effect due to uneven illumination, inaccurate barcode angle correction, lack of a reconstruction strategy for the characteristics of 39-code, and difficulty in efficiently and accurately recognizing barcodes in slide scanning.

[0008] The core technology of the present invention mainly realizes the robust recognition of barcodes in scenes with uneven illumination through a local adaptive binarization algorithm (combining integral images to accelerate the calculation of dynamic thresholds), an angle precise correction method based on Hough line clustering, and a barcode reconstruction strategy for the grouping characteristics of Code 39.

[0009] In a first aspect, the present invention provides an optimized method for recognizing glass slide scanned barcodes, and the method includes the following steps: S1. Image preprocessing: Perform downsampling and illumination compensation processing on the acquired glass slide image to obtain an image after illumination compensation; S2. Barcode area positioning and angle correction: Obtain the connected area where the barcode is located through morphological processing, determine the minimum circumscribed rectangle of the connected area to obtain preliminary angle information. When the preliminary angle information is less than a preset threshold, perform line extraction and clustering on the connected area through Hough line detection, calculate the final correction angle according to the clustering result, and perform rotation calibration on the image after illumination compensation based on the final correction angle to obtain a calibrated image; S3. Adaptive binarization processing: Expand the boundary of the calibrated image, calculate the integral image and the squared integral image of the expanded image, calculate the local mean and standard deviation of each pixel based on the integral image and the squared integral image, and use the local mean and standard deviation to construct a dynamic threshold to binarize the calibrated image to obtain a binarized image; S4. Barcode reconstruction and recognition: Perform morphological operations on the binarized image to disconnect the adhesion area and connect discrete points, count the black and white interval widths of the barcode, perform grouping processing on the black and white interval widths according to the coding rules of Code 39, extract the top 3 units with the largest width in each group as wide bars, reconstruct the barcode and perform recognition.

[0010] Further, in step S1, the illumination compensation processing specifically includes: Divide the glass slide image into multiple sub-regions of a preset size, and calculate the pixel mean of each sub-region as the low-frequency illumination component; Perform normalization processing on the glass slide image according to the low-frequency illumination component to obtain an image after illumination compensation.

[0011] Further, in step S3, the calculation formula of the dynamic threshold is:

[0012] where μ is the pixel mean within the local window, σ is the pixel standard deviation within the local window, k is a parameter controlling the weight of the standard deviation on the threshold, and r is a parameter standardizing the standard deviation range.

[0013] Further, the morphological operations include: Perform erosion processing on the binary image using erosion with a preset size to disconnect the adhesion areas of adjacent barcodes; Process the eroded image through multiple opening and closing operations to connect the discrete point areas of the same barcode.

[0014] Further, the barcode reconstruction specifically includes: If the binary image recognition fails, rotate the binary image by 180° and superimpose it with the original binary image to obtain a supplemented binary image; Perform vertical projection statistics on the supplemented binary image to obtain an array of black and white interval widths, and reconstruct the barcode according to the width array and the 39-code encoding rule.

[0015] Further, the calculation of the integral image and the squared integral image is used to quickly obtain the pixel sum and the pixel squared sum within any rectangular region, reducing the computational complexity of calculating the neighborhood pixel sum from O(N 2 ) to O(1), where N is the window size.

[0016] Further, the steps of Hough line detection include: Extract straight line segments of a preset length from the connected region, group the straight line segments with similar slopes through a clustering algorithm, and calculate the average value of the angles of each group of straight line segments as the final correction angle.

[0017] In a second aspect, the present invention provides an optimized device for identifying barcodes in a slide scan, including: An image preprocessing module that performs downsampling and light compensation processing on the acquired slide image to obtain a light-compensated image; A barcode area positioning and angle correction module that obtains the connected region where the barcode is located through morphological processing, determines the minimum circumscribed rectangle of the connected region to obtain preliminary angle information, and when the preliminary angle information is less than a preset threshold, performs straight line extraction and clustering on the connected region through Hough line detection, calculates the final correction angle according to the clustering result, and performs rotation calibration on the light-compensated image based on the final correction angle to obtain a calibrated image; An adaptive binary processing module that performs boundary expansion on the calibrated image, calculates the integral image and the squared integral image of the expanded image, calculates the local mean and standard deviation of each pixel based on the integral image and the squared integral image, and constructs a dynamic threshold using the local mean and standard deviation to perform binary processing on the calibrated image to obtain a binary image; Barcode reconstruction and recognition, perform morphological operations on the binary image to disconnect the adhesion areas and connect the discrete points, count the black and white interval widths of the barcode, perform grouping processing on the black and white interval widths according to the 39-code encoding rule, extract the top 3 units with the largest widths in each group as wide bars, and reconstruct and recognize the barcode.

[0018] In a third aspect, the present invention provides an electronic device, including a memory and a processor. A computer program is stored in the memory, and the processor is configured to run the computer program to execute the above-mentioned optimized method for slide scanning barcode recognition.

[0019] In a fourth aspect, the present invention provides a readable storage medium, in which a computer program is stored. The computer program includes program codes for controlling a process to execute the process, and the process includes the optimized method for slide scanning barcode recognition according to the above.

[0020] The main contributions and innovations of the present invention are as follows: 1) Adaptive binarization algorithm and integral image acceleration: A dynamic threshold formula based on local mean and standard deviation is proposed. Local adaptive binarization in uneven illumination scenarios is achieved by configuring parameters k (contrast sensitivity coefficient) and r (standard deviation range), avoiding overexposure / underexposure problems caused by global thresholds. The integral image pre-computation technology is introduced, reducing the computational complexity of calculating the sum of pixels in a local window from O(N 2 ) to O(1), significantly improving the binarization efficiency of large windows while ensuring controllable memory occupancy.

[0021] 2) Two-stage angle correction mechanism: The angle correction strategy of "minimum circumscribed rectangle rough adjustment + Hough line fine adjustment" is first proposed: the preliminary angle is obtained through the circumscribed rectangle of the largest connected component in morphology. For scenarios with small angle deviations (such as angle < 0.5°), the barcode edge line segments are extracted by Hough line detection, and the average angle is calculated through a clustering algorithm, solving the problem of insufficient angle estimation of thin and narrow barcodes by traditional single geometric positioning and achieving sub-pixel level angle correction accuracy.

[0022] 3) Exclusive reconstruction strategy for Code 39 characteristics: A vertical projection statistics and grouping screening algorithm is designed for the coding rule of Code 39 of "10 units / group, 3 wide bars": after disconnecting adhesions and connecting discrete points through erosion, opening and closing operations, the width of black and white intervals is statistically calculated, and the positions of wide bars are determined according to the top 3 largest widths in each group to complete missing or adhered barcode units. This strategy is tolerant of printing defects (unequal width, local missing), avoiding the limitation of traditional methods relying on complete barcode images and significantly improving the recognition success rate of low-quality barcodes.

[0023] Details of one or more embodiments of the present invention are set forth in the following drawings and description to make other features, objects, and advantages of the present invention more concise and understandable. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] The accompanying drawings described herein are used to provide a further understanding of the present invention, and constitute a part of the present invention. The illustrative embodiments of the present invention and their descriptions are used to explain the present invention, and do not constitute an improper limitation of the present invention. In the drawings: Figure 1 is the original slide barcode image; Figure 2 is the regional recognition and cropping diagram according to the embodiment of the present invention; Figure 3 is the barcode area recognition diagram according to the embodiment of the present invention; Figure 4 is the Hough line extraction diagram according to the embodiment of the present invention; Figure 5 is the regional recognition and rotation adjustment diagram according to the embodiment of the present invention; Figure 6 is the barcode area illumination elimination diagram according to the embodiment of the present invention; Figure 7 is the barcode area binary image according to the embodiment of the present invention; Figure 8 is the barcode area binary image rotated 180° according to the embodiment of the present invention; Figure 9 is the result diagram of the OR operation between the barcode area binary image rotated 180° and the binary image according to the embodiment of the present invention; Figure 10 is the barcode reconstruction diagram according to the embodiment of the present invention; Figure 11 is the flow of the optimized method for identifying the slide scan barcode according to the embodiment of the present invention; Figure 12 is the schematic hardware structure diagram of the electronic device according to the embodiment of the present invention. Detailed implementation manners

[0025] Here, the exemplary embodiments will be described in detail, and the examples are shown in the accompanying drawings. When the following description refers to the accompanying drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementation manners described in the following exemplary embodiments do not represent all implementation manners consistent with one or more embodiments of this specification. On the contrary, they are merely examples of devices and methods consistent with some aspects of one or more embodiments of this specification as detailed in the appended claims.

[0026] It should be noted that: in other embodiments, the steps of the corresponding method are not necessarily executed in the order shown and described in this specification. In some other embodiments, the steps included in the method may be more or less than those described in this specification. In addition, a single step described in this specification may be decomposed into multiple steps for description in other embodiments; and multiple steps described in this specification may also be combined into a single step for description in other embodiments.

[0027] Defects of the prior art: In the traditional barcode recognition method, due to uneven illumination, printing defects and geometric deformation, the binarization is incomplete, the angle correction is inaccurate, and the calculation efficiency is low, making it difficult to balance robustness and real-time performance in complex scenarios.

[0028] Based on this, the present invention is based on a new solution to solve the problems existing in the prior art.

[0029] Embodiment 1 The present invention aims to propose an optimized method for slide scanning barcode recognition, which realizes efficient and robust recognition of low-quality barcodes through local dynamic threshold binarization accelerated by integral images (parameter k and r adjustment), Hough line clustering for angle correction, and group reconstruction based on the 39-code rule (rotation superposition and morphological repair).

[0030] Specifically, the embodiment of the present invention provides an optimized method for slide scanning barcode recognition, referring to Figures 1-11 , the method includes: S1. Image preprocessing: Perform downsampling and illumination compensation processing on the acquired slide image to obtain an image after illumination compensation; In this embodiment, the specific steps of image preprocessing are as follows: A1. Read the slide positioning picture and convert it into a grayscale picture; A2. Perform downsampling processing on the image to improve the image processing speed and at the same time achieve the effect of noise suppression, denoted as img; A3. Reduce the influence of illumination on the picture analysis process, and the effect is as Figure 6 ; a) Divide the image into small squares of 12*12, and denote the width and height as W and H. Perform a rough shadow estimation on the image img, and denote the shadow as , processing method: , estimate the low-frequency illumination component. This processing method is fast and has good robustness. Here, W = H = 12 represents the width and height of each small square. By traversing all small squares in the image, a "shadow map" of the same size as the original image is generated, and the average illumination intensity of each area is recorded. The purpose of the above formula is to calculate the grayscale mean of all pixels within a W×H (here W = H = 12) small square centered at the pixel point (x, y) in the image as the estimated value of the low-frequency illumination component of this area. img(i, j): the grayscale value at the coordinate (i, j) in the original image (the range is usually 0 - 255, and the larger the value, the brighter the pixel).

[0031] In this step, since uneven illumination is manifested as slowly changing bright and dark areas (low-frequency signals) in the image, while the black and white stripes of the barcode are high-frequency signals (local details), therefore, taking the mean of the pixels within each 12×12 small square (formula shadow(x,y)) is essentially a low-pass filter - smoothing high-frequency noise and details, and retaining the low-frequency illumination trend (such as global shadows and local brightness changes).

[0032] b) According to the characteristics of the barcode in the barcode image being black background and white bars, process the images img and shadow:

[0033] Among them, the numerator img(x,y): the grayscale value of the original image at (x,y) (the range is usually 0 - 255, 0 is black, and 255 is white).

[0034] The denominator shadow(x,y)+ε: shadow(x,y): the low-frequency illumination component calculated by the mean of the 12×12 small square (step A3.a), reflecting the average illumination intensity of this area (the larger the value, the stronger the illumination).

[0035] ε: a very small positive number (such as 10 -6 ), to avoid calculation errors caused by the denominator being zero and ensure numerical stability.

[0036] Finally, adjust 1 -...: map the reflectivity to the interval (0,1) (the larger the original grayscale value, the smaller the result; vice versa), aligning with the characteristics of the barcode "black bars (low reflectivity) - white background (high reflectivity)" (after processing, the black bars correspond to high values, and the white background corresponds to low values, facilitating subsequent binarization with 0 / 255 for distinction).

[0037] In this step, the original image is normalized through the above formula. The pixel values in the dark areas (small shadow(x,y)) are enlarged, and the pixel values in the bright areas (large shadow(x,y)) are reduced, thereby eliminating the influence of uneven illumination and making the black and white contrast of the barcode more uniform (as Figure 6 shown).

[0038] In this way, through the local mean estimation of 12×12 small squares, the present invention separates the low-frequency illumination component in a simple and efficient way. Without introducing complex calculations, it effectively solves the interference of uneven illumination on barcode recognition. It is a key preprocessing step for subsequent adaptive binarization and precise positioning, and embodies the technical characteristics of "fast, robust, and adaptive to rigid carriers". Through illumination-reflectivity decoupling, the original grayscale image affected by illumination is converted into a normalized image that only reflects the difference in black and white reflectivity of the barcode. This is the core operation of "eliminating the influence of uneven illumination". Its design cleverly combines the rapidity of low-frequency shadow estimation with the accuracy of pixel-by-pixel correction, providing high-quality input for subsequent binarization, regional positioning and other steps. It is one of the key innovations of the present invention to improve the robustness of barcode recognition.

[0039] S2. Barcode area positioning and angle correction: The connected area where the barcode is located is obtained through morphological processing, and the minimum circumscribed rectangle of the connected area is determined to obtain preliminary angle information. When the preliminary angle information is less than a preset threshold, the connected area is extracted and clustered through Hough line detection, and the final correction angle is calculated according to the clustering result. The image after illumination compensation is rotated and calibrated based on the final correction angle to obtain a calibrated image; In this embodiment, the specific steps are as follows: A4. Binarize the light_removed image and record it as light_removed_bin, remove the small blocks in the binary image, and fill the holes in the binary image; A5. Use morphology to obtain the area where the barcode is located in the image light_removed_bin, and select the largest connected area (such as Figure 3 ), as the area where the code is located and obtain the width, height and angle information of the minimum enclosing rectangle, and make preliminary corrections to the image according to the angle and aspect ratio; A6. When the absolute value of angle is less than 0.5, it means that the circumscribed rectangle method in step A5 cannot adjust the angle of the thinner barcode. For the area of ​​the maximum connected domain in step A5, extract the Hough straight line of a certain length (such as Figure 4 ), select Hough lines with similar slopes according to the clustering method, and calculate the corresponding angle average value according to the angles of all Hough lines as the final correction angle.

[0040] A7. Calculate the rotation matrix based on the angle and the roi (region of interest) where the barcode is located, and calibrate the angle of img. Figure 2 , after calibration Figure 5 ; A8. The image where the barcode is located is captured from img and is marked as warped_image.

[0041] S3. Adaptive Binary Thresholding: Expand the boundaries of the calibrated image, calculate the integral image and the squared integral image of the expanded image, calculate the local mean and standard deviation of each pixel based on the integral image and the squared integral image, and use the local mean and standard deviation to construct a dynamic threshold to binarize the calibrated image to obtain a binary image; In this embodiment, the specific steps are as follows: B1. Process the image warped_image according to step A3 to obtain an image denoted as dst. For example, perform a binarization operation on the image after eliminating the light intensity operation, denoted as bar_code_bin. The binary operation is carried out as follows: a) Boundary Expansion: Set kernelSize (the kernel size, which represents the size of the sliding window used for local binarization, that is, the neighborhood range (width × height, usually an odd number, such as 25, 31, etc.) considered when calculating the threshold for each pixel), and use the cv::copyMakeBorder function to expand the boundaries of the input image. The expansion size is margin (i.e., kernelSize / 2), where margin is the window radius (i.e., the pixel distance from the window center to the edge). If margin = 12, then kernelSize = 25 (the window is 25×25 pixels, with 12 pixels on each side around the central pixel).

[0042] The purpose is to prevent the window of edge pixels from exceeding the image boundary during the integral image calculation, ensuring the integrity of the local window of image edge pixels (for example, when there are no pixels on the left / above of the edge pixel, expand the boundary to fill with the mean value or mirror pixels to ensure the calculation legality).

[0043] b) Integral Image Calculation: Use the cv::integral function to calculate the integral image sum and the squared integral image sqsum of the expanded image. The integral image is used to quickly calculate the sum of pixels in any rectangular region, and the squared integral image is used to quickly calculate the sum of pixel squares.

[0044] The purpose is to reduce the computational complexity of calculating the sum of pixels sumValue and the sum of pixel squares sqSumValue in any rectangular region from O(N 2 ) to O(1) (N is the window size) through one pre - calculation, significantly improving the binarization efficiency of large windows (for example, the speed is increased by about 600 times when the window is 25×25).

[0045] c) Binarization Processing: To handle the residual influence when processing images with uneven illumination, traverse each pixel of the output image dst, and calculate the sum of pixels sumValue and the sum of pixel squares sqSumValue within the local window centered on this pixel. Among them , r = 128.0, k = 0.2. The details are as follows: i. , where μ( ) is the pixel mean within the local window, reflecting the local brightness; σ( ) is the pixel standard deviation within the local window; k = 0.2 (configurable) is the weight controlling the influence of the standard deviation on the threshold (the larger k is, the more sensitive the threshold is to the contrast, suitable for low-contrast barcodes); r = 128 (configurable) is the standardized standard deviation range to prevent abnormal standard deviations caused by noise (such as extremely small window noise making σ too large or too small).

[0046] ii. Binarization rule

[0047] (White is the background, black is the barcode, consistent with the "black bars on a white background" feature of Code 39).

[0048] In this way, the threshold of each pixel is dynamically determined by its local brightness and contrast, avoiding the failure problem of the global threshold (such as Otsu's method) in areas with uneven illumination (such as missed detection of black bars in bright areas and misjudgment of the background in dark areas).

[0049] S4. Barcode reconstruction and recognition: Perform morphological operations on the binarized image to disconnect the adhesive areas and connect the discrete points, count the black and white interval widths of the barcode, group the black and white interval widths according to the encoding rules of Code 39, and extract the top 3 units with the largest widths in each group as wide bars to reconstruct and recognize the barcode.

[0050] In this embodiment, the specific steps are as follows: B2. Perform two reconstruction methods on bar_code_bin (such as Figure 7 ) in the following two ways: Path 1. Complement the parts that cannot be correctly processed by binarization due to strong light. After rotating bar_code_bin by 180° (such as Figure 8 ), directly superimpose it on the original image to obtain a new bar_code_bin (such as Figure 9 ), and directly recognize bar_code_bin through zxing (an open-source barcode and QR code recognition library by Google). If the recognition fails, then through the vertical projection statistical method, count the widths of the black and white intervals and record them in an array variable denoted as lengths for barcode reconstruction; In other words, rotate the binary image by 180° and superimpose it on the original image (logical OR operation) to complement the missed detection areas caused by strong light (such as the barcode edge being too bright and misjudged as the background. After rotation, the black and white are reversed, and superimposition can restore the complete contour, such as Figures 8-9 ).

[0051] If recognition still fails after superposition, enter vertical projection statistics: Analyze the width of black and white intervals through projection to generate an lengths array (recording the width of each black and white unit).

[0052] Path 2: First, erode bar_code_bin with a 2x50 kernel to disconnect the possibly connected areas between adjacent two codes and erode the discrete point areas. Then, alternately perform opening and closing operations multiple times to connect the same code. Count the barcode contour and record the starting positions of black and white areas in the form of the coordinates of the upper left corner and the lower right corner, and calculate the width of the black and white areas, denoted as length1s.

[0053] In other words, it is the erosion operation: Erode the image with a 2×50 kernel (2 pixels high, 50 pixels wide, in the vertical direction) to disconnect the adhesion areas of adjacent barcodes (such as the horizontal adhesion caused by overly wide printing of wide bars), and at the same time remove discrete noise points.

[0054] Opening and closing operations: Alternately perform opening operations (erosion + dilation, removing isolated noise points) and closing operations (dilation + erosion, connecting adjacent barcode units) multiple times to ensure the connectivity of the same barcode unit.

[0055] Contour statistics: Record the starting coordinates of black and white areas and calculate the width length1s (for subsequent grouping and matching).

[0056] B3. Collect information from B2 and reconstruct the barcode; a) According to the characteristics of Code 39, group them into sets of 10. There are 3 wide bars in a set. Record the sequence numbers and indices of the top 3 lengths in a set for lengths and length1s respectively, with 10 elements each, and record them in the selectedIndex as the selected sequence numbers.

[0057] That is, the encoding rule is: Each group of Code 39 contains 10 units (5 black and 5 white or 5 white and 5 black, including 3 wide bars), and the width of the wide bar is 2 - 3 times that of the narrow bar.

[0058] b) Reconstruct bar_nums = ceil(lengths.size() / 10.) * 10 – 1 as the total quantity. When the quantity is insufficient, directly default to forcibly supplement the first group as the starting code of Code 39, and the remaining codes follow the rule of alternating black and white in sequence; Search in selectedIndex. If it exists, check whether the bar in selectedIndex is a wide bar, otherwise it is a narrow bar, to obtain the reconstructed barcode image, as Figure 10 shown.

[0059] In other words, it is grouping and screening: Group lengths and length1s into sets of 10 units. Extract the top 3 units with the largest width in each group as wide bars (selectedIndex), and the rest are narrow bars (meeting the "3 wide bars" rule of Code 39).

[0060] Quantity Completion: If the number of units is insufficient, the starting code is defaultly supplemented (such as the unit combination corresponding to the "*" symbol), and a complete barcode is generated according to the black and white alternating rule (such as Figure 10 ).

[0061] In this way, it has tolerance for printing defects (such as too narrow narrow bars, too wide wide bars or partial missing), and enforces the matching of 39 - code rules through "width top3 screening" to avoid recognition failure caused by partial missing in traditional methods.

[0062] B4. Barcode image recognition is completed.

[0063] The above steps solve the problem of residual light through adaptive binarization, and solve the barcode integrity problem through the reconstruction of 39 - code characteristics. The combination of the two forms strong robustness to complex light and non - ideal barcodes. The technical highlight lies in the deep integration of computer vision algorithms (integral image, morphology) and specific coding rules (39 - code), realizing the full - link optimization from "image pre - processing" to "coding - level reconstruction", filling the gaps in barcode recognition integrity and efficiency in the existing technology.

[0064] Embodiment 2 Based on the same concept, the present invention also proposes an optimized device for slide - scanning barcode recognition, including: An image pre - processing module that performs down - sampling and light compensation processing on the acquired slide image to obtain an image with light compensation; A barcode area positioning and angle correction module that obtains the connected area where the barcode is located through morphological processing, determines the minimum circumscribed rectangle of the connected area to obtain preliminary angle information. When the preliminary angle information is less than a preset threshold, straight lines are extracted and clustered from the connected area through Hough line detection, and the final correction angle is calculated according to the clustering result. Based on the final correction angle, the image with light compensation is rotationally calibrated to obtain a calibrated image; An adaptive binarization processing module that performs boundary expansion on the calibrated image, calculates the integral image and the square integral image of the expanded image, calculates the local mean and standard deviation of each pixel based on the integral image and the square integral image, and constructs a dynamic threshold using the local mean and standard deviation to binarize the calibrated image to obtain a binarized image; Barcode reconstruction and recognition, performing morphological operations on the binarized image to disconnect the adhesion area and connect discrete points, counting the black - and - white interval widths of the barcode, grouping the black - and - white interval widths according to the coding rules of 39 - code, extracting the top 3 units in width in each group as wide bars, reconstructing the barcode and performing recognition.

[0065] Embodiment 3 This embodiment also provides an electronic device, refer to Figure 12, including a memory 404 and a processor 402, where a computer program is stored in the memory 404, and the processor 402 is configured to run the computer program to execute the steps in any of the above method embodiments.

[0066] Specifically, the above-mentioned processor 402 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present invention.

[0067] Among them, the memory 404 may include a mass storage 404 for data or instructions. By way of example and not limitation, the memory 404 may include a hard disk drive (HDD), a floppy disk drive, a solid state drive (SSD), a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive, or a combination of two or more of these. Where appropriate, the memory 404 may include removable or non-removable (or fixed) media. Where appropriate, the memory 404 may be internal or external to the data processing device. In a particular embodiment, the memory 404 is non-volatile memory. In a particular embodiment, the memory 404 includes a read-only memory (ROM) and a random access memory (RAM). Where appropriate, the ROM may be a mask-programmed ROM, a programmable ROM (PROM), an erasable PROM (EPROM), an electrically erasable PROM (EEPROM), an electrically alterable ROM (EAROM), or a flash memory, or a combination of two or more of these. Where appropriate, the RAM may be a static random access memory (SRAM) or a dynamic random access memory (DRAM), where the DRAM may be a fast page mode dynamic random access memory (FPMDRAM), an extended data output dynamic random access memory (EDODRAM), a synchronous dynamic random access memory (SDRAM), etc.

[0068] The memory 404 can be used to store or cache various data files required for processing and / or communication, as well as possible computer program instructions executed by the processor 402.

[0069] The processor 402 reads and executes the computer program instructions stored in the memory 404 to implement any one of the slide scanning barcode recognition optimization methods in the above embodiments.

[0070] Optionally, the above electronic device may further include a transmission device 406 and an input / output device 408. Among them, the transmission device 406 is connected to the above processor 402, and the input / output device 408 is connected to the above processor 402.

[0071] The transmission device 406 can be used to receive or send data via a network. Specific examples of the above network may include wired or wireless networks provided by the communication provider of the electronic device. In one example, the transmission device includes a network adapter (abbreviated as NIC), which can be connected to other network devices through a base station and thus communicate with the Internet. In one example, the transmission device 406 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0072] The input / output device 408 is used to input or output information.

[0073] Embodiment 4 This embodiment also provides a readable storage medium. The readable storage medium stores a computer program, and the computer program includes program codes for controlling a process to execute the process. The process includes the slide scanning barcode recognition optimization method according to Embodiment 1.

[0074] It should be noted that the specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementation manners, and will not be repeated here.

[0075] Generally, various embodiments can be implemented in hardware or dedicated circuits, software, logic, or any combination thereof. Some aspects of the present invention can be implemented in hardware, while other aspects can be implemented by firmware or software executed by a controller, a microprocessor, or other computing devices, but the present invention is not limited thereto. Although the various aspects of the present invention can be shown and described as block diagrams, flowcharts, or using some other graphical representations, it should be understood that, as a non-limiting example, the blocks, devices, systems, technologies, or methods described herein can be implemented in hardware, software, firmware, dedicated circuits or logic, general hardware or a controller or other computing devices, or some combination thereof.

[0076] Embodiments of the present invention can be implemented by computer software, which can be executed by a data processor of a mobile device, such as in a processor entity, or by hardware, or by a combination of software and hardware. A computer software or program (also referred to as a program product), including software routines, applets, and / or macros, can be stored in any device-readable data storage medium, and they include program instructions for performing specific tasks. The computer program product can include one or more computer-executable components configured to execute the embodiments when the program runs. One or more computer-executable components can be at least one software code or a part thereof. Additionally, in this regard, it should be noted that any box in the logical flow, as Figure 11 shown in [reference], can represent a program step, or interconnected logic circuits, boxes, and functions, or a combination of program steps and logic circuits, boxes, and functions. The software can be stored on physical media such as memory chips or storage blocks implemented within a processor, magnetic media such as hard disks or floppy disks, and optical media such as, for example, DVDs and their data variants, CDs. The physical media are non-transitory media.

[0077] Those skilled in the art should understand that the technical features of the above embodiments can be combined arbitrarily. For the sake of brevity of description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered to be within the scope described in this specification.

[0078] The above embodiments only represent several implementation manners of the present invention, and their descriptions are relatively specific and detailed, but they should not be construed as limiting the scope of the present invention. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present invention, several modifications and improvements can still be made, and these all belong to the protection scope of the present invention. Therefore, the protection scope of the present invention should be subject to the appended claims.

Claims

1. A slide scanning barcode recognition optimization method, characterized in that: The following steps are involved: S1. Image preprocessing: downsampling and illumination compensation processing are performed on the acquired slide image to obtain an illumination compensated image; S2, barcode area positioning and angle correction: obtaining the connected area where the barcode is located through morphological processing, determining the minimum circumscribed rectangle of the connected area to obtain preliminary angle information, and when the preliminary angle information is less than a preset threshold, extracting and clustering the lines of the connected area through Hough line detection, calculating the final correction angle according to the clustering result, and performing rotation calibration on the image after illumination compensation based on the final correction angle to obtain a calibrated image; S3, adaptive binarization processing: performing boundary extension on the calibrated image, calculating the integral image and the square integral image of the extended image, calculating the local mean and standard deviation of each pixel based on the integral image and the square integral image, and using the local mean and the standard deviation to construct a dynamic threshold to binarize the calibrated image to obtain a binarized image; S4. Barcode reconstruction and recognition: Perform morphological operations on the binary image to disconnect the adhesion areas and connect the discrete points, count the black and white interval widths of the barcode, group the black and white interval widths according to the encoding rules of the 39 code, extract the top 3 units in width in each group as wide bars, reconstruct the barcode and recognize it.

2. The slide scanning barcode recognition optimization method according to claim 1, characterized in that: In step S1, the illumination compensation process specifically includes: Dividing the slide image into a plurality of sub-regions of preset sizes, and calculating a pixel mean value of each sub-region as a low-frequency illumination component; The slide image is normalized according to the low-frequency illumination component to obtain an illumination-compensated image.

3. The slide scanning barcode recognition optimization method according to claim 1, characterized in that: In step S3, the calculation formula of the dynamic threshold is: ; Among them, μ is the mean value of pixels in the local window, σ is the standard deviation of pixels in the local window, k is the parameter that controls the weight of the influence of the standard deviation on the threshold, and r is the parameter that standardizes the range of the standard deviation.

4. The slide scanning barcode recognition optimization method according to claim 1, characterized in that: The morphological operations include: Using an erosion kernel of a preset size to perform an erosion process on the binary image to disconnect the adhesion area of ​​adjacent barcodes; The eroded image is processed through multiple opening and closing operations to connect the discrete point regions of the same barcode.

5. The slide scanning barcode recognition optimization method according to claim 1, characterized in that: The barcode reconstruction specifically includes: If the binary image recognition fails, the binary image is rotated 180° and then superimposed with the original binary image to obtain a supplemented binary image; The supplemented binary image is subjected to vertical projection statistics to obtain a black-and-white interval width array, and a barcode is reconstructed according to the width array and the 39-code encoding rule.

6. The slide scanning barcode recognition optimization method according to claim 1, characterized in that: The calculation of the integral map and the square integral map is used to quickly obtain the pixel sum and the pixel square sum in any rectangular area, reducing the computational complexity of the neighborhood pixel sum from O(N 2 ) is reduced to O(1), where N is the window size.

7. A slide scanning barcode recognition optimization method as described in any one of claims 1 to 6, characterized in that: The Hough line detection step comprises: A straight line segment of a preset length is extracted from the connected area, the straight line segments with similar slopes are grouped using a clustering algorithm, and the average value of the angle of each group of straight line segments is calculated as the final correction angle.

8. A slide scanning barcode recognition optimization device, characterized in that: include: An image preprocessing module performs downsampling and illumination compensation processing on the acquired slide image to obtain an illumination compensated image; The barcode area positioning and angle correction module obtains the connected area where the barcode is located through morphological processing, determines the minimum circumscribed rectangle of the connected area to obtain preliminary angle information, and extracts and clusters the connected area through Hough line detection when the preliminary angle information is less than the preset threshold. The final correction angle is calculated based on the clustering results, and the image after illumination compensation is rotated and calibrated based on the final correction angle to obtain the calibrated image; The adaptive binarization processing module performs boundary extension on the calibrated image, calculates the integral image and the square integral image of the extended image, calculates the local mean and standard deviation of each pixel based on the integral image and the square integral image, and uses the local mean and the standard deviation to construct a dynamic threshold to binarize the calibrated image to obtain a binarized image. Barcode reconstruction and recognition: perform morphological operations on the binary image to disconnect the adhesion area and connect the discrete points, count the black and white interval widths of the barcode, group the black and white interval widths according to the encoding rules of Code 39, extract the top 3 units in width in each group as the wide bar, reconstruct the barcode and recognize it.

9. An electronic device comprising a memory and a processor, characterized in that: The memory stores a computer program, and the processor is configured to run the computer program to execute the slide scanning barcode recognition optimization method according to any one of claims 1 to 7.

10. A readable storage medium, characterized in that: The readable storage medium stores a computer program, wherein the computer program includes a program code for controlling a process to execute a process, wherein the process includes the slide scanning barcode recognition optimization method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Method and device for recognizing low-resolution barcode

    CN101901329A

  • Two-dimensional code detection method and device

    CN110263595A

  • Text image tilt correction method, system and device and storage medium

    CN111553344A

  • Wrinkle bar code identification method

    CN114881064A

  • Method for detecting grain size of steel for lifting hook based on image processing

    CN115861326A

Cited By

  • Label image correction processing method, device and equipment

    CN121527769A

  • Automatic goods identification system of ARM robot

    CN121638288A

  • An automated cargo identification system for an arm robot

    CN121638288B