A text extraction method, device and electronic equipment

By performing erosion, dilation, and skeleton extraction processes in image processing, cursive characters can be extracted automatically, solving the problem of high manpower and time consumption in existing technologies and improving text extraction efficiency.

CN116912815BActive Publication Date: 2026-02-24BEIJING IQIYI TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202310851061.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-07-12
Publication Date
2026-02-24
Estimated Expiration
2043-07-12

AI Technical Summary

Technical Problem

Existing technologies for extracting cursive characters from image processing software require a significant amount of manpower and time, and also demand a high level of expertise from the staff.

Method used

By detecting the text to be extracted in the image, performing erosion and dilation processing, and combining the results with skeleton extraction, the extraction basis is obtained, and the text is extracted automatically.

Benefits of technology

It reduces the time spent manually extracting text and improves text extraction efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116912815B_ABST
    Figure CN116912815B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a text extraction method and device and electronic equipment, and relate to the technical field of image processing. The method comprises: detecting a text to be extracted in a to-be-detected image to obtain a detection result; performing erosion processing on the detection result to obtain an erosion result about the text to be extracted, and performing inflation processing on the detection result to obtain an inflation result about the text to be extracted; extracting font lines and line gap background areas of the text to be extracted through skeleton extraction processing on the detection result; merging the erosion result, the inflation result, the font lines and the line gap background areas to obtain extraction basis about the text to be extracted; and extracting the text to be extracted in the to-be-detected image based on the extraction basis. Compared with the prior art, the scheme provided in the embodiments of the present application can improve the text extraction efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image processing technology, and in particular to a text extraction method, apparatus, and electronic device. Background Technology

[0002] When creating derivative works from images, the text content that is desired to be retained is extracted and reused. For example, when creating derivative works from posters, it is necessary to extract the cursive text from the original poster and paste it onto the derivative image.

[0003] Typically, staff use image processing software to extract cursive text from the original poster. For example, Photoshop (Adobe Photoshop, an image processing software developed and published by Adobe Systems). However, processing original posters using image processing software requires a high level of expertise from the staff, and extracting cursive text from the original poster consumes a significant amount of manpower and time. Summary of the Invention

[0004] The purpose of this application is to provide a text extraction method, apparatus, and electronic device to improve text extraction efficiency. The specific technical solution is as follows:

[0005] In a first aspect of this application, a text extraction method is provided, the method comprising:

[0006] The text to be extracted is detected in the image to be detected, and the detection result is obtained;

[0007] The detection results are subjected to erosion processing to obtain erosion results of the text to be extracted, and the detection results are subjected to dilation processing to obtain dilation results of the text to be extracted.

[0008] By extracting the skeleton from the detection results, the font texture and background area of ​​the texture gaps in the text to be extracted are extracted.

[0009] By merging the corrosion results, the dilation results, the font texture, and the background area between the texture gaps, the extraction criteria for the text to be extracted are obtained.

[0010] Based on the extraction criteria, the text to be extracted is extracted from the image to be detected.

[0011] Optionally, in one specific implementation, the step of extracting the font texture and texture gap background area of ​​the text to be extracted by skeleton extraction processing of the detection result includes:

[0012] The detection results are subjected to skeleton extraction processing to obtain the font texture of the text to be extracted;

[0013] Extract the edge contour of the detection result to obtain the contour region of the detection result, and determine the region outside the detection result in the contour region as the internal background region to be extracted;

[0014] The skeleton extraction process is performed on the internal background region to be extracted to obtain the texture gap background region of the text to be extracted.

[0015] Optionally, in one specific implementation, the extraction is based on a Trimap graph.

[0016] In a second aspect of this application, a text extraction apparatus is also provided, the apparatus comprising:

[0017] The acquisition module is used to detect the text to be extracted in the image to be detected and obtain the detection results;

[0018] The processing module is used to perform erosion processing on the detection results to obtain erosion results about the text to be extracted, and to perform dilation processing on the detection results to obtain dilation results about the text to be extracted;

[0019] The skeleton extraction module is used to extract the font texture and texture gap background area of ​​the text to be extracted by processing the skeleton of the detection result.

[0020] The merging module is used to merge the erosion results, the dilation results, the font texture, and the background area of ​​the texture gaps to obtain the extraction basis for the text to be extracted;

[0021] An extraction module is used to extract the text to be extracted from the image to be detected based on the extraction criteria.

[0022] Optionally, in one specific implementation, the skeleton extraction module is specifically used for:

[0023] The detection results are subjected to skeleton extraction processing to obtain the font texture of the text to be extracted;

[0024] Extract the edge contour of the detection result to obtain the contour region of the detection result, and determine the region outside the detection result in the contour region as the internal background region to be extracted;

[0025] The skeleton extraction process is performed on the internal background region to be extracted to obtain the texture gap background region of the text to be extracted.

[0026] Optionally, in one specific implementation, the extraction is based on a Trimap graph.

[0027] In a third aspect provided in the embodiments of this application, an electronic device is also provided, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; the memory is used to store computer programs; and the processor is used to implement any of the text extraction methods provided in the first aspect when executing the programs stored in the memory.

[0028] In another aspect of the embodiments of this application, a computer-readable storage medium is also provided, wherein a computer program is stored therein, and when the computer program is executed by a processor, it implements any of the text extraction methods provided in the first aspect above.

[0029] In another aspect of the embodiments of this application, a computer program product containing instructions is also provided, which, when run on a computer, causes the computer to perform any of the text extraction methods provided in the first aspect above.

[0030] Applying the scheme provided in this application, firstly, by detecting the text to be extracted in the image to be detected, a detection result can be obtained. Secondly, the obtained detection result is subjected to erosion processing to obtain an erosion result of the text to be extracted, and the obtained detection result is subjected to dilation processing to obtain a dilation result of the text to be extracted. Then, by performing skeleton extraction processing on the above detection result, the font texture and texture gap background area of ​​the text to be extracted are extracted. Thus, the obtained erosion result, dilation result, font texture and texture gap background area are merged to obtain the extraction basis of the text to be extracted. In this way, the text to be extracted can be extracted from the image to be detected based on the obtained extraction basis.

[0031] Based on this, by merging the obtained erosion results, dilation results, font textures, and texture gap background areas of the text to be extracted, the extraction basis for the aforementioned text to be extracted can be obtained. Thus, the extraction basis can be used to extract the text to be extracted from the image to be detected. This automated extraction method reduces the text extraction time spent on manual extraction by staff, thereby improving text extraction efficiency. Attached Figure Description

[0032] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below.

[0033] Figure 1(a) is a schematic diagram of an initial image provided in an embodiment of this application;

[0034] Figure 1(b) is a schematic diagram of the detection results obtained after detecting Figure 1(a);

[0035] Figure 1(c) is a schematic diagram of the corrosion result obtained after etching the above-mentioned Figure 1(b);

[0036] Figure 1(d) is a schematic diagram of the expansion result obtained after performing expansion processing on Figure 1(b);

[0037] Figure 1(e) is a schematic diagram of the result obtained after skeleton extraction processing of Figure 1(b).

[0038] Figure 2 A flowchart illustrating a text extraction method provided in an embodiment of this application;

[0039] Figure 3 A flowchart illustrating another text extraction method provided in an embodiment of this application;

[0040] Figure 4 This is a schematic diagram of the result of a text extraction device provided in an embodiment of this application;

[0041] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0042] The technical solutions in the embodiments of this application will now be described with reference to the accompanying drawings.

[0043] When reworking images, the desired text content is extracted and reused. Typically, image processing software is used to extract the cursive text from the original poster. However, processing original posters with image processing software requires a high level of expertise from the staff, and extracting the cursive text from the original poster consumes a significant amount of manpower and time.

[0044] To address the aforementioned technical problems, this application provides a text extraction method.

[0045] This method is applicable to various scenarios involving text extraction from images. For example, it can extract text from cursive fonts in posters or from text in cover images. Furthermore, this method can be applied to various electronic devices such as laptops, tablets, and desktop computers (hereinafter referred to as electronic devices). Therefore, this application does not limit the application scenarios or the executing entity of this method.

[0046] This application provides a text extraction method that may include the following steps:

[0047] The text to be extracted is detected in the image to be detected, and the detection result is obtained;

[0048] The detection results are subjected to erosion processing to obtain erosion results of the text to be extracted, and the detection results are subjected to dilation processing to obtain dilation results of the text to be extracted.

[0049] By extracting the skeleton from the detection results, the font texture and background area of ​​the texture gaps in the text to be extracted are extracted.

[0050] By merging the corrosion results, the dilation results, the font texture, and the background area between the texture gaps, the extraction criteria for the text to be extracted are obtained.

[0051] Based on the extraction criteria, the text to be extracted is extracted from the image to be detected.

[0052] As can be seen from the above, by applying the solution provided in this application embodiment, firstly, by detecting the text to be extracted in the image to be detected, a detection result can be obtained. Secondly, the obtained detection result is subjected to erosion processing to obtain an erosion result of the text to be extracted, and the obtained detection result is subjected to dilation processing to obtain a dilation result of the text to be extracted. Then, by performing skeleton extraction processing on the above detection result, the font texture and texture gap background area of ​​the text to be extracted are extracted. Thus, the obtained erosion result, dilation result, font texture and texture gap background area are merged to obtain the extraction basis of the text to be extracted. In this way, the text to be extracted can be extracted from the image to be detected based on the obtained extraction basis.

[0053] Based on this, by merging the obtained erosion results, dilation results, font textures, and texture gap background areas of the text to be extracted, the extraction basis for the aforementioned text to be extracted can be obtained. Thus, the extraction basis can be used to extract the text to be extracted from the image to be detected. This automated extraction method reduces the text extraction time spent on manual extraction by staff, thereby improving text extraction efficiency.

[0054] To facilitate understanding of the text extraction method provided in this application embodiment, the relevant terms in this application embodiment will be explained in detail below.

[0055] 1. Erosion processing refers to using an erosion algorithm to remove the edges of an image, thereby obtaining the foreground region of the image. The aforementioned erosion algorithm can be the erode (erosion operation) function of OpenCV (an open-source computer vision and machine learning software library). This application does not specifically limit this aspect.

[0056] For example, if the object to be eroded is text, the obtained erosion result is the text foreground area of the text.

[0057] Exemplarily, FIG. 1(a) is a schematic diagram of an initial image provided by an embodiment of the present application. FIG. 1(b) is a schematic diagram of a detection result obtained after detecting FIG. 1(a). FIG. 1(c) is a schematic diagram of an erosion result obtained after performing erosion processing on FIG. 1(b) above.

[0058] 2. Dilation processing refers to expanding the edges of an image using a dilation algorithm, thereby obtaining the background area of the image. Among them, the above dilation algorithm can be the dilate (dilation operation) function of OpenCV. The embodiments of the present application do not make specific limitations on this.

[0059] For example, if the object to be dilated is text, the obtained dilation result is the text background area of the text.

[0060] Exemplarily, FIG. 1(d) is a schematic diagram of a dilation result obtained after performing dilation processing on FIG. 1(b) above.

[0061] 3. Skeleton extraction processing refers to performing image thinning processing on an original shape using a set of curve sets that are consistent with the connectivity and topological structure distribution of the original shape. Among them, the above skeleton extraction processing can be the skeletonize (skeletonization) function of OpenCV. The embodiments of the present application do not make specific limitations on this.

[0062] Exemplarily, FIG. 1(e) is a schematic diagram of the result obtained after performing skeleton extraction processing on FIG. 1(b) above. As shown in FIG. 1(e), if the extracted object is the text "Wushan", the processing result obtained after skeleton extraction processing is the font texture of the text "Wushan", that is, the stroke structure of "Wushan".

[0063] Next, a text extraction method provided by an embodiment of the present application will be specifically described with reference to the accompanying drawings.

[0064] Figure 2 is a schematic flowchart of a text extraction method provided by an embodiment of the present application. As Figure 2 shown, a text extraction method provided by an embodiment of the present application may include the following steps S201-S205:

[0065] S201: Detect the text to be extracted in the image to be detected and obtain a detection result.

[0066] When extracting text from an image, the process begins by acquiring the image to be extracted, then detecting the text to be extracted in that image, and finally obtaining the detection results for the extracted text.

[0067] For example, taking Figure 1(a) and Figure 1(b) as examples, the initial image shown in Figure 1(a) is used as the image to be detected. By detecting the image to be detected, the detection result shown in Figure 1(b) is obtained.

[0068] Optionally, a preset text detection algorithm can be used to detect the text to be extracted in the image to be detected, and the detection result can be obtained.

[0069] For example, the cursive text in the poster is created by pasting a PNG (Portable Network Graphic) image with an alpha channel onto the original poster image during the poster production process. However, in the actual secondary creation process, the PNG image used in the initial poster production cannot be directly extracted from the original poster image. Therefore, a cursive text detection algorithm is needed to detect the cursive text in the original poster image to obtain a mask of the cursive text, which is the detection result in this embodiment.

[0070] S202: Perform erosion processing on the detection results to obtain the erosion result of the text to be extracted, and perform dilation processing on the detection results to obtain the dilation result of the text to be extracted.

[0071] After obtaining the above detection results, the erosion algorithm can be used to erode the detection results, thereby obtaining the erosion results of the above text to be extracted.

[0072] For example, taking Figure 1(b) and Figure 1(c) as examples, after performing corrosion treatment on the detection results shown in Figure 1(b), the corrosion results shown in Figure 1(c) are obtained.

[0073] During the aforementioned erosion process, the erosion algorithm erodes away the edge information of the "fog hill." The remaining image information after erosion is the text foreground region of the "fog hill," which is the erosion result in this embodiment. In other words, the obtained erosion result is the text foreground region of the text to be extracted.

[0074] Furthermore, after obtaining the above detection results, the dilation algorithm can be used to dilate the detection results, thereby obtaining the dilated results for the above-mentioned text to be extracted.

[0075] For example, taking Figure 1(b) and Figure 1(d) as examples, after performing dilation processing on the detection result shown in Figure 1(b), the dilation result shown in Figure 1(d) is obtained.

[0076] In the aforementioned dilation process, the dilation algorithm expands the edge information of the "fog hill," thereby expanding the "fog hill" into a whole. The remaining image information after dilation constitutes the text background area of ​​the "fog hill," which is the dilation result in this embodiment. In other words, the obtained dilation result is the text background area of ​​the text to be extracted.

[0077] In some cases, because the font corresponding to the text to be extracted may contain very fine strokes, these fine strokes may be eroded away during the erosion process of the above detection results, resulting in an erosion result without any trace of the fine strokes. Furthermore, during the dilation process of the above detection results, the entire text to be extracted will expand into a single unit. Therefore, when the font corresponding to the text to be extracted contains complex strokes, the background area within the font will blend into the text to be extracted, failing to provide a clear dilation result.

[0078] Therefore, in order to provide a more accurate basis for the subsequent text extraction process of electronic devices, the detection results can be processed again.

[0079] S203: By processing the skeleton of the detection results, extract the font texture and background area of ​​the text to be extracted.

[0080] In order to improve the image quality of the text extracted by the electronic device, after obtaining the detection results of the text to be extracted, skeleton extraction processing can be performed on the detection results to extract the font texture and background area of ​​the text to be extracted.

[0081] The font texture of the text to be extracted refers to the stroke structure of the text, that is, the foreground area inside the text.

[0082] For example, as shown in Figure 1(e), the texture formed by each white thin line 102 in Figure 1(e) is the font texture of the text to be extracted in this embodiment of the application.

[0083] The text gap background area mentioned above refers to the image area corresponding to the gap area between the stroke structures in the text to be extracted, which is the background area inside the text.

[0084] For example, as shown in Figure 1(e), each black line 103 in Figure 1(e) is the texture of the text gap background area to be extracted in this embodiment of the application.

[0085] In this way, the font texture and background area between the textures of the text to be extracted can provide detailed image information about the internal structure of the text in the subsequent text extraction process of the electronic device.

[0086] S204: Merge the erosion results, dilation results, font texture, and texture gap background area to obtain the extraction basis for the text to be extracted;

[0087] S205: Based on the extraction criteria, extract the text to be extracted from the image to be detected.

[0088] After obtaining the erosion results, dilation results, font textures, and texture gap background areas of the text to be extracted, these results can be merged to obtain a refined extraction basis for the text to be extracted.

[0089] In this way, the electronic device can use the erosion and dilation results from the extraction criteria to determine the foreground and background regions of the text to be extracted. Furthermore, using the font texture and texture gap background regions from the extraction criteria, it can determine the image regions corresponding to the stroke structures within the characters and the gap regions between those stroke structures.

[0090] In other words, by defining the foreground and background regions of the text, the approximate text range occupied by the text to be extracted is determined. Similarly, by defining the foreground region of the text represented by the font texture and the background region of the text represented by the gaps in the texture, the refined text range occupied by the text within the text to be extracted is determined. Thus, by utilizing the image information of the foreground region, background region, internal foreground region, and internal background region of the text, the outer and inner contours of the text to be extracted can be determined. This provides a refined basis for extracting the text, enabling the electronic device to extract a more accurate text from the image being detected.

[0091] Since the gaps between the strokes of the text to be extracted are actually the background areas of the image to be detected, in order to provide a more accurate basis for extraction, the foreground area inside the text and the background area inside the text can be determined separately, which are the font texture and texture gap background areas in this embodiment.

[0092] In this way, the obtained erosion results, dilation results, font textures, and background areas between texture gaps of the text to be extracted can be merged. That is, the image information corresponding to the above multiple processing results is merged into one image, resulting in an image that only includes the image information of the erosion results, dilation results, font textures, and background areas between texture gaps. Therefore, the obtained image is determined as the extraction basis for the text to be extracted. Thus, the electronic device can extract the text to be extracted from the image to be detected based on the obtained extraction basis.

[0093] For example, after erosion processing of the detection result, the remaining image information represents the main internal part of the detection result, i.e., the foreground region of the text. After dilation processing of the detection result, the remaining image information represents the main external part of the detection result, i.e., the background region of the text. After skeleton extraction processing of the detection result, the extracted image information represents the foreground region of the text represented by the font texture, and the background region of the text represented by the gaps between the textures.

[0094] For example, the erosion result shown in Figure 1(c) presents the main body of "Fog Mountain", which is the text foreground area of ​​"Fog Mountain"; the dilation result shown in Figure 1(d) presents the main body outside "Fog Mountain", which is the text background area of ​​"Fog Mountain"; and the skeleton extraction result shown in Figure 1(e) presents the stroke structure inside "Fog Mountain", which is the text foreground area of ​​"Fog Mountain", and the gap area between the stroke structures inside "Fog Mountain", which is the text background area of ​​"Fog Mountain".

[0095] In this way, by merging the image information of the text foreground area, text background area, text inner foreground area, and text inner background area together, the image information of the words "Fog Mountain" can be obtained.

[0096] Optionally, the OpenCV matting algorithm can be used to extract the text to be detected from the image to be detected based on the above extraction criteria.

[0097] Optionally, in one specific implementation, the above extraction basis can be a Trimap graph.

[0098] In this specific implementation, the image information corresponding to the obtained erosion results, dilation results, font textures, and texture gap background areas can be merged into a Trimap image. In this way, the electronic device can use the image information included in the Trimap image as the basis for extracting the text to be extracted from the image to be detected.

[0099] As can be seen from the above, by applying the solution provided in this application embodiment, firstly, by detecting the text to be extracted in the image to be detected, a detection result can be obtained. Secondly, the obtained detection result is subjected to erosion processing to obtain an erosion result of the text to be extracted, and the obtained detection result is subjected to dilation processing to obtain a dilation result of the text to be extracted. Then, by performing skeleton extraction processing on the above detection result, the font texture and texture gap background area of ​​the text to be extracted are extracted. Thus, the obtained erosion result, dilation result, font texture and texture gap background area are merged to obtain the extraction basis of the text to be extracted. In this way, the text to be extracted can be extracted from the image to be detected based on the obtained extraction basis.

[0100] Based on this, by merging the obtained erosion results, dilation results, font textures, and texture gap background areas of the text to be extracted, the extraction basis for the aforementioned text to be extracted can be obtained. Thus, the extraction basis can be used to extract the text to be extracted from the image to be detected. This automated extraction method reduces the text extraction time spent on manual extraction by staff, thereby improving text extraction efficiency.

[0101] Alternatively, in one specific implementation, Figure 3 This is a flowchart illustrating another text extraction method provided in an embodiment of this application. Figure 3 As shown, step S203 above, which involves extracting the font texture and background area of ​​the text to be extracted by processing the skeleton of the detection result, may include the following steps S2031-S2033:

[0102] S2031: Perform skeleton extraction processing on the detection results to obtain the font texture of the text to be extracted;

[0103] S2032: Extract the edge contour of the detection result to obtain the contour region of the detection result, and determine the region outside the detection result in the contour region as the internal background region to be extracted;

[0104] S2033: Perform skeleton extraction processing on the internal background area to be extracted to obtain the texture gap background area of ​​the text to be extracted.

[0105] In this specific implementation, after obtaining the detection results of the text to be extracted, the skeleton extraction process can be performed on the detection results to obtain the font texture of the text to be extracted, that is, the foreground area inside the text of the text to be extracted.

[0106] Furthermore, after obtaining the above detection results, the edge contours of the above detection results can be extracted, thereby obtaining the contour region of the above detection results. In this way, the area in the above contour region other than the above detection results can be determined as the internal background region to be extracted of the above text to be extracted. That is, the area other than the area where the text is located within the entire contour region is determined as the internal background region to be extracted of the above text to be extracted.

[0107] Then, the skeleton extraction process can be performed again on the determined internal background area to be extracted. In the internal background area to be extracted, the texture gap background area of ​​the text to be extracted is extracted, that is, the text internal background area of ​​the text to be extracted is extracted.

[0108] Optionally, the OpenCV findContours algorithm can be used to detect the edge contours of the detection results, thereby obtaining the contour region of the detection results.

[0109] Corresponding to the text extraction method provided in the above embodiments of this application, this application also provides a text extraction device.

[0110] Figure 4 This is a schematic diagram of the structure of a text extraction device provided in an embodiment of this application, as shown below. Figure 4 As shown, the device may include the following modules:

[0111] The acquisition module 410 is used to detect the text to be extracted in the image to be detected and obtain the detection result;

[0112] The processing module 420 is used to perform erosion processing on the detection result to obtain the erosion result of the text to be extracted, and to perform dilation processing on the detection result to obtain the dilation result of the text to be extracted;

[0113] The skeleton extraction module 430 is used to extract the font texture and texture gap background area of ​​the text to be extracted by performing skeleton extraction processing on the detection results before merging the erosion results and the dilation results to obtain the extraction basis for the text to be extracted.

[0114] The merging module 440 is used to merge the erosion result, the dilation result, the font texture, and the background area of ​​the texture gap to obtain the extraction basis for the text to be extracted;

[0115] Extraction module 450 is used to extract the text to be extracted from the image to be detected based on the extraction criteria.

[0116] As can be seen from the above, by applying the solution provided in this application embodiment, firstly, by detecting the text to be extracted in the image to be detected, a detection result can be obtained. Secondly, the obtained detection result is subjected to erosion processing to obtain an erosion result of the text to be extracted, and the obtained detection result is subjected to dilation processing to obtain a dilation result of the text to be extracted. Then, by performing skeleton extraction processing on the above detection result, the font texture and texture gap background area of ​​the text to be extracted are extracted. Thus, the obtained erosion result, dilation result, font texture and texture gap background area are merged to obtain the extraction basis of the text to be extracted. In this way, the text to be extracted can be extracted from the image to be detected based on the obtained extraction basis.

[0117] Based on this, by merging the obtained erosion results, dilation results, font textures, and texture gap background areas of the text to be extracted, the extraction basis for the aforementioned text to be extracted can be obtained. Thus, the extraction basis can be used to extract the text to be extracted from the image to be detected. This automated extraction method reduces the text extraction time spent on manual extraction by staff, thereby improving text extraction efficiency.

[0118] Optionally, in one specific implementation, the skeleton extraction module 430 is specifically used for:

[0119] The detection results are subjected to skeleton extraction processing to obtain the font texture of the text to be extracted;

[0120] Extract the edge contour of the detection result to obtain the contour region of the detection result, and determine the region outside the detection result in the contour region as the internal background region to be extracted;

[0121] The skeleton extraction process is performed on the internal background region to be extracted to obtain the texture gap background region of the text to be extracted.

[0122] Optionally, in one specific implementation, the extraction is based on a Trimap graph.

[0123] Corresponding to the above embodiments of this application, an electronic device is also provided, such as... Figure 5 As shown, it includes a processor 501, a communication interface 502, a memory 503, and a communication bus 504, wherein the processor 501, the communication interface 502, and the memory 503 communicate with each other through the communication bus 504.

[0124] Memory 503 is used to store computer programs;

[0125] When the processor 501 executes the program stored in the memory 503, it implements the steps of any of the text extraction methods provided in the embodiments of this application.

[0126] The communication bus mentioned above can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used to represent it in the diagram, but this does not mean that there is only one bus or one type of bus.

[0127] The communication interface is used for communication between the aforementioned terminal and other devices.

[0128] The memory may include random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.

[0129] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0130] In another embodiment provided in this application, a computer-readable storage medium is also provided, wherein a computer program is stored therein, and when the computer program is executed by a processor, it implements any of the text extraction methods described in the above embodiments.

[0131] In another embodiment provided in this application, a computer program product containing instructions is also provided, which, when run on a computer, causes the computer to execute any of the text extraction methods described in the above embodiments.

[0132] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid state disk (SSD)).

[0133] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0134] The various embodiments in this specification are described in a related manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the device embodiments, electronic device embodiments, computer-readable storage medium embodiments, and computer program product embodiments are basically similar to the method embodiments, and therefore the descriptions are relatively simple; relevant parts can be referred to the descriptions of the method embodiments.

[0135] The above description is merely a preferred embodiment of this application and is not intended to limit the scope of protection of this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application are included within the scope of protection of this application.

Claims

1. A text extraction method, characterized in that, The method includes: The text to be extracted is detected in the image to be detected, and the detection result is obtained; The detection results are subjected to erosion processing to obtain erosion results of the text to be extracted, and the detection results are subjected to dilation processing to obtain dilation results of the text to be extracted. By extracting the skeleton from the detection results, the font texture and background area of ​​the texture gaps in the text to be extracted are extracted. The image information corresponding to the erosion result, the dilation result, the font texture, and the background area of ​​the texture gap is merged into a Trimap image, and the Trimap image is used as the basis for extracting the text to be extracted; wherein, the extraction basis is an image including the image information of the erosion result, the dilation result, the font texture, and the background area of ​​the texture gap; Based on the extraction criteria, the text to be extracted is extracted from the image to be detected.

2. The method according to claim 1, characterized in that, The process of extracting the skeleton from the detection results to extract the font texture and background area of ​​the text to be extracted includes: The detection results are subjected to skeleton extraction processing to obtain the font texture of the text to be extracted; Extract the edge contour of the detection result to obtain the contour region of the detection result, and determine the region outside the detection result in the contour region as the internal background region to be extracted; The skeleton extraction process is performed on the internal background region to be extracted to obtain the texture gap background region of the text to be extracted.

3. A text extraction device, characterized in that, The device includes: The acquisition module is used to detect the text to be extracted in the image to be detected and obtain the detection results; The processing module is used to perform erosion processing on the detection results to obtain erosion results about the text to be extracted, and to perform dilation processing on the detection results to obtain dilation results about the text to be extracted; The skeleton extraction module is used to extract the font texture and texture gap background area of ​​the text to be extracted by processing the skeleton of the detection result. The merging module is used to merge the image information corresponding to the erosion result, the dilation result, the font texture, and the background area of ​​the texture gap into a Trimap image, and use the Trimap image as the extraction basis for the text to be extracted; wherein, the extraction basis is an image including the image information of the erosion result, the dilation result, the font texture, and the background area of ​​the texture gap; An extraction module is used to extract the text to be extracted from the image to be detected based on the extraction criteria.

4. The apparatus according to claim 3, characterized in that, The skeleton extraction module is specifically used for: The detection results are subjected to skeleton extraction processing to obtain the font texture of the text to be extracted; Extract the edge contour of the detection result to obtain the contour region of the detection result, and determine the region outside the detection result in the contour region as the internal background region to be extracted; The skeleton extraction process is performed on the internal background region to be extracted to obtain the texture gap background region of the text to be extracted.

5. An electronic device, characterized in that, It includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, when executing a program stored in memory, implements the steps of the method described in any one of claims 1-2.

6. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the method described in any one of claims 1-2.

Citation Information

Patent Citations

  • Character image vectorization method and system based on framework instruction

    CN103942552A