CN115171090A - Method, device, equipment and medium for processing target field - Google Patents
Method, device, equipment and medium for processing target field Download PDFInfo
- Publication number
- CN115171090A CN115171090A CN202210845878.XA CN202210845878A CN115171090A CN 115171090 A CN115171090 A CN 115171090A CN 202210845878 A CN202210845878 A CN 202210845878A CN 115171090 A CN115171090 A CN 115171090A
- Authority
- CN
- China
- Prior art keywords
- area
- image
- target field
- irrelevant
- character
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V20/00—Scenes; Scene-specific elements
- G06V20/60—Type of objects
- G06V20/62—Text, e.g. of license plates, overlay texts or captions on TV images
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V30/00—Character recognition; Recognising digital ink; Document-oriented image-based pattern recognition
- G06V30/10—Character recognition
- G06V30/18—Extraction of features or characteristics of the image
- G06V30/18105—Extraction of features or characteristics of the image related to colour
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V30/00—Character recognition; Recognising digital ink; Document-oriented image-based pattern recognition
- G06V30/10—Character recognition
- G06V30/19—Recognition using electronic means
- G06V30/191—Design or setup of recognition systems or techniques; Extraction of features in feature space; Clustering techniques; Blind source separation
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Multimedia (AREA)
- Theoretical Computer Science (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Character Input (AREA)
Abstract
The application provides a method, a device, equipment and a medium for processing a target field, which comprise the following steps: determining a target field area image containing the target field, and converting the target field area image into a color space; determining the pixel value of the target field area image converted into the color space in at least one channel of the color space, comparing the pixel value of the at least one channel with the preset character area pixel range of the corresponding channel, and determining an irrelevant area beyond the character area pixel range; and filtering the irrelevant area from the target field area image so as to separate a field area from the target field area image. Therefore, through the separation of the character areas, the accuracy and the definition of character recognition can be improved.
Description
Technical Field
The present application relates to the field of image processing technologies, and in particular, to a method, an apparatus, a device, and a medium for processing a target field.
Background
Optical Character Recognition (OCR) refers to a process of analyzing, recognizing and processing an image of text data to obtain Character information in a target field. Common OCR recognition, including certificate OCR, report OCR, and the like, is mainly performed on flat paper or photos.
Since the recognized text information comes from paper or photos, if any other stripe interference occurs at the text position, such as table lines, reflection lines, certificate shading, steel marks, red marks and the like, the final judgment of the recognition model is significantly interfered. Therefore, how to process the target field so as to improve the recognition accuracy and definition of the text information is a technical problem to be considered.
Disclosure of Invention
In view of this, the present application provides a method, an apparatus, a device, and a medium for processing a target field, and mainly aims to improve accuracy and definition of text recognition by processing the target field.
According to an aspect of the present application, there is provided a method for processing a target field, in which a picture to be recognized is subjected to optical character recognition, the method including: determining a target field area image containing the target field, and converting the target field area image into a color space; determining the pixel value of the target field area image converted into the color space in at least one channel of the color space, comparing the pixel value of the at least one channel with the preset character area pixel range of the corresponding channel, and determining an irrelevant area exceeding the character area pixel range; and filtering the irrelevant region from the target field region image so as to separate a character region from the target field region image.
According to an aspect of the present application, there is provided an apparatus for processing a target field, where the target field is obtained by performing optical character recognition on a picture to be recognized, the apparatus including: a color space conversion unit for determining a target field area image containing the target field and converting the target field area image to a color space; an irrelevant area determining unit, configured to determine a pixel value of the target field area image converted into the color space in at least one channel of the color space, compare the pixel value of the at least one channel with a preset text area pixel range of a corresponding channel, and determine an irrelevant area exceeding the text area pixel range; and the filtering unit is used for filtering the irrelevant area from the target field area image so as to separate the character area from the target field area image.
According to an aspect of the present application, there is provided a computer device comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the computer program to perform the above method for processing a target field.
According to an aspect of the application, a storage medium is provided, in which a computer program is stored, wherein the computer program is arranged to execute the above method of processing a target field when running.
By means of the technical scheme, the method for processing the target field converts the regional image of the target field into the color space; and comparing the pixel value of the color space channel with the preset character area pixel range of the corresponding channel to determine an irrelevant area and filtering the irrelevant area, thereby separating the character area from the target character area image. Because the character area of the target field has color stability, the character area can be effectively separated in a mode of comparing a color space with the pixel range of the character area, so that the accuracy and definition of character information identification can be improved, for example, the character information can be automatically stripped from interference backgrounds such as table lines, reflection lines, certificate shading, steel marks, red marks and the like, and the final OCR identification effect can be improved.
The foregoing description is only an overview of the technical solutions of the present application, and the present application can be implemented according to the content of the description in order to make the technical means of the present application more clearly understood, and the following detailed description of the present application is given in order to make the above and other objects, features, and advantages of the present application more clearly understandable.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the application and together with the description serve to explain the application and not to limit the application. In the drawings:
fig. 1 is a schematic diagram illustrating an implementation scenario of a method for processing a target field according to an embodiment of the present application;
FIG. 2 is a flowchart of a method for processing a target field according to a first embodiment of the present application;
FIG. 3 is a flowchart of a method for processing a target field according to a second embodiment of the present application;
FIG. 4 is a flowchart of a method for processing a target field according to a third embodiment of the present application;
FIG. 5 is a flowchart of a method for processing a target field according to a fourth embodiment of the present application;
FIG. 6 is a schematic structural diagram illustrating an apparatus for processing a target field according to an embodiment of the present disclosure;
FIG. 7 is a schematic structural diagram of a computer device for processing a target field according to an embodiment of the present application;
fig. 8 shows a schematic structural diagram of another computer device for processing a target field according to an embodiment of the present application.
Detailed Description
In order to make the technical solutions better understood by those skilled in the art, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only partial embodiments of the present application, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application. It should be noted that the embodiments and features of the embodiments in the present application may be combined with each other without conflict.
Referring to fig. 1, a scene diagram is implemented for a method for processing a target field according to an embodiment of the present application. Fig. 1 illustrates an example of certificate OCR, first, OCR recognition is performed on a certificate photo to obtain each target field containing text information, and in the example of fig. 1, a target field 1 and a target field 2 are recognized, where the target field refers to a picture area mainly including text information. Then, the method for processing the target field provided by the embodiment of the application mainly processes the target field identified by the OCR, including separating a text region, weakening an irrelevant region image, enhancing a text region image, and the like, so as to improve accuracy and definition of text information identification.
Referring to fig. 2, a flowchart of a method for processing a target field according to a first embodiment of the present application is shown. The method is used for processing a target field obtained by OCR of a picture to be recognized, and comprises the following steps S201-S203.
S201: a target field area image containing a target field is determined, and the target field area image is converted to a color space.
After analysis, it is found that the specific target field has stable color characteristics, but the color characteristics are not three primary colors generally, so that the target character is considered to be distinguished from background interference based on other color space characteristics. For the identification scenes of the card type and the form type, the pixel characteristics of the target field are basically stable in the color space, so that the color characteristic range can be found out by using experience, and the target character area is stripped from the background. Color space, also called color model (also called color space or color system), is used to describe colors in a generally accepted way under certain criteria. There are many kinds of color spaces, and RGB (Red, green, blue, light-based RGB color space), CMY (Cyan, magenta, yellow, light-reflection-based RGB color space), HSV (Hue, saturation, value, hue-based color space), HSI (Hue, saturation, intensity-based color space), and the like are commonly used.
S202: and determining the pixel value of the target field area image converted into the color space in at least one channel of the color space, comparing the pixel value of at least one channel with the preset pixel range of the character area corresponding to the channel, and determining an irrelevant area beyond the pixel range of the character area.
The channels for different color space representations differ, but are often conveniently represented from a saturation channel, a color channel, a brightness (luminance) channel, and so forth. It has been found through research that for a document or form recognition scenario, the target field typically has a brightness that is distinct from the background, and thus, in one implementation, processing of the target field can be undertaken from a brightness channel.
For a picture to be recognized, when the picture is recognized through OCR, the image is preprocessed, and in the image preprocessing process, the image needs to be binarized, for example, for a picture to be recognized with a light background and a dark character, the image only contains black foreground information and white background information, so that the recognition processing efficiency and accuracy are improved. Therefore, in the image preprocessing step in the OCR recognition process, whether the picture to be recognized is a light-bottom dark character or a dark-bottom light character can be determined. For example, for light-bottom dark characters, the lightness of dark characters is stable, typically within a range less than some maximum threshold, whereas for light-bottom dark characters, the lightness of characters is stable at higher values, e.g., within a range greater than a minimum threshold. Thus, in one implementation, the color space is HSV space or RGB space, and the at least one channel is a lightness channel; the method therefore further comprises: setting the range of brightness channel pixels of the character area from 0 to the maximum threshold value as the pixel range of the character area for the target character area image of the light-background deep character; and setting a brightness channel pixel minimum threshold value larger than the character area as a character area pixel range for the target character area image of the dark-bottom light character.
S203: and filtering out irrelevant areas from the target field area image so as to separate the field area from the target field area image.
In one implementation, the pixel value of the irrelevant area may be set as the background color value of the target field area image.
For example, the RGB image is converted into a color space, such as HSV space, an empirical range is set for each dimension of the color space, and pixels that are out of the empirical range are used as extraneous pixels to be filtered and changed to a background color. For example, colors exceeding 0 to 150 are filtered for the lightness V channel, and the excess is converted into a white background.
The first embodiment is schematically described below as a specific example.
In short, in this example, the manner of determining the extraneous region is: determining a mask (mask) of the character area by setting a pixel range of the character area; and traversing the pixel value of at least one channel of the target field area image converted into the color space according to the mask, thereby determining an irrelevant area beyond the pixel range of the field area.
Specifically, this example is implemented as follows.
Step 1: converting RGB image into HSV color space
1.1, obtaining img image, reading image file by means of "cv2.Imread" tool, the channel order is BGR.
1.2, converting img in a BGR format into HSV _ img in an HSV format by using an image conversion tool (such as cv2. CvtColor).
Step 2: filtering pixels beyond the empirical range as irrelevant pixels
Among them, mask (mask) matting is often adopted: assuming that the image img is a 3-level matrix with a size of H × W × 3, the mask is a corresponding 2-level Boolean matrix with a size of H × W for expressing whether the pixel at the corresponding position is adopted (1 means adopted, and 0 means rejected).
The following effects can be achieved by the matrix index img _ masked [ mask ] = img [ mask ]:
go through
Namely mask i,j If =0, img _ masked i,j Remaining unchanged, it can be initialized to white:
take "driving license address field" as an example
2.1, through some means (manual circling, empirical trial, or color space statistical method), it is known that, in the HSV space, the lightness channel pixel values (V values) are mainly distributed between 0 and 160 in the text area of the "driver license address field", and the non-text area V values (irrelevant area V values) are mainly distributed between 140 and 255.
2.2, based on the boundaries of the two, take a balanced boundary value, such as the mean 150.
2.3 generating mask of character area Character(s)
2.4, initialization
rgb_img_masked=C White colour =[255,255,255]
Or
2.5, img of the original image, filtering by using mask:
rgb_img_masked[mask character(s) ]=img[mask Character(s) ]
Alternatively to hsv _ img, mask filtering was used:
hsv_img_masked[mask character(s) ]=hsv_img[mask Character(s) ]
rgb _ img _ masked or hsv _ img _ masked strips the field from the background.
It can be seen that a method for processing a target field provided in the first embodiment of the present application converts an image of a target field region into a color space; and comparing the pixel value of the color space channel with the preset character area pixel range of the corresponding channel to determine an irrelevant area and filtering the irrelevant area, thereby separating the character area from the target character area image. By adopting the scheme of the first embodiment of the application, as long as the text area has certain color distribution experience, a more reasonable color boundary determination mode can be determined, so that the effect of highlighting the text area from the target field is improved, for example, text information can be automatically stripped from interference backgrounds such as table lines, reflection lines, certificate shading, steel marks, red marks and the like, and the final OCR recognition effect can be improved.
Referring to fig. 3, a flowchart of a method for processing a target field according to a second embodiment of the present application is shown. In this second embodiment, compared to the first embodiment, after separating the text region by filtering out the irrelevant region from the target field region, the irrelevant region is further thinned out, thereby weakening the image in which the irrelevant region is displayed.
S301: a target field area image containing a target field is determined, and the target field area image is converted to a color space.
S302: and determining the pixel value of the target field area image converted into the color space in at least one channel of the color space, comparing the pixel value of at least one channel with the preset pixel range of the character area corresponding to the channel, and determining an irrelevant area beyond the pixel range of the character area.
S303: and filtering out irrelevant areas from the target field area image so as to separate the field area from the target field area image.
S304: and performing fading processing on the image of the irrelevant area, thereby weakening the image of the irrelevant area.
For details of the principles and processes of S301-S303, reference may be made to the first embodiment, which is not described herein again.
The following describes how to thin out the image of the extraneous region.
In one implementation, the image of the extraneous region can be faded as follows:
(1) Setting a character area mask corresponding to the character area, and performing reverse operation on the character area mask to obtain an irrelevant area mask;
(2) Performing desalination treatment on an irrelevant area corresponding to the irrelevant area mask by adopting mean filtering, median filtering, gaussian filtering or bilateral filtering operation to obtain a desalinated irrelevant area image;
(3) And merging the image of the character area and the image of the faded irrelevant area, thereby weakening and displaying the image of the irrelevant area.
The second embodiment will be explained below by way of a specific example.
In summary, the text area of the target field filtered by the first embodiment is made as mask _ target, and the reverse is made as mask _ other, which indicates an irrelevant area (area beyond the text boundary). For the mask _ other range, a weakened image (smooth filtering, thinning, etc.) is used, and then the mask _ target and the mask _ other weakened image are merged to obtain a new image.
1. As described in the example of the first embodiment, a text region mask, denoted as mask, is set Character(s) 。
2. Assuming that mask gets negated to-mask, mask + to mask = J, J is a full 1 matrix
img _ masked [ -mask ] = img [ -mask ] then represent
Define mask other =~mask target For the negation operation, the region outside the text, that is, the irrelevant region (or referred to as the background region) can be obtained through filtering.
3. Weakening the original img features in the RGB space to obtain the blu _ img, for example, mean filtering (cv2. Blu), median filtering (cv2. Median blur), gaussian filtering (cv2. Gaussian), bilateral filtering (cv2. Bilateral filter), and the like.
4. The RGB image is initialized.
rgb_img_masked=C White colour =[255,255,255]
5. And assigning the original image to the character area.
rgb_img_masked[mask target ]=img[mask target ]
6. The irrelevant areas are assigned a weakening map.
rgb_img_masked[mask other ]=blur_img[mask other ]
It can be seen that, in the method for processing the target field provided in the second embodiment of the present application, after the text region is separated by filtering the irrelevant region from the target field region, the irrelevant region is further thinned, so that the image of the irrelevant region is weakened to be displayed.
Referring to fig. 4, a flowchart of a method for processing a target field according to a third embodiment of the present application is shown. In this third embodiment, compared to the first embodiment, after separating the text region by filtering out irrelevant regions from the target text region, the text region is further subjected to enhancement processing, thereby highlighting the image of the text region.
S401: a target field area image containing a target field is determined, and the target field area image is converted to a color space.
S402: and determining the pixel value of the target field area image converted into the color space in at least one channel of the color space, comparing the pixel value of at least one channel with the preset pixel range of the character area corresponding to the channel, and determining an irrelevant area beyond the pixel range of the character area.
S403: and filtering out irrelevant areas from the target field area image so as to separate the field area from the target field area image.
S404: the image of the character area is subjected to enhancement processing, so that the image of the character area is highlighted.
The detailed principle and process of S401-S403 can refer to the first embodiment, which is not described herein.
Next, how to enhance the image of the character region will be described.
In one implementation, the image of the text region may be enhanced by:
(1) Setting a character area mask corresponding to the character area, and performing reverse operation on the character area mask to obtain an irrelevant area mask;
(2) Carrying out sharpening processing or deepening processing on a character area corresponding to the character area mask to obtain an enhanced character area image;
(3) And combining the image of the strengthened character region with the image of the irrelevant region to highlight the image of the character region.
The third embodiment is explained below by a specific example.
In summary, the text area of the target field filtered by the first embodiment is made as mask _ target, and the reverse is made as mask _ other, which indicates an irrelevant area (an area beyond the text boundary). The image in the mask _ target range is enhanced (by sharpening, deepening, or the like), and then the enhanced image in the mask _ target region is merged with the mask _ other image.
1. As described in the example of the first embodiment, a text region mask, denoted as mask, is set Character(s) 。
2. Assuming that mask gets negated to-mask, mask + to mask = J, J is a full 1 matrix
img _ masked [ -mask ] = img [ -mask ] then represent
Define mask other =~mask target For the reverse operation, the region outside the text, i.e. the irrelevant region (or called background region), can be filtered.
3. Enhancing original img features in an RGB space to obtain a reinformed _ img, for example, color shading is performed by opening three channel colors, or edge information is obtained and then superimposed on an image to realize image sharpening (edge detection methods such as Sobel operators, laplacian operators, scharr operators, canny operators, and the like, all have corresponding cv2 functions).
4. Initializing RGB map
rgb_img_masked=C White colour =[255,255,255]
5. Character region assignment enhancement map
rgb_img_masked[mask target ]=reinforced_img[mask target ]
6. Independent area assignment artwork
rgb_img_masked[mask other ]=img[mask other ]
It can be seen that, in the method for processing the target field provided in the third embodiment of the present application, after the text region is separated by filtering the irrelevant region from the target field region, the text region is further enhanced, so that the text region is highlighted, and the definition of text information recognition is finally improved.
Referring to fig. 5, a flowchart of a method for processing a target field according to a fourth embodiment of the present application is shown. In the fourth embodiment, after the text region is separated by filtering the irrelevant region from the target field region, the irrelevant region is further thinned and the text region is emphasized, so that the image of the irrelevant region is displayed weakly and the image of the text region is displayed prominently, as compared with the first embodiment.
S501: a target field area image containing a target field is determined, and the target field area image is converted to a color space.
S502: and determining the pixel value of the target field area image converted into the color space in at least one channel of the color space, comparing the pixel value of at least one channel with the preset pixel range of the character area corresponding to the channel, and determining an irrelevant area beyond the pixel range of the character area.
S503: and filtering out irrelevant areas from the target field area image so as to separate the field area from the target field area image.
S504: and performing fading processing on the image of the irrelevant area and performing strengthening processing on the image of the character area, so as to weaken the image of the irrelevant area and highlight the image of the character area.
The detailed principle and process of S501-S503 can refer to the first embodiment, which is not described herein.
Next, how to weaken the image of the irrelevant area and strengthen the image of the character area will be described.
In one implementation, the image of the irrelevant area and the image of the strengthened text area can be weakened by:
(1) Setting a character area mask corresponding to the character area, and performing reverse operation on the character area mask to obtain an irrelevant area mask;
(2) Performing desalination treatment on an irrelevant area corresponding to the irrelevant area mask by adopting mean filtering, median filtering, gaussian filtering or bilateral filtering operation to obtain a desalinated irrelevant area image, and performing sharpening treatment or deepening treatment on a character area corresponding to the character area mask to obtain a reinforced character area image;
(3) And merging the faded irrelevant area image and the strengthened text area image, thereby weakening the image of the irrelevant area and highlighting the image of the text area.
The fourth embodiment is explained below by a specific example.
In summary, the text area of the target field filtered by the first embodiment is made as mask _ target, and the reverse is made as mask _ other, which indicates an irrelevant area (an area beyond the text boundary). The image in the mask _ target range is enhanced (sharpened, deepened, or the like) using the weakened image (smooth filtering, thinning, or the like) for the mask _ other range, and then the enhanced image in the mask _ target region is merged with the weakened image in the mask _ other region.
1. As described in the example of the first embodiment, a text region mask, denoted as mask, is set Character(s) 。
2. Assuming that the mask negation is-mask, mask +, -mask = J, J is the all-1 matrix
img _ masked [ -mask ] = img [ -mask ] then represent
Define mask other =~mask target For the reverse operation, the region outside the text, i.e. the irrelevant region (or called background region), can be filtered.
3. Weakening the original image img characteristics in the RGB space to obtain blu _ img, for example, performing operations such as mean filtering (cv2. Blu), median filtering (cv2. Median blur), gaussian filtering (cv2. Gaussian), bilateral filtering (cv2. Bilateral filter), and the like; and enhancing the original img features in the RGB space to obtain a re-emphasized _ img, for example, opening three channel colors to darken the colors, or obtaining edge information and then superimposing the edge information on the image to realize image sharpening (edge detection methods such as Sobel operator, laplacian operator, scharr operator, canny operator, etc. all have corresponding cv2 functions).
4. Initializing RGB maps
rgb_img_masked=C White colour =[255,255,255]
5. Character region assignment enhancement map
rgb_img_masked[mask target ]=reinforced_img[mask target ]
6. Inquiry area assignment weakening map
rgb_img_masked[mask other ]=blur_img[mask other ]
It can be seen that, in the method for processing the target field provided in the fourth embodiment of the present application, after the text region is separated by filtering the irrelevant region from the target field region, the irrelevant region is further faded, and the text region is enhanced, so that the irrelevant region is weakened and the text region is highlighted, and the accuracy and the definition of text information recognition can be improved to the greatest extent.
Referring to fig. 6, for the apparatus for processing a target field provided in the embodiment of the present application, a target field obtained by performing optical character recognition on a picture to be recognized is processed, the apparatus includes:
a color space conversion unit 601 configured to determine a target field area image including the target field, and convert the target field area image into a color space;
an irrelevant area determining unit 602, configured to determine a pixel value of the target field area image converted into the color space in at least one channel of the color space, compare the pixel value of the at least one channel with a preset text area pixel range of a corresponding channel, and determine an irrelevant area beyond the text area pixel range;
a filtering unit 603, configured to filter the irrelevant area from the target field area image, so as to separate a field area from the target field area image.
In one implementation, the irrelevant area determining unit 602 is specifically configured to: determining a mask of a character area by setting a pixel range of the character area; and traversing the pixel value of at least one channel of the target field area image converted into the color space according to the mask, thereby determining an irrelevant area beyond the pixel range of the character area.
In one implementation, the color space is an HSV space or an RGB space, and the at least one channel is a lightness channel; setting the range of brightness channel pixels of a character area from 0 to a maximum threshold value as the pixel range of the character area for the target field area image of the light-bottom deep character; and setting a brightness channel pixel minimum threshold value larger than a character area as the character area pixel range for the target field area image of the light-dark character.
In one implementation, the filtering unit 603 is specifically configured to: and setting the pixel value of the irrelevant area as the background color value of the target field area image.
In one implementation, the method further comprises:
a fading unit 604, configured to perform fading processing on the image of the unrelated area, so as to weaken the image of the unrelated area for display.
In one implementation, the desalination unit 604 is specifically configured to: setting a character area mask corresponding to the character area, and performing reverse operation on the character area mask to obtain an irrelevant area mask; performing desalination treatment on an irrelevant area corresponding to the irrelevant area mask by adopting mean filtering, median filtering, gaussian filtering or bilateral filtering operation to obtain a desalinated irrelevant area image; and merging the image of the text area and the faded image of the irrelevant area, thereby weakening and displaying the image of the irrelevant area.
In one implementation, the method further comprises: the enhancing unit 605 is configured to perform enhancement processing on the text region, so as to highlight the image of the text region.
In one implementation, the strengthening unit 605 is specifically configured to: setting a character area mask corresponding to the character area, and performing reverse operation on the character area mask to obtain an irrelevant area mask; carrying out sharpening processing or deepening processing on the character area corresponding to the character area mask to obtain an enhanced character area image; and merging the enhanced character area image and the image of the irrelevant area, thereby highlighting the image of the character area.
In one implementation, the device further includes a fading and enhancing unit 606, configured to fade the irrelevant area and enhance the text area, so as to weaken the image of the irrelevant area and highlight the image of the text area.
In one implementation, the fade emphasis unit 606 is specifically configured to: setting a character area mask corresponding to the character area, and performing reverse operation on the character area mask to obtain an irrelevant area mask; performing desalination treatment on an irrelevant area corresponding to the irrelevant area mask by adopting mean filtering, median filtering, gaussian filtering or bilateral filtering operation to obtain a desalinated irrelevant area image, and performing sharpening treatment or deepening treatment on a character area corresponding to the character area mask to obtain a reinforced character area image; and merging the faded irrelevant area image and the strengthened character area image, so as to weaken the image of the irrelevant area and highlight the image of the character area.
For specific limitations of the device for processing the target field, reference may be made to the above limitations of the method for processing the target field, which are not described herein again. The respective modules in the above-described apparatus for processing the target field may be wholly or partially implemented by software, hardware, and a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as shown in fig. 7. The computer device includes a processor, a memory, a network interface, and a database connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes non-volatile and/or volatile storage media, internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The network interface of the computer device is used for communicating with an external client through a network connection. The computer program is executed by a processor to implement the functions or steps of a service side of a method of processing a target field.
In one embodiment, a computer device is provided, which may be a client, and its internal structure diagram may be as shown in fig. 8. The computer device includes a processor, a memory, a network interface, a display screen, and an input device connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The network interface of the computer device is used for communicating with an external server through a network connection. The computer program is executed by a processor to implement functions or steps of a method client side of processing a target field
In one embodiment, a computer device is provided, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor implementing the following steps when executing the computer program:
determining a target field area image containing the target field, and converting the target field area image into a color space;
determining the pixel value of the target field area image converted into the color space in at least one channel of the color space, comparing the pixel value of the at least one channel with the preset character area pixel range of the corresponding channel, and determining an irrelevant area beyond the character area pixel range;
and filtering the irrelevant region from the target field region image so as to separate a character region from the target field region image.
In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored which, when executed by a processor, performs the steps of:
determining a target field area image containing the target field, and converting the target field area image into a color space;
determining the pixel value of the target field area image converted into the color space in at least one channel of the color space, comparing the pixel value of the at least one channel with the preset character area pixel range of the corresponding channel, and determining an irrelevant area exceeding the character area pixel range;
and filtering the irrelevant area from the target field area image so as to separate a field area from the target field area image.
It should be noted that, the functions or steps that can be implemented by the computer-readable storage medium or the computer device can be referred to the related descriptions of the server side and the client side in the foregoing method embodiments, and are not described here one by one to avoid repetition.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory, among others. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically Programmable ROM (EPROM), electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double Data Rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous Link DRAM (SLDRAM), rambus (Rambus) direct RAM (RDRAM), direct Rambus Dynamic RAM (DRDRAM), and Rambus Dynamic RAM (RDRAM), among others.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-mentioned functions.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not depart from the spirit and scope of the embodiments of the present invention, and they should be construed as being included therein.
Claims (10)
1. A method for processing a target field is characterized in that the target field obtained by optical character recognition of a picture to be recognized is processed, and the method comprises the following steps:
determining a target field area image containing the target field, and converting the target field area image into a color space;
determining the pixel value of the target field area image converted into the color space in at least one channel of the color space, comparing the pixel value of the at least one channel with the preset character area pixel range of the corresponding channel, and determining an irrelevant area beyond the character area pixel range;
and filtering the irrelevant area from the target field area image so as to separate a field area from the target field area image.
2. The method of claim 1, wherein comparing the pixel value of the at least one channel with a predetermined text region pixel range of a corresponding channel to determine an irrelevant region beyond the text region pixel range comprises:
determining a mask of a character area by setting a pixel range of the character area;
and traversing the pixel value of at least one channel of the target field area image converted into the color space according to the mask so as to determine an irrelevant area beyond the pixel range of the character area.
3. The method of claim 1, wherein the color space is an HSV space or an RGB space, and the at least one channel is a lightness channel;
the method further comprises the following steps:
setting the range of brightness channel pixels of a character area from 0 to a maximum threshold value as the pixel range of the character area for the target character area image of the light-background deep character;
and setting a brightness channel pixel minimum threshold value larger than a character area as the character area pixel range for the target field area image of the light-dark character.
4. The method of claim 3, wherein the filtering the extraneous region from the target field region image comprises:
and setting the pixel value of the irrelevant area as the background color value of the image of the target field area.
5. The method according to any one of claims 1-4, wherein after said filtering out said extraneous region from said target field region image to separate a field region from said target field region image, further comprising: performing fading processing on the image of the irrelevant area to weaken and display the image of the irrelevant area;
the step of performing fading processing on the image of the irrelevant area to weaken the display of the image of the irrelevant area comprises the following steps: setting a character area mask corresponding to the character area, and performing a reverse operation on the character area mask to obtain an irrelevant area mask; performing desalination treatment on an irrelevant area corresponding to the irrelevant area mask by adopting mean filtering, median filtering, gaussian filtering or bilateral filtering operation to obtain a desalinated irrelevant area image; and merging the image of the character area and the faded image of the irrelevant area, thereby weakening and displaying the image of the irrelevant area.
6. The method according to any one of claims 1-4, further comprising, after said filtering out said extraneous region from said target field region image to separate a region of text from said target field region image: performing enhancement processing on the character area so as to highlight the image of the character area;
the strengthening processing on the character area so as to highlight the image of the character area comprises the following steps: setting a character area mask corresponding to the character area, and performing reverse operation on the character area mask to obtain an irrelevant area mask; carrying out sharpening processing or deepening processing on the character area corresponding to the character area mask to obtain an enhanced character area image; and merging the enhanced character area image and the image of the irrelevant area, thereby highlighting the image of the character area.
7. The method according to any one of claims 1-4, wherein after the fading the image of the extraneous region to weaken the display of the image of the extraneous region, further comprising: performing fading processing on the irrelevant area and performing strengthening processing on the character area, so as to weaken the image of the irrelevant area and highlight the image of the character area;
the fading the irrelevant area and the strengthening the text area to weaken the image displaying the irrelevant area and highlight the image displaying the text area comprises: setting a character area mask corresponding to the character area, and performing reverse operation on the character area mask to obtain an irrelevant area mask; performing desalination treatment on an irrelevant area corresponding to the irrelevant area mask by adopting mean filtering, median filtering, gaussian filtering or bilateral filtering operation to obtain a desalinated irrelevant area image, and performing sharpening treatment or deepening treatment on a character area corresponding to the character area mask to obtain a reinforced character area image; and merging the faded irrelevant area image and the strengthened character area image, so as to weaken the image of the irrelevant area and highlight the image of the character area.
8. An apparatus for processing a target field, wherein the target field obtained by optical character recognition of a picture to be recognized is processed, the apparatus comprising:
a color space conversion unit for determining a target field area image containing the target field and converting the target field area image to a color space;
an irrelevant area determining unit, configured to determine a pixel value of the target field area image converted into the color space in at least one channel of the color space, compare the pixel value of the at least one channel with a preset text area pixel range of a corresponding channel, and determine an irrelevant area exceeding the text area pixel range;
and the filtering unit is used for filtering the irrelevant area from the target field area image so as to separate the field area from the target field area image.
9. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the steps of the method of processing a target field according to any one of claims 1 to 7.
10. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the steps of the method of processing a target field according to any one of claims 1 to 7 when executing the computer program.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202210845878.XA CN115171090A (en) | 2022-07-19 | 2022-07-19 | Method, device, equipment and medium for processing target field |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202210845878.XA CN115171090A (en) | 2022-07-19 | 2022-07-19 | Method, device, equipment and medium for processing target field |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| CN115171090A true CN115171090A (en) | 2022-10-11 |
Family
ID=83495356
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202210845878.XA Pending CN115171090A (en) | 2022-07-19 | 2022-07-19 | Method, device, equipment and medium for processing target field |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN115171090A (en) |
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN116740724A (en) * | 2023-05-24 | 2023-09-12 | 众安在线财产保险股份有限公司 | Methods, devices, electronic equipment and media for removing seepage content in text images |
-
2022
- 2022-07-19 CN CN202210845878.XA patent/CN115171090A/en active Pending
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN116740724A (en) * | 2023-05-24 | 2023-09-12 | 众安在线财产保险股份有限公司 | Methods, devices, electronic equipment and media for removing seepage content in text images |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN110008954B (en) | A method and system for extracting complex background text images based on multi-threshold fusion | |
| CN104899586B (en) | Method and device is identified to the word content for including in image | |
| CN109636825A (en) | Seal graphics dividing method, device and computer readable storage medium | |
| JP5455038B2 (en) | Image processing apparatus, image processing method, and program | |
| US8103104B2 (en) | Text extraction and its application to compound document image compression | |
| US10922801B2 (en) | Channel-based binarization of color | |
| CN111415363A (en) | Image edge identification method | |
| EP2645332B1 (en) | Image processing device that separates image into plural regions | |
| EP2545499A2 (en) | Text enhancement of a textual image undergoing optical character recognition | |
| US9088754B2 (en) | Image processing device determining characteristic quantity relating to number of colors | |
| CN107659799B (en) | Image pickup apparatus, image processing method, and storage medium | |
| CN110298812B (en) | Image fusion processing method and device | |
| EP3143549B1 (en) | Segmentation based image transform | |
| US8285036B2 (en) | Image processing method, image processing apparatus, and computer-readable storage medium for computer program | |
| CN104156703A (en) | License plate location method and system based on color texture | |
| CN115171090A (en) | Method, device, equipment and medium for processing target field | |
| Huang et al. | Detecting shadows in high-resolution remote-sensing images of urban areas using spectral and spatial features | |
| US20150055858A1 (en) | Systems and methods for color recognition in computer vision systems | |
| JP2010074342A (en) | Image processing apparatus, image forming apparatus, and program | |
| Tarafdar et al. | Image segmentation using background subtraction on colored images | |
| JP2019046225A (en) | Recognition device, recognition program, and recognition method | |
| CN112836587B (en) | Runway identification method, device, computer equipment and storage medium | |
| US20100238470A1 (en) | Document image processing system and document image processing method | |
| Park et al. | Simple shadow removal using shadow depth map and illumination-invariant feature | |
| Tribuzy et al. | Vehicle License Plate Preprocessing Techniques Using Graphical Interface |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination |