Image processing method, computer device and storage medium

By automatically generating a defective printed image processing method, the problem of insufficient training data is solved, automatic labeling and efficient generation of defective image samples are achieved, and labor costs are reduced.

CN115705728BActive Publication Date: 2025-09-30HONG FU JIN PRECISION IND (SHENZHEN) CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110888256.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-08-03
Publication Date
2025-09-30
Estimated Expiration
2041-08-03

AI Technical Summary

Technical Problem

In the existing technology, there is a lack of a large number of defective printed image samples in industrial production for training defect detection models. The manual synthesis and labeling process is labor-intensive and error-prone, leading to the problem of insufficient training data.

Method used

The method for automatically generating a defective printed image includes obtaining a defect-free image, segmenting a text area and processing it into multiple images, calculating a similarity measure, determining a defect threshold, synthesizing a defective image, and reducing manual participation.

Benefits of technology

It achieves automatic labeling of training samples without the need for additional deep learning models, reduces the cost of manual synthesis and labeling, and generates a large number of defective images for training.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115705728B_ABST
    Figure CN115705728B_ABST
Patent Text Reader

Abstract

The present application provides an image processing method, computer device, and storage medium, wherein the method includes: determining the text area and background area of ​​a flawless image to obtain a first image of each character; removing the background from the first image to obtain a second image; processing the second image to obtain a third image, N fourth images, and N fifth images corresponding to the fourth image; calculating a similarity measure between each fifth image and the corresponding third image to determine a defect threshold; determining whether the fourth image corresponding to the fifth image is a flawed image; and when the fourth image is a flawed image, intercepting a background image, performing shading processing on the background image, and synthesizing the flawed image and the shading-processed background image to obtain a composite image. The present application can assist in generating flawed training samples and reduce labor costs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing, and in particular to an image processing method, a computer device, and a storage medium. Background Art

[0002] Due to the high yield rate in current industrial production processes, it is difficult to obtain a large number of defective printed image samples to use as training samples for defect detection models. Existing methods for manually synthesizing defective samples require manual labeling of the defective data after generating simulated data, or training a separate deep learning model to classify them. This consumes a lot of manpower and time, and the manual labeling process is prone to errors. How to efficiently solve the problem of insufficient training data while ensuring accuracy has always been a major challenge in the application of deep learning. Summary of the Invention

[0003] In view of the above, it is necessary to provide an image processing method, a computer device and a storage medium that can automatically generate a large number of defective printed images and reduce the cost of manual synthesis and marking.

[0004] The image processing method includes: obtaining a flawless image, determining a text area and a background area of ​​the flawless image, and determining the position of each character in the text area; segmenting the text area according to the position of each character to obtain a first image of each character; removing the background from the first image of each character to obtain a second image of each character; processing the second image of each character according to a preset first image processing method to obtain a third image of each character; processing the second image of each character according to a preset second image processing method to obtain N fourth images and N fifth images of each character, wherein the N fourth images of each character correspond to the N fifth images one-to-one, and N is a positive integer greater than 1; calculating a similarity measure between each fifth image of the N fifth images of each character and the third image of each character to obtain a similarity measure for each character. The method comprises the following steps: comparing the N similarity metrics corresponding to each character with the N similarity metrics corresponding to each character, and establishing associations between the N fifth images of each character and the N similarity metrics corresponding to each character, and determining a defect threshold value according to the N similarity metrics corresponding to all the characters in the character area; comparing each similarity metric in the N similarity metrics corresponding to each character with the defect threshold value, wherein when any similarity metric corresponding to any character is greater than the defect threshold value, determining that the fourth image corresponding to the fifth image associated with the any similarity metric is a defective image; when any fourth image is determined to be a defective image, cutting out a background image from the background area, wherein the size of the cut-out background image is equal to the size of the defective image; and performing brightness and darkness processing on the cut-out background image, synthesizing the defective image and the background image after the brightness and darkness processing to obtain a synthesized image.

[0005] Optionally, the first image processing method includes image binarization and contour extraction; the second image processing method includes erasure processing, image binarization and contour extraction.

[0006] Optionally, removing the background of the first image of each character to obtain the second image of each character includes method 1: using the Otsu algorithm to determine the first threshold of the first image, obtaining the mask of the first image according to the first threshold, and performing a bitwise AND operation on the mask and the first image to obtain a foreground character image of the first image; and using Gaussian blur technology to soften the edges of the foreground character image to obtain the second image.

[0007] Optionally, removing the background of the first image of each character to obtain the second image of each character includes method two: using Fourier transform to remove dots in the first image, and binarizing the first image after removing the dots; and using Gaussian blur technology to soften the edges of the binarized first image to obtain the second image.

[0008] Optionally, the first image processing method and the second image processing method perform image binarization according to the first threshold value, and perform contour extraction using a Fourier descriptor algorithm or an invariant moment algorithm.

[0009] Optionally, the second image of each character is processed according to a preset second image processing method to obtain N fourth images and N fifth images of each character, and the N fourth images of each character correspond to the N fifth images one by one, including: randomly erasing the second image of each character N times to obtain N fourth images of each character; performing image binarization on the N fourth images of each character to obtain N black and white images; and performing contour extraction on the N black and white images to obtain the N fifth images.

[0010] Optionally, the similarity measure refers to the Euclidean distance between each fifth image of each character and the third image of each character; wherein, determining a defect threshold based on the N similarity measures corresponding to all the characters in the text area includes: making a line graph of the relationship between the similarity measure and the number of images according to the number of images of the fifth image corresponding to each value of the similarity measure; and taking the first local minimum value of the similarity measure in the line graph as the defect threshold.

[0011] Optionally, the intercepted background image is subjected to brightness and darkness processing, and the defective image and the background image after brightness and darkness processing are synthesized to obtain a synthesized image, which includes: performing multiple brightness and darkness adjustments on the intercepted background image to obtain multiple adjusted images, and synthesizing the multiple adjusted images with the defective image respectively to obtain multiple synthesized images.

[0012] The computer-readable storage medium stores at least one instruction, and when the at least one instruction is executed by a processor, the image processing method is implemented.

[0013] The computer device includes a memory and at least one processor. The memory stores at least one instruction. When the at least one instruction is executed by the at least one processor, the image processing method is implemented.

[0014] Compared with the existing technology, the image processing method, computer device and storage medium can automatically generate a large number of defective printed images, and can automatically label the training samples therein without training additional deep learning models, thereby reducing the cost of manual synthesis and labeling. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are merely embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without any creative work.

[0016] Figure 1 This is a flowchart of the image processing method provided in an embodiment of the present application.

[0017] Figure 2 This is an architectural diagram of a computer device provided in an embodiment of the present application.

[0018] Figure 3A This is an example diagram of step S1 and step S2 provided in an embodiment of the present application.

[0019] Figure 3B This is an example diagram of the process of obtaining the second image provided in an embodiment of the present application.

[0020] Figure 4 This is an example diagram of the process of obtaining a defective image provided by an embodiment of the present application.

[0021] Figure 5 This is an example diagram of the broken line relationship diagram provided in the embodiment of the present application.

[0022] Figure 6 This is an example diagram of the process of obtaining a composite image provided in an embodiment of the present application.

[0023] Description of main component symbols

[0024] Computer device 3 Image processing system 30 Memory 31 processor 32

[0025] The following specific implementation methods will further illustrate the present application in conjunction with the above-mentioned drawings. DETAILED DESCRIPTION

[0026] In order to more clearly understand the above-mentioned objectives, features and advantages of the present application, the present application is described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that the embodiments of the present application and the features therein can be combined with each other in the absence of conflict.

[0027] The following description sets forth many specific details to facilitate a full understanding of the present application. The embodiments described are only a portion of the embodiments of the present application, not all of the embodiments. All other embodiments derived by persons of ordinary skill in the art based on the embodiments of the present application without creative effort are intended to fall within the scope of protection of the present application.

[0028] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application pertains. The terms used herein in the specification of this application are for the purpose of describing specific embodiments only and are not intended to limit this application.

[0029] See Figure 1 FIG. 1 is a flowchart of an image processing method according to a preferred embodiment of the present application.

[0030] In this embodiment, the image processing method can be applied to a computer device (eg Figure 2 In the computer device 3) shown, for a computer device that needs to perform image processing, the image processing function provided by the method of the present application can be directly integrated on the computer device, or run on the computer device in the form of a software development kit (SDK).

[0031] like Figure 1 As shown, the image processing method specifically includes the following steps. According to different requirements, the order of the steps in the flowchart can be changed, and some steps can be omitted.

[0032] In step S1 , a computer device obtains a flawless image, determines a text area and a background area of ​​the flawless image, and determines a position of each character in the text area.

[0033] In one embodiment, a computer device can obtain a flawless image in response to user input. The flawless image can also be pre-stored in a memory of the computer device or in another device communicatively connected to the computer device. In this embodiment, the flawless image can be a standard sample (Golden Sample) of a factory-produced printed product, containing text (e.g., Chinese characters, numbers, English letters, etc.). It should be noted that the position of the standard sample image does not require correction, nor does the orientation of the text within it.

[0034] In one embodiment, the computer device can use optical character recognition (OCR) technology to identify the text in the flawless image, thereby confirming the text area and background area of ​​the flawless image, and determining the position of each character in the text area. The text area refers to the area containing the text, and the computer device can use region of interest (ROI) technology to outline the text area, for example Figure 3A As shown, all the characters are framed in a large rectangular frame (solid line) along the arrangement direction of the characters, and the character area is framed. It should be noted that Figure 3A The dotted frame outside the large rectangular frame is only used to indicate the large rectangular frame; the background area refers to the area that does not contain text, that is, the area outside the text area in the flawless image, for example Figure 3A The area indicated by the shaded area is shown.

[0035] In step S2, the computer device segments the text area according to the position of each character to obtain a first image of each character.

[0036] In one embodiment, the computer device can use the character segmentation function of the OCR software to segment the text area, segment the area where each character is located, and obtain the first image of each character, wherein the first image of each character includes an image of the complete outline of the character. Figure 3A The large rectangular box (solid line) in the figure is segmented according to Figure 3A The small rectangular box (solid line) in the image is used to segment the rectangular image of the area where the character "0" is located, and the image is obtained as follows: Figure 3B In the first image 3B1 of the character "0", it should be noted that Figure 3A The dotted frame outside the small and medium rectangular frames is only used to indicate the small rectangular frames.

[0037] In step S3, the computer device removes the background of the first image of each character to obtain a second image of each character.

[0038] In one embodiment, removing the background of the first image of each character to obtain the second image of each character includes method 1: a computer device uses the Otsu Thresholding algorithm to determine a first threshold of the first image, obtains a mask of the first image according to the first threshold, and performs a bitwise AND operation on the mask and the first image to obtain a foreground character image of the first image; and uses Gaussian Blur technology to soften the edges of the foreground character image to obtain the second image.

[0039] In one embodiment, the method is applicable to the first image with low background complexity, for example, the first image is a silk screen printing image. The Otsu algorithm can determine the first threshold of the first image, the first threshold including the best segmentation threshold (for example, 30) of the image binarization of the first image; and binarize the first image according to the first threshold to obtain the mask of the first image. For example Figure 3BIn the example, the mask image 3B2 of the first image 3B1 is obtained using the Otsu algorithm.

[0040] In one embodiment, the bitwise AND operation can separate the foreground text outline image from the background that does not contain the text outline in the first image, thereby obtaining the foreground text image and the background image of the first image, wherein the background of the foreground text image is transparent. Figure 3B , the foreground text image 3B3 and background image 3B4 of image 3B1 are obtained based on image 3B2.

[0041] In one embodiment, Figure 3B As shown in the foreground text image 3B3, since the foreground text image may contain jagged edges, the Gaussian blur technique can be used to soften the edges, and the obtained second image is as shown in FIG. Figure 3B As shown in the second image 3B5.

[0042] In one embodiment, removing the background from the first image of each character to obtain the second image of each character includes method 2: a computer device uses Fourier transform to remove dots in the first image and binarizes the first image after the dots are removed; and uses Gaussian blur technology to soften the edges of the binarized first image to obtain the second image.

[0043] In one embodiment, method 2 is applicable to a first image with a complex background containing dots (e.g., square dots, circular dots, etc.), for example, a multi-color printed image. The Fourier transform can change the frequency of the first image to remove the dots. The binarization performed on the first image after dot removal can be the Otsu algorithm described in method 1. The Gaussian blurring technique is the same as that used in method 1.

[0044] In step S4 , the computer device processes the second image of each character according to a preset first image processing method to obtain a third image of each character.

[0045] In one embodiment, the first image processing method includes image binarization and contour extraction. The computer device performs image binarization on the second image according to the first threshold value. For example, when the pixel value at any position in the second image is greater than or equal to the first threshold value, the pixel at any position is binarized to 255; when the pixel value at any position in the second image is less than the first threshold value, the pixel at any position is binarized to 0. For example Figure 4 As shown, image 4A1 is obtained after the second image 3B5 is binarized.

[0046] In one embodiment, the computer device uses a Fourier descriptor algorithm or an invariant moment algorithm to extract the outline of the text in the second image after the image is binarized; the Fourier descriptor algorithm can identify the closed edges of the text outline in the second image after the image is binarized and reconstruct it, thereby extracting the text outline; the invariant moment algorithm uses properties such as translation invariance, scale invariance and rotation invariance to describe the overall characteristics of the second image after the image is binarized, thereby extracting the text outline in the second image after the image is binarized. For example Figure 4 As shown, after contour extraction is performed on image 4A1, a third image 4A2 of the character "0" is obtained. It should be noted that each character in the flawless image has a corresponding third image. When the flawless image contains M characters, a total of M third images are obtained, where M represents a positive integer greater than 0.

[0047] In step S5, the computer device processes the second image of each character according to a preset second image processing method to obtain N fourth images and N fifth images of each character, where the N fourth images and N fifth images of each character correspond one to one, and N is a positive integer greater than 1.

[0048] In one embodiment, the computer device may use an image erasing tool (e.g., an eraser tool in Photoshop) to randomly erase the second image of each character N times to obtain N fourth images of each character, for example Figure 4 As shown, after randomly erasing the second image 3B5 of the character “0” twice, two fourth images of the character “0” are obtained: a fourth image 4B1 and a fourth image 4C1.

[0049] In one embodiment, the computer device performs image binarization on the N fourth images of each character to obtain N black and white images. The image binarization is the same as the method used in step S4, for example Figure 4 As shown, image 4B2 is obtained after image binarization is performed on the fourth image 4B1, and image 4C2 is obtained after image binarization is performed on the fourth image 4C1.

[0050] In one embodiment, the computer device performs contour extraction on the N black-and-white images to obtain the N fifth images. The contour extraction is the same as the method used in step S4, for example Figure 4 As shown, after performing contour extraction on image 4B2, a fifth image 4B3 of the character "0" is obtained; after performing contour extraction on image 4C2, a fifth image 4C3 of the character "0" is obtained.

[0051] It should be noted that when the flawless image contains M characters, after obtaining N fourth images of each character, a total of M*N fourth images of all characters are obtained, and M*N fifth images are also obtained.

[0052] In step S6, the computer device calculates a similarity measurement (Similarity Measurement) between each of the N fifth images of each character and the third image of each character, obtains N similarity measurements corresponding to each character, and establishes an association between the N fifth images of each character and the N similarity measurements corresponding to each character, and determines a defect threshold based on the N similarity measurements corresponding to all the characters in the character area.

[0053] In one embodiment, the similarity measure refers to the Euclidean distance between each fifth image of each character and the third image of each character. The computer device calculates the Euclidean distance between each fifth image of each character and the third image of each character, thereby obtaining the value of the similarity measure corresponding to each fifth image of each character. For example, Figure 4 As shown, for the character "0" with two fifth images, the Euclidean distance between the fifth image 4B3 and the third image 4A2 of the character "0" is 0.76, and the Euclidean distance between the fifth image 4C3 and the third image 4A2 of the character "0" is 0.23. It should be noted that when the flawless image contains M characters, after obtaining N fourth images for each character, a total of M*N fourth images for all characters are obtained, which also results in M*N fifth images, and thus M*N similarity metrics.

[0054] In one embodiment, determining a defect threshold based on N similarity metrics corresponding to all the text in the text area includes: creating a line graph of the relationship between the similarity metric and the number of images according to the number of images of the fifth image corresponding to each value of the similarity metric.

[0055] Specifically, when the flawless image contains M characters, after obtaining M*N similarity metric values, the computer device will count the number of fifth images corresponding to each similarity metric value, and use the similarity metric as the horizontal axis and the number of fifth images as the vertical axis to create the broken line relationship graph. For example, the number of fifth images corresponding to a similarity metric value of 0.01 is 36, the number of fifth images corresponding to a similarity metric value of 0.35 is 0, the number of fifth images corresponding to a similarity metric value of 0.82 is 52, and so on. The resulting broken line relationship graph is as follows: Figure 5 shown.

[0056] In one embodiment, the computer device uses the first local minimum value (Local Minimum) of the similarity measure in the line relationship graph as the defect threshold. Figure 5 As shown in FIG, the first local minimum value of the similarity measure in the broken line relationship graph is 0.35, so the defect threshold is 0.35. It should be noted that, Figure 5 The dashed line in is for example only. The first local minimum is 0.35.

[0057] In step S7, the computer device compares each similarity metric among the N similarity metrics corresponding to each character with the size of the defect threshold. When any similarity metric corresponding to any character is less than or equal to the defect threshold, step S8 is executed. When any similarity metric corresponding to any character is greater than the defect threshold, step S9 is executed.

[0058] In step S8 , the computer device determines that the fourth image corresponding to the fifth image associated with any one of the similarity metrics is a flawless image.

[0059] For example, the Euclidean distance between the fifth image 4C3 of the character “0” and the third image 4A2 is 0.23, which is smaller than the defect threshold of 0.35. The computer device may mark the fourth image 4C1 as a flawless image.

[0060] In step S9, the computer device determines that the fourth image corresponding to the fifth image associated with any one of the similarity metrics is a defective image; when any one of the fourth images is determined to be a defective image, a background image is cut out from the background area, and the size of the cut out background image is equal to the size of the defective image; and the cut out background image is subjected to brightness processing, and the defective image and the background image after the brightness processing are synthesized to obtain a synthesized image.

[0061] For example, if Figure 4 As shown, the Euclidean distance between the fifth image 4B3 of the character “0” and the third image 4A2 is 0.76, which is greater than the defect threshold of 0.35. The computer device can mark the fourth image 4B1 as a defective image 4B1.

[0062] In one embodiment, since the brightness of the text area and the background area may be slightly different, the background image may be adjusted multiple times (for example, 4 times) to increase the tolerance to ambient light, thereby obtaining multiple images with adjusted brightness (for the sake of clarity, the images with adjusted brightness are referred to as "adjusted images"); the multiple adjusted images are synthesized with the defective image to obtain multiple synthesized images. For example Figure 6 As shown, the computer device cuts out a background image 6A of the same size as the defective image 4B1 from the background area, adjusts the brightness and darkness of the background image 6A four times, and synthesizes the defective image 4B1 and the background image 6A after each brightness and darkness processing to obtain synthesized image 6B, synthesized image 6C, synthesized image 6D, and synthesized image 6E.

[0063] In one embodiment, the synthetic image can be used as a defective sample to train a neural network to obtain a defect detection model; after obtaining the synthetic image of any text, steps S5 to S9 can be repeated to obtain more (for example, 80) defective samples of the any text.

[0064] In one embodiment, when the flawless image contains M characters, the computer device obtains N fourth images of each character, and obtains a total of M*N fourth images; the computer device determines that K fourth images among the M*N fourth images are defective images, and intercepts K background images corresponding to each of the defective images from the background area; the computer device performs L brightness adjustments on each image, and then synthesizes each background image after brightness adjustment with the corresponding defective image to obtain K*L synthesized images, where K is a positive integer less than M*N, and L is a positive integer greater than one.

[0065] In step S10, the computer device determines the relationship between the number of the composite images and a preset second threshold value. When the number of the composite images is less than the preset second threshold value, step S1 is executed; when the number of the composite images is greater than or equal to the preset second threshold value, step S11 is executed.

[0066] In one embodiment, the preset second threshold may be 100,000.

[0067] In step S11 , a computer device uses the synthetic image to train a neural network to obtain a defect detection model.

[0068] above Figure 1 The image processing method of this application is introduced in detail. Figure 2 , the hardware device architecture for implementing the image processing method is introduced.

[0069] It should be understood that the embodiment is for illustration only and the scope of the patent application is not limited to this structure.

[0070] See Figure 2 As shown, it is a schematic diagram of the structure of the computer device provided in the preferred embodiment of the present application. In the preferred embodiment of the present application, the computer device 3 includes a memory 31 and at least one processor 32. Those skilled in the art should understand that Figure 2 The structure of the computer device shown does not constitute a limitation of the embodiments of the present application, and can be either a bus structure or a star structure. The computer device 3 can also include more or less other hardware or software than shown in the figure, or a different component arrangement.

[0071] In some embodiments, the computer device 3 includes a terminal that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to a microprocessor, a dedicated integrated circuit, a programmable gate array, a digital processor and an embedded device.

[0072] It should be noted that the computer device 3 is only an example. Other existing or future electronic products that are suitable for this application should also be included in the scope of protection of this application and included here by reference.

[0073] In some embodiments, the memory 31 is used to store program code and various data. For example, the memory 31 can be used to store flawless images, or the image processing system 30 installed in the computer device 3, and can achieve high-speed, automatic access to programs or data during the operation of the computer device 3. The memory 31 includes read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), one-time programmable read-only memory (OTPROM), electronically erasable programmable read-only memory (EEPROM), compact disc read-only memory (CD-ROM) or other optical disk storage, magnetic disk storage, magnetic tape storage, or any other computer-readable storage medium capable of carrying or storing data.

[0074] In some embodiments, the at least one processor 32 may be comprised of an integrated circuit, such as a single packaged integrated circuit or a plurality of packaged integrated circuits with the same or different functions, including a combination of one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and various control chips. The at least one processor 32 is the control core (Control Unit) of the computer device 3, connecting the various components of the entire computer device 3 using various interfaces and circuits. It executes or runs programs or modules stored in the memory 31 and calls data stored in the memory 31 to perform various functions of the computer device 3 and process data, such as image processing.

[0075] In some embodiments, the image processing system 30 is run in a computer device 3. The image processing system 30 may include a plurality of functional modules composed of program code segments. The program code of each program segment in the image processing system 30 may be stored in a memory 31 of the computer device 3 and executed by at least one processor 32 to implement Figure 1 The image processing functions are shown.

[0076] In this embodiment, the image processing system 30 can be divided into multiple functional modules according to the functions it performs. A module as referred to in this application refers to a series of computer program segments that can be executed by at least one processor and can perform fixed functions, which are stored in a memory.

[0077] Although not shown, the computer device 3 may also include a power source (such as a battery) to power various components. Preferably, the power source may be logically connected to the at least one processor 32 via a power management device, thereby enabling the power management device to manage charging, discharging, and power consumption. The power source may also include one or more DC or AC power sources, a recharging device, a power failure detection circuit, a power converter or inverter, a power status indicator, and other arbitrary components. The computer device 3 may also include various sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be described in detail here.

[0078] It should be understood that the embodiment is for illustration only and the scope of the patent application is not limited to this structure.

[0079] The above-mentioned integrated unit implemented in the form of a software functional module can be stored in a computer-readable storage medium. The above-mentioned software functional module is stored in a storage medium and includes a number of instructions for causing a computer device (which can be a server, personal computer, etc.) or a processor to execute parts of the methods described in various embodiments of the present application.

[0080] In a further embodiment, in combination Figure 2 The at least one processor 32 can execute the operating system of the computer device 3 and various installed application programs (such as the image processing system 30), program codes, etc., for example, the various modules mentioned above.

[0081] The memory 31 stores program code, and the at least one processor 32 can call the program code stored in the memory 31 to perform related functions. The program code stored in the memory 31 can be executed by the at least one processor 32, thereby realizing the functions of the various modules to achieve the purpose of image processing.

[0082] In one embodiment of the present application, the memory 31 stores one or more instructions (ie, at least one instruction), and the at least one instruction is executed by the at least one processor 32 to implement Figure 1 The images shown are processed for the purpose.

[0083] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the module division is only a logical function division, and other division methods may be used in actual implementation.

[0084] The modules described as separate components may or may not be physically separate, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed across multiple network elements. Some or all of the modules may be selected to achieve the purpose of the solution of this embodiment according to actual needs.

[0085] In addition, the functional modules in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional modules.

[0086] It is obvious to those skilled in the art that the present application is not limited to the details of the above-mentioned exemplary embodiments, and that the present application can be implemented in other specific forms without departing from the spirit or basic characteristics of the present application. Therefore, from any point of view, the embodiments should be regarded as exemplary and non-restrictive, and the scope of the present application is defined by the appended claims rather than the above description, and it is intended that all changes that fall within the meaning and scope of the equivalent elements of the claims are included in the present application. Any figure mark in the claims should not be regarded as limiting the claim involved. In addition, it is obvious that the word "comprising" does not exclude other units or, and the singular does not exclude the plural. Multiple units or devices stated in the device claim can also be implemented by one unit or device through software or hardware. Words such as first, second, etc. are used to indicate names and do not indicate any particular order.

[0087] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application and are not limiting. Although the present application has been described in detail with reference to the above preferred embodiments, those skilled in the art should understand that the technical solutions of the present application may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present application.

Claims

1. An image processing method, characterized in that: The method comprises: Acquire a flawless image, determine a text area and a background area of ​​the flawless image, and determine a position of each character in the text area; Segmenting the text area according to the position of each character to obtain a first image of each character; removing the background of the first image of each character to obtain a second image of each character; Processing the second image of each character according to a preset first image processing method to obtain a third image of each character; Processing the second image of each character according to a preset second image processing method to obtain N fourth images and N fifth images of each character, wherein the N fourth images and the N fifth images of each character correspond one to one, and N is a positive integer greater than 1; calculating a similarity measure between each of the N fifth images of each character and the third image of each character to obtain N similarity measures corresponding to each character, and associating the N fifth images of each character with the N similarity measures corresponding to each character, and determining a defect threshold based on the N similarity measures corresponding to all characters in the character area; comparing each similarity metric among the N similarity metrics corresponding to each character with the defect threshold, wherein when any similarity metric corresponding to any character is greater than the defect threshold, determining that the fourth image corresponding to the fifth image associated with the any similarity metric is a defective image; When any fourth image is determined to be a defective image, intercepting a background image from the background area, wherein the size of the intercepted background image is equal to the size of the defective image; and The captured background image is subjected to brightness and shading processing, and the defective image and the background image subjected to the brightness and shading processing are synthesized to obtain a synthesized image.

2. The image processing method according to claim 1, wherein: The first image processing method includes image binarization and contour extraction; the second image processing method includes erasure processing, image binarization and contour extraction.

3. The image processing method according to claim 2, wherein: The method of removing the background from the first image of each character to obtain the second image of each character includes the following steps: Determining a first threshold of the first image using the Otsu algorithm, obtaining a mask of the first image based on the first threshold, and performing a bitwise AND operation on the mask and the first image to obtain a foreground text image of the first image; and Gaussian blur technology is used to soften the edges of the foreground text image to obtain the second image.

4. The image processing method according to claim 2, wherein: The method of removing the background of the first image of each character to obtain the second image of each character includes the following method: removing halftone dots from the first image using Fourier transform, and binarizing the first image after the halftone dots are removed; and Gaussian blur technology is used to soften the edges of the binarized first image to obtain the second image.

5. The image processing method according to claim 3, wherein: The first image processing method and the second image processing method perform image binarization according to the first threshold value, and use a Fourier descriptor algorithm or an invariant moment algorithm to perform contour extraction.

6. The image processing method according to claim 2, wherein: The step of processing the second image of each character according to a preset second image processing method to obtain N fourth images and N fifth images of each character, wherein the N fourth images of each character correspond to the N fifth images in one-to-one correspondence, includes: Randomly erasing the second image of each character N times to obtain N fourth images of each character; performing image binarization on the N fourth images of each character to obtain N black-and-white images; Contour extraction is performed on the N black-and-white images to obtain the N fifth images.

7. The image processing method according to claim 1, wherein: The similarity measure is the Euclidean distance between each fifth image of each character and the third image of each character; The step of determining a defect threshold according to N similarity metrics corresponding to all characters in the text area includes: Creating a line graph of the relationship between the similarity measure and the number of images according to the number of the fifth images corresponding to each value of the similarity measure; and The first local minimum value of the similarity measure in the broken line relationship graph is used as the defect threshold.

8. The image processing method according to claim 1, wherein: The performing brightness and darkness processing on the intercepted background image, synthesizing the defective image and the background image after the brightness and darkness processing, and obtaining the synthesized image comprises: The captured background image is subjected to multiple brightness adjustments to obtain multiple adjusted images, and the multiple adjusted images are synthesized with the defective image to obtain multiple synthesized images.

9. A computer-readable storage medium, characterized in that The computer-readable storage medium stores at least one instruction, and when the at least one instruction is executed by a processor, the image processing method according to any one of claims 1 to 8 is implemented.

10. A computer device, characterized in that: The computer device includes a memory and at least one processor, wherein the memory stores at least one instruction, and when the at least one instruction is executed by the at least one processor, the image processing method according to any one of claims 1 to 8 is implemented.

Citation Information

Patent Citations

  • Image processing device and image processing method

    CN106326895A

  • Defect detection method, electronic device and computer readable storage medium

    CN111915549A