Small package complex background picture processing method and system for transparent text information extraction

By combining multiple image processing algorithms and deep learning models, the problem of low recognition accuracy in traditional OCR technology in complex backgrounds is solved, and efficient and accurate recognition of transparent text information of small packaging products is achieved.

CN119477780AInactive Publication Date: 2025-02-18NANTONG UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411551164.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-01
Publication Date
2025-02-18
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

When traditional OCR technology deals with complex backgrounds, color interference and font diversity, it has low recognition accuracy and low processing efficiency, making it difficult to effectively extract transparent text information on small packaging products.

Method used

Using a variety of image processing algorithms and deep learning models, including Gamma correction, CLAHE technology, median filtering, color segmentation, contour detection, morphological operation and PaddleOCR model, we will independently judge and correct errors in OCR recognition results and improve complex backgrounds. The accuracy of the recognition of transparent text information area under the following.

Benefits of technology

It significantly improves the accuracy and completeness of OCR recognition in complex backgrounds, reduces the phenomenon of snippets and text discontinuity, and realizes efficient and accurate identification of transparent text information areas under complex backgrounds.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119477780A_ABST
    Figure CN119477780A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of image processing, in particular to a small package complex background image processing method and system for transparent text information extraction, and the method comprises the steps: 1, reading at least one image file from an input directory, the image file comprising transparent text information and a complex background; 2, preprocessing the read image file to obtain a processed image; 3, recognizing a transparent character information area in the image through color segmentation and contour detection; 4, processing the transparent text information area by applying morphological operation; and 5, improving the definition of the processed image, and extracting the text content in the image by using an OCR technology. According to the method, through multi-step image processing, the definition of the transparent character information area is enhanced, the recognition rate is further improved through transparent character information area detection based on color segmentation, and the accuracy and integrity of OCR recognition under the complex background condition of the transparent character information are remarkably improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image processing, and in particular to a method and system for processing small-package complex background images for transparent text information extraction. Background Art

[0002] With the rapid development of automation technology, image-based text recognition technology has been widely used in various industries, especially in product packaging, logistics management, and information extraction. However, traditional OCR technology often faces problems of low recognition accuracy and low processing efficiency when dealing with complex backgrounds, color interference, and font diversity. Especially in small packaged products, due to the reflection, shadow, and background complexity of the packaging surface, traditional OCR methods often have difficulty in effectively extracting transparent text information areas, resulting in poor recognition results.

[0003] In recent years, image processing technology has made significant progress in improving OCR recognition performance. Gamma correction and CLAHE techniques are widely used in image preprocessing, which helps to enhance the contrast of images and improve the distinguishability between text and background. However, although these methods improve image quality to a certain extent, they still have limitations when detecting transparent text information in complex backgrounds.

[0004] In order to solve these problems, the present application proposes a small package complex background image processing method and system for transparent text information extraction. Summary of the invention

[0005] The purpose of the present invention is to solve the shortcomings existing in the prior art, and a small package complex background image processing method and system for transparent text information extraction is proposed. It combines multiple image processing algorithms and deep learning models, and can independently judge and correct errors in OCR recognition results, especially when processing complex or irregular backgrounds, to achieve efficient and accurate recognition of transparent text information areas under complex backgrounds.

[0006] In order to achieve the above object, the present invention adopts the following technical solutions:

[0007] A method for processing a small package complex background image for extracting transparent text information comprises the following steps:

[0008] Step 1: Read at least one image file from an input directory, wherein the image file contains transparent text information and a complex background;

[0009] Step 2: preprocessing the read image file to obtain a processed image, wherein the preprocessing step includes: applying Gamma correction to adjust image brightness, using CLAHE technology to enhance contrast, and using median filtering to reduce noise;

[0010] Step 3: Identify the transparent text information area in the image through color segmentation and contour detection;

[0011] Step 4: Apply morphological operations to process the transparent text information area to improve the integrity and readability of the text;

[0012] Step 5: Improve the clarity of the processed image and use OCR technology to extract the text content in the image.

[0013] Preferably, in step 1, the image file includes pictures such as product packaging, billboards, posters, etc., and the color contrast between the background and the text is usually low, making the text difficult to be recognized by traditional OCR algorithms; the color contrast between the background and the text is usually low, making the text difficult to be recognized by traditional OCR algorithms.

[0014] Preferably, in step 2, the read image file is subjected to gamma correction. Gamma correction is used to adjust the brightness value of the image to enhance the visibility of the transparent text information. By adjusting the gamma value, the details of the dark area are enhanced, and the transparent text information becomes more conspicuous due to the increased brightness, thereby improving the effect of the subsequent processing steps.

[0015] Among them, after gamma correction, CLAHE (Contrast Limited Adaptive Histogram Equalization) technology is further applied to the image. This step improves the brightness and contrast in complex backgrounds by limiting the range of local contrast enhancement, preventing overexposure or dark areas in the image after enhancement. CLAHE technology can effectively highlight transparent text information areas while retaining background details, ensuring that the contrast of text is improved without affecting the overall image quality.

[0016] Next, the image is subjected to denoising, and the median filter algorithm is used to reduce the impact of background noise on text recognition. Median filtering is a nonlinear filtering method that removes random noise in an image by replacing pixel values. This step can reduce noise interference in complex backgrounds, maintain edge details of the image, and make subsequent text area detection more accurate.

[0017] Preferably, in step 3, the denoised image is color segmented, and the color of the transparent text information area is filtered by the set HSV color range to adapt to different brightness and shadow conditions. Here, the image is converted to the HSV color space to more accurately extract the white text area. In the HSV color space, by setting the color range of the transparent text information (such as saturation and brightness thresholds), the transparent text information area in the image is separated from the background to form a preliminary text area mask.

[0018] Preferably, in step 3, a contour detection algorithm is applied to detect and draw contours, filter small contours, and retain only areas that may be text. Based on the mask generated by color segmentation, a contour detection algorithm is applied to detect the contour of the text area. Through contour detection, noise and non-text areas can be further filtered out to ensure that only those areas that may be transparent text information are retained. Contour detection helps to accurately define the boundaries of the text area, so that subsequent morphological processing can be more effective.

[0019] Preferably, in step 4, the morphological operation includes: performing a closing operation on the transparent text information area to fill the gaps in the text area, thereby enhancing the integrity of the text. The morphological operation is performed on the detected text area, including a closing operation. The closing operation is used to fill small gaps in the text area and connect broken edge lines. Since complex backgrounds may cause discontinuity in the text area, the closing operation can enhance the integrity of the text area and ensure that the text shape is clearer, thereby improving the accuracy of OCR recognition.

[0020] After the morphological operation is completed, sharpening processing is applied to appropriately sharpen the image. Sharpening enhances the edge details of the image, makes the edge of the transparent text information more prominent, and further enhances the contrast of the text area. This processing can prevent recognition difficulties caused by blur or noise.

[0021] Preferably, the image processing includes multiple iterations to extract more text information until the amount of text extraction no longer increases.

[0022] Preferably, in step 5, the OCR technology uses the PaddleOCR model for text recognition and supports the recognition of Chinese characters to ensure the accuracy of text extraction. Here, OCR technology is used to perform text recognition on the processed image, and the PaddleOCR model is adopted, which supports the recognition of Chinese characters and can accurately extract the content of transparent text information under complex background conditions. Among them, the PaddleOCR model extracts image features through a multi-layer convolutional neural network, and combines with a pre-trained character recognition model to ensure that high-quality text information can be recognized under a variety of background interferences.

[0023] The present invention also provides a small package complex background image processing system for transparent text information extraction, the system comprising:

[0024] Image input module, used to read image files containing transparent text information and complex background;

[0025] Image processing module, used to perform gamma correction, CLAHE, noise reduction, white text area detection and morphological processing;

[0026] The OCR module is used to perform text recognition on the processed image and output the final text result.

[0027] By adopting the above technical solutions: through multi-step image processing, including gamma correction, contrast-limited adaptive histogram equalization (CLAHE), noise reduction, sharpening and morphological operations, the clarity of transparent text information areas is enhanced, and the recognition rate is further improved through transparent text information area detection based on color segmentation. On this basis, combined with PaddleOCR to extract text from the enhanced image, the accuracy and completeness of OCR recognition under complex background conditions of transparent text information are significantly improved.

[0028] Compared with the prior art, the present invention has the following beneficial effects:

[0029] 1. The present invention significantly improves the visibility of transparent text information in complex backgrounds through gamma correction and CLAHE contrast enhancement.

[0030] 2. The present invention removes background noise through median filtering, uses closing operation to enhance the integrity of text, and reduces the phenomenon of word break and text discontinuity.

[0031] 3. This invention adopts the advanced PaddleOCR model for text recognition and combines it with image preprocessing technology to greatly improve the OCR recognition accuracy under complex backgrounds.

[0032] 4. The present invention combines a variety of image processing algorithms with deep learning models, and can independently judge and correct errors in OCR recognition results, especially when processing complex or irregular backgrounds, and achieve efficient and accurate recognition of transparent text information areas under complex backgrounds. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] Figure 1 is a flow chart of the present invention;

[0034] Figure 2 This is a comparison chart of OCR recognition of images before and after processing in an embodiment of the present invention. DETAILED DESCRIPTION

[0035] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the accompanying drawings, so that those skilled in the art can better understand the advantages and features of the present invention, thereby making a clearer definition of the protection scope of the present invention. The embodiments described in the present invention are only a part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present invention.

[0036] like Figure 1 As shown, a small package complex background image processing method for transparent text information extraction includes the following steps:

[0037] Step 1: Read at least one image file from an input directory, wherein the image file contains transparent text information and a complex background;

[0038] Step 2: preprocessing the read image file to obtain a processed image, wherein the preprocessing step includes: applying Gamma correction to adjust image brightness, using CLAHE technology to enhance contrast, and using median filtering to reduce noise;

[0039] Step 3: Identify the transparent text information area in the image through color segmentation and contour detection;

[0040] Step 4: Apply morphological operations to process the transparent text information area to improve the integrity and readability of the text;

[0041] Step 5: Improve the clarity of the processed image and use OCR technology to extract the text content in the image.

[0042] Example 1: Image reading

[0043] First, read the image file containing transparent text information and complex background from the input directory. The image file can be of the type of product packaging, billboard or label, and the image format can include common formats such as JPEG and PNG. The image is imported into the processing system through the image reading function cv2.imread() and stored as a three-channel RGB format image to ensure data integrity in subsequent processing steps. In order to ensure the efficiency of batch image processing, the system will traverse all image files in the input directory and process them one by one in order.

[0044] Example 2: Image resizing

[0045] Since the resolution and size of different images vary, in order to unify the processing standards, the present invention first resizes the images. The width of all input images is uniformly adjusted to 1024 pixels, keeping the image aspect ratio unchanged. This step is implemented by the cv2.resize() function of OpenCV, and bilinear interpolation is used for scaling to ensure that the image quality is not affected during the scaling process.

[0046] Example 3: Gamma Correction

[0047] In order to improve the visibility of transparent text information in the image, the image is first subjected to Gamma correction. Gamma correction is a nonlinear brightness adjustment method used to enhance the bright areas of the image to make the transparent text information more prominent. Gamma correction formula:

[0048]

[0049] Among them, I out (x, y) is the pixel value of the output image at position (x, y) after Gamma correction; I in (x, y) is the pixel value of the input image at position (x, y); Gamma value controls the image brightness. When Gamma < 1, the output image becomes darker, when Gamma > 1, the output image becomes brighter, and when Gamma = 1, the output image is the same as the input image. The Gamma value is set to 1.8 through the formula calculation. In the corrected image, the brightness of the transparent text information is significantly improved, and the contrast of the background area is enhanced, which is conducive to the subsequent text area segmentation. This step pre-generates the Gamma lookup table (LUT) and uses the cv2.LUT() function to efficiently perform the Gamma transformation of each pixel.

[0050] Example 4: CLAHE contrast enhancement

[0051] In order to further improve the contrast between the transparent text information and the complex background in the image, the CLAHE (contrast-limited adaptive histogram equalization) technology is used to locally enhance the image. The specific steps include: first, convert the RGB image to a grayscale image to reduce color interference; then, apply the CLAHE technology to the grayscale image to limit the enhancement of the local contrast to avoid artifacts caused by over-enhancement. The grid size is set to 8x8, and the maximum contrast enhancement limit is 3.0; finally, the enhanced image is converted back to three channels for subsequent processing. The advantage of CLAHE technology is that it can locally adjust the image contrast to avoid overall image distortion, especially under complex backgrounds, effectively improving the contrast of the text area.

[0052] Example 5: Image denoising

[0053] Since complex backgrounds may contain noise, textures or gradient colors, these interferences will affect text recognition. Therefore, the median filter technology is applied to reduce noise on the image. Median filtering effectively removes isolated noise points by selecting the median value of each pixel neighborhood to replace the current pixel value, and does not blur the edge of the image. In this embodiment, a 5x5 filter window is used to ensure that the details of the text edge are retained while removing noise. This operation is implemented by the cv2.medianBlur() function of OpenCV.

[0054] Example 6: Color Segmentation

[0055] In order to extract the transparent text information from the complex background, the image is converted from the RGB color space to the HSV color space. The HSV color space can better distinguish the color, brightness and saturation information, which is convenient for color segmentation. The specific segmentation steps are as follows: convert the image to HSV format, extract the hue (H), saturation (S) and brightness (V) channels; set the color threshold range of the transparent text information: the hue range is 0180, the saturation range is 050, and the brightness range is 200255; use the cv2.inRange() function to generate a binary mask image, the transparent text information area in the mask image is the foreground (value 255), and the rest is the background (value 0). The purpose of this step is to accurately separate the transparent text information area in the complex background, laying the foundation for subsequent contour detection and morphological processing.

[0056] Example 7: Contour Detection

[0057] The binary mask image generated by color segmentation may contain multiple connected areas. Use contour detection technology to identify transparent text information areas in the image. The specific steps are as follows: Use cv2.findContours() function to detect contour information in the binary image; set a minimum contour area threshold (such as 100 pixels) to filter out smaller noise contours and only retain larger contours that may be text areas. Contour detection can accurately determine the boundaries of text areas and provide input for subsequent morphological operations.

[0058] Example 8: Morphological Processing

[0059] In order to enhance the integrity of the text area, the "closing operation" in the morphological operation is used to process the image after contour detection. The closing operation can fill the small gaps in the text area and connect the broken text edges to ensure the integrity of the text shape. The specific operation is to use a 5x5 structure element to perform a morphological dilation operation to expand the edge of the text area; then perform an erosion operation to restore the normal text boundary. This operation is implemented through the cv2.morphologyEx() function, and finally generates a complete and coherent text area to avoid recognition errors caused by broken edges.

[0060] Example 9: Sharpening

[0061] In the processed image, the text area is basically clear, but in order to further enhance the edge details of the text, sharpening technology is used. The second-order derivative of the image is calculated through the Laplace operator to enhance the edge part of the image. The specific steps are as follows:

[0062] The convolution kernel used is:

[0063]

[0064] This convolution kernel can highlight the edge information in the image and is particularly suitable for enhancing the outline of text. The sharpened image has a stronger contrast and the text edges are more prominent, making it suitable for OCR recognition.

[0065] Example 10: OCR recognition

[0066] After the above image processing steps, the transparent text information area has been significantly enhanced, and the PaddleOCR model is used to recognize the text in the image. The PaddleOCR model uses a convolutional neural network (CNN) to extract image features and combines it with a long short-term memory network (LSTM) to predict character sequences. The specific OCR recognition process is as follows: First, the edge, texture and other features of the image are extracted through a convolutional neural network; then, the LSTM model is used to analyze the coherence and shape features of the characters and predict the character sequence; finally, the recognition result is output.

[0067] Example 11: Iterative Processing

[0068] In some cases, image processing and OCR recognition may require multiple iterations to achieve the best results. Therefore, the present invention designs an iterative processing mechanism. Specifically, after each processing is completed, the number of recognized characters is calculated; if the recognition result of the current iteration increases compared to the previous result, the iterative processing continues; if the number of recognized characters does not change, the iteration is stopped and the final result is output. This iterative mechanism can further improve the accuracy of character recognition in complex backgrounds or low-quality images.

[0069] like Figure 2 As shown in the effect, when the unprocessed image is directly recognized, Figure 2 In (a), only 70% to 75% of the text can be recognized, and many words cannot be recognized due to the complex interference of the background. Figure 2 As shown in (b), the recognition rate can reach over 95%.

[0070] In summary, the present invention combines a variety of image processing algorithms with deep learning models, and can independently judge and correct errors in OCR recognition results, especially when processing complex or irregular backgrounds, and realize efficient and accurate recognition of transparent text information areas under complex backgrounds.

[0071] The description and practice disclosed in the present invention are easy to think and understand for ordinary technicians in the technical field, and several improvements and modifications can be made without departing from the principles of the present invention. Therefore, modifications or improvements made without departing from the spirit of the present invention should also be regarded as the protection scope of the present invention.

Claims

1. A method for processing small-package complex background images for transparent text information extraction, characterized in that: The steps include: Step 1: Read at least one image file from an input directory, wherein the image file contains transparent text information and a complex background; Step 2: preprocessing the read image file to obtain a processed image, wherein the preprocessing step includes: applying Gamma correction to adjust image brightness, using CLAHE technology to enhance contrast, and using median filtering to reduce noise; Step 3: Identify the transparent text information area in the image through color segmentation and contour detection; Step 4: Apply morphological operations to process the transparent text information area to improve the integrity and readability of the text; Step 5: Improve the clarity of the processed image and use OCR technology to extract the text content in the image.

2. According to the method for processing small package complex background images for extracting transparent text information according to claim 1, it is characterized in that: In step 1, the image files include product packaging, billboards, and poster images.

3. According to the method for processing small package complex background images for extracting transparent text information according to claim 1, it is characterized in that: In step 2, the image is subjected to denoising, and a median filter algorithm is used to reduce the impact of background noise on text recognition.

4. The method for processing small package complex background images for extracting transparent text information according to claim 1 is characterized in that: In step 3, the denoised image is color segmented, and the color of the transparent text information is filtered through the set HSV color range to adapt to different brightness and shadow conditions.

5. The method for processing small package complex background images for extracting transparent text information according to claim 4 is characterized in that: In step 3, a contour detection algorithm is applied to detect and draw contours, filter small contours, and retain only areas that may be text.

6. The method for processing small package complex background images for extracting transparent text information according to claim 1, characterized in that: In step 4, the morphological operation includes: performing a closing operation on the transparent text information area to fill the gaps in the text area, thereby enhancing the integrity of the text.

7. A method for processing small package complex background images for extracting transparent text information according to any one of claims 1 to 6, characterized in that: Image processing includes multiple iterations to extract more text information until the amount of text extraction no longer increases.

8. The method for processing small package complex background images for extracting transparent text information according to claim 1, characterized in that: In step 5, the OCR technology uses the PaddleOCR model for text recognition and supports the recognition of Chinese characters to ensure the accuracy of text extraction.

9. A small package complex background image processing system for transparent text information extraction, characterized in that: The system comprises: Image input module, used to read image files containing white text and complex background; Image processing module, used to perform gamma correction, CLAHE, noise reduction, transparent text information area detection and morphological processing operations; The OCR module is used to perform text recognition on the processed image and output the final text result.

10. A small package complex background image processing system for transparent text information extraction according to claim 9, characterized in that: The operations of the image processing module are implemented by computer program instructions, and the program can be stored on a computer readable medium to facilitate the deployment and operation of the system.