Method and device for separating characters from image, electronic equipment and medium
By performing binarization, reconstruction and black hat operations on the image, a text filter is generated to remove the non-text parts of the image, solving the problem of low text recognition accuracy in the existing technology and achieving higher text recognition accuracy. and lower error rates.
Patent Information
- Application Number
- CN202411303166.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-18
- Publication Date
- 2025-01-21
AI Technical Summary
In the prior art, when using text recognition software to select text parts from an image file, if non-text information such as some images exist in the selected area of the box, the text that has been selected will not be accurately identified, resulting in text Low recognition accuracy.
By using the morphological operation method to process the original image, the original image is binarized, reconstructed and opened, and the black hat operation is performed to obtain the text filter. The text filter is used to remove the image part of the original image, leaving only the text. Message text image.
It improves the accuracy of text recognition, reduces the recognition error rate, and ensures that the recognition accuracy will not be reduced due to mistakenly selecting non-text areas during text recognition.
Smart Images

Figure CN119339382A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of image processing, and in particular to a method, device, electronic device and medium for separating text from an image. Background Art
[0002] At present, image content is becoming increasingly rich. For example, an image file may contain both text and images. The text in an image file cannot be edited directly. It is necessary to use text recognition software to recognize the text before the next editing operation can be performed. In the prior art, when using text recognition software to select a text portion from an image file, if the selected area also contains non-text information such as a partial image, the selected text cannot be accurately recognized, resulting in a low text recognition accuracy. Summary of the invention
[0003] In order to solve the problems in the related art, the embodiments of the present disclosure provide a method, device, electronic device and medium for separating text from an image.
[0004] In a first aspect, an embodiment of the present disclosure provides a method for separating text from an image, comprising: Get the original image; Performing binarization operation, reconstruction opening operation and black hat operation on the original image in sequence to obtain a text filter; The original image is processed using the text filter to obtain a text image.
[0005] In an implementation of the present disclosure, the step of sequentially performing a binarization operation, a reconstruction operation, and a black hat operation on the original image to obtain a text filter includes: Performing a binarization operation on the original image to obtain a first image; Performing an erosion operation on the first image to obtain a second image; Using the second image as a seed image and the first image as a mask to perform a reconstruction operation to obtain a third image; A black hat operation is performed on the third image to obtain a text filter.
[0006] In one implementation of the present disclosure, the method further includes: Receive configuration parameters of a text filter; the configuration parameters include a binarization threshold and / or an erosion kernel and / or a rectangular kernel of a black hat operation; The performing a binarization operation on the original image to obtain a first image comprises: Obtaining a first image based on the binarization threshold; The performing an erosion operation on the first image to obtain a second image comprises: Obtaining a second image based on the erosion kernel; The performing a black hat operation on the third image to obtain a text filter comprises: A text filter is obtained based on the rectangular kernel.
[0007] In an implementation of the present disclosure, the step of processing the original image using the text filter to obtain a text image includes: The text filter is inverted and added to the original image to obtain a text image.
[0008] In one implementation of the present disclosure, the method further includes: Perform text recognition on the text image.
[0009] In an implementation of the present disclosure, before performing text recognition on the text image, the method further includes: Perform text enhancement processing on the text image.
[0010] In a second aspect, an embodiment of the present disclosure provides a device for separating text from an image, comprising: An acquisition module is configured to acquire an original image; A generating module is configured to sequentially perform a binarization operation, a reconstruction operation, and a black hat operation on the original image to obtain a text filter; The processing module is configured to process the original image using the text filter to obtain a text image.
[0011] In one implementation of the present disclosure, the generating module includes: A first generating unit is configured to perform a binarization operation on the original image to obtain a first image; A second generating unit is configured to perform an erosion operation on the first image to obtain a second image; a third generating unit, configured to perform a reconstruction operation using the second image as a seed image and the first image as a mask to obtain a third image; The fourth generating unit is configured to perform a black hat operation on the third image to obtain a text filter.
[0012] In one implementation of the present disclosure, the device further includes: A configuration module, configured to receive configuration parameters of a text filter; the configuration parameters include a binarization threshold and / or an erosion kernel and / or a rectangular kernel of a black hat operation; The first generating unit is further configured to: obtain a first image based on the binarization threshold; The second generating unit is further configured to: obtain a second image based on the erosion kernel; The fourth generating unit is further configured to obtain a text filter based on the rectangular kernel.
[0013] In one implementation of the present disclosure, the processing module includes: The operation unit is configured to add the inverted text filter to the original image to obtain a text image.
[0014] In one implementation of the present disclosure, the device further includes: The recognition module is configured to perform text recognition on the text image.
[0015] In one implementation of the present disclosure, the device further includes: The enhancement processing module is configured to perform text enhancement processing on the text image.
[0016] In a third aspect, an embodiment of the present disclosure provides an electronic device, comprising a memory and a processor, wherein the memory is used to store one or more computer instructions, and wherein the one or more computer instructions are executed by the processor to implement a method as described in any one of the first aspects.
[0017] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium on which computer instructions are stored. When the computer instructions are executed by a processor, the method described in any one of the first aspects is implemented.
[0018] The technical effects provided by the embodiments of the present disclosure may include the following beneficial effects: According to the technical solution provided by the embodiment of the present disclosure, a method for separating text from an image includes: obtaining an original image; sequentially performing a binarization operation, a reconstruction operation, and a black hat operation on the original image to obtain a text filter; and using the text filter to process the original image to obtain a text image. In the above technical solution, the original image is processed by using a morphological operation method, and the original image is sequentially subjected to a binarization operation, a reconstruction operation, and a black hat operation to obtain a text filter. The text filter can be used to remove the image portion of the original image, and only the text image containing text information is retained. In this way, when performing text recognition, the accuracy of text recognition will not be reduced due to the mistaken selection of a non-text area, which is conducive to improving the accuracy of text recognition and reducing the recognition error rate.
[0019] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 A flow chart of a method for separating text from an image according to an embodiment of the present disclosure is shown.
[0021] Figure 2a-2f A schematic diagram showing a method of obtaining a text image according to a specific embodiment of the present disclosure is shown.
[0022] Figure 3 A structural block diagram of a device for separating text from an image according to an embodiment of the present disclosure is shown.
[0023] Figure 4 A structural block diagram of an electronic device according to an embodiment of the present disclosure is shown.
[0024] Figure 5 A schematic diagram showing the structure of a computer system suitable for implementing the method according to an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0025] Hereinafter, exemplary embodiments of the present disclosure will be described in detail with reference to the accompanying drawings so that those skilled in the art can easily implement them. In addition, for the sake of clarity, parts not related to the description of the exemplary embodiments are omitted in the accompanying drawings.
[0026] In the present disclosure, it should be understood that terms such as "include" or "have" are intended to indicate the presence of features, numbers, steps, behaviors, components, parts, or a combination thereof disclosed in the present specification, and are not intended to exclude the possibility that one or more other features, numbers, steps, behaviors, components, parts, or a combination thereof exist or are added.
[0027] It should also be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present disclosure may be combined with each other. The present disclosure will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0028] As mentioned above, in the prior art, when text recognition software is used to select text from an image file, if the selected area also contains non-text information such as partial images, the selected text cannot be accurately recognized, resulting in low text recognition accuracy.
[0029] Taking the above-mentioned defects into consideration, the method for separating text from an image provided by the present invention processes the original image by adopting a morphological operation method, and sequentially performs binarization operation, reconstruction operation, and black hat operation on the original image to obtain a text filter. The text filter can be used to remove the image part in the original image, and only retain the text image containing text information. In this way, when performing text recognition, the text recognition accuracy will not be reduced due to the mistaken selection of non-text areas, which is beneficial to improving the text recognition accuracy and reducing the recognition error rate.
[0030] Figure 1 A flow chart of a method for separating text from an image according to an embodiment of the present disclosure is shown.
[0031] like Figure 1As shown, the method for separating text from an image includes the following steps S110-S140: In step S110, an original image is obtained; In step S120, the original image is subjected to binarization operation, reconstruction opening operation, and black hat operation in sequence to obtain a text filter; In step S130, the original image is processed using the text filter to obtain a text image.
[0032] In the disclosed method, the original image is a grayscale image, and the original image can be the entire image obtained by shooting, or a partial image captured. The original image contains text and non-text information such as pictures. The purpose of the present disclosure is to remove the non-text information in the original image and obtain a text image that retains the text information. The format of the text in the text image, such as grayscale, position, size, angle and other information, is generally the same as that of the original image, except that the non-text information is removed, so as to facilitate the subsequent text recognition processing.
[0033] In the disclosed method, morphological operations in image processing are used to process the binarized original image, non-text information in the original image is removed, a text filter capable of filtering text information in the original image is obtained, and then the text filter is used to process the original image to obtain a text image.
[0034] Basic morphological operations include but are not limited to corrosion, expansion, opening and closing operations, gradient operations, white hat operations, black hat operations, morphological reconstruction operations, etc. Among them, the opening operation is to corrode the image first and then expand it; the closing operation is to expand the image first and then corrode it; the gradient operation is to subtract the eroded image from the expanded image; the white hat operation is to open the image and then subtract the open operation image from the original image; the black hat operation is to close the image and then subtract the original image from the closed operation image; the morphological reconstruction operation is different from the basic corrosion and expansion in that the labeled image is introduced in the corrosion and expansion process, and the template image is used to constrain the reconstruction. Morphological reconstruction operations can be divided into reconstruction opening operations and reconstruction closing operations.
[0035] The morphological operation adopted in the disclosed method is not arbitrary, but a reconstruction operation and a black hat operation are selected, and after the binarization operation, the reconstruction operation and the black hat operation are performed in sequence. The location of the text and non-text information is used as the foreground for explanation. The purpose of the binarization operation is to separate the foreground and the white background, wherein the text and non-text information in the grayscale image, such as pictures, are set to black. The purpose of the corrosion in the reconstruction operation is to further process the pictures that are not completely set to black in the binarization operation to black, and the text and holes in the text in the image obtained after reconstruction are filled with black. Finally, a black hat operation is performed to remove the pictures in the grayscale image, and the text in the image processed by the reconstruction operation is set to white, so as to obtain a black background and white text image as a text filter. The text filter is inverted and added to the original grayscale image to obtain a new grayscale image that only retains the text information in the grayscale image under the white background, that is, the text image is obtained.
[0036] In one implementation of the present disclosure, the step S120 sequentially performs a binarization operation, a reconstruction operation, and a black hat operation on the original image to obtain a text filter, including: Performing a binarization operation on the original image to obtain a first image; Performing an erosion operation on the first image to obtain a second image; Using the second image as a seed image and the first image as a mask to perform a reconstruction operation to obtain a third image; A black hat operation is performed on the third image to obtain a text filter.
[0037] For details, please refer to Figure 2a-2f As shown. Figure 2a As shown, the original grayscale image is recorded as grayscale image i, which contains the picture area and the text area. The grayscale image i is binarized to filter out the pure white area to obtain the first image BW. The pure white area in the first image BW includes the area near the text and the white area next to the black picture (obtained by processing the picture area), as shown in Figure 2b As shown; then the first image BW is eroded, and the structural element of the erosion kernel is defined as a square with a side length of n1. The erosion kernel is used to shrink the white part of the black image inward, so that the image area is completely set to black, and the text area is also eroded, and the second image BW2 is obtained, as shown Figure 2c As shown in the figure, the second image BW2 is used as the seed image, and the first image BW is used as the mask for reconstruction. The seed image (white pixels) is continuously expanded until the edge of the restricted (mask) image is reached or there is no further expansion. The intuitive effect is that the position of the white area after corrosion is mapped to the BW image and expands outward. When the edge is encountered, the expansion stops. In this way, the white part of the image area is removed and the text area is set to black text on a white background, which is recorded as the third image image, as shown in the figure. Figure 2d As shown; then perform a black hat operation on the third image image, define the expansion kernel and erosion kernel of the bottom hat operation as structural elements of the same size, and the structural element is a rectangular kernel of n2*n3, use the rectangular kernel to eliminate the text area and retain the image area, and then subtract it from the grayscale image i to remove the image area in the grayscale image i and retain the text area (the icon in the lower left corner is also retained here), recorded as text filter image2, as shown Figure 2e As shown. Figure 2e The obtained text filter image2 is inverted and added to the original grayscale image i to obtain a new grayscale image that only retains the text information in the grayscale image i under a white background, that is, the text image image3 is obtained, as shown in Figure 2f shown.
[0038] In one implementation of the present disclosure, the method further includes: Receive configuration parameters of a text filter; the configuration parameters include a binarization threshold and / or an erosion kernel and / or a rectangular kernel of a black hat operation; The performing a binarization operation on the original image to obtain a first image comprises: Obtaining a first image based on the binarization threshold; The performing an erosion operation on the first image to obtain a second image comprises: Obtaining a second image based on the erosion kernel; The performing a black hat operation on the third image to obtain a text filter comprises: A text filter is obtained based on the rectangular kernel.
[0039] In the disclosed method, a text filter can be obtained by configuring a binarization threshold and / or a size of a rectangular kernel of an erosion kernel and / or a black hat operation.
[0040] by Figure 2a The grayscale image i shown is used as an example for schematic illustration. Figure 2a The picture area is on the right and the text area is on the left of the picture area.
[0041] By adjusting the binarization threshold, the size of the white part in the black image in the first image BW can be changed. Choosing a suitable binarization threshold can reduce the difficulty of subsequent reconstruction and black hat operations. The erosion kernel is selected, for example, (5, 5), so that the white part in the black image shrinks inward, thereby removing the white part in the black image. If the length / width of the erosion kernel is too large, it will cause excessive erosion in the X / Y direction and lose details. If it is too small, the white part in the black image will remain. The bottom hat operation uses a larger rectangular kernel, such as (3×100), in order to retain a large area of black image area while eliminating a small area of black text area. If the rectangular kernel is too small, part of the content of the text area will be lost. If the rectangular kernel is too large, the black image area will be missed.
[0042] It is understandable that the original image may also include non-text information such as table lines in Excel, or the text area may be embedded in the image area. Those skilled in the art only need to adjust the binarization threshold and / or the size of the erosion kernel and / or the rectangular kernel of the black hat operation accordingly to obtain a text filter that matches the original image currently being processed. Preferably, the binarization threshold, the erosion kernel, and the size of the rectangular kernel may be adjusted simultaneously.
[0043] In an implementation of the present disclosure, the step S130 of processing the original image using the text filter to obtain a text image includes: The text filter is inverted and added to the original image to obtain a text image.
[0044] Specifically, Figure 2e The obtained text filter image2 is inverted and added to the original grayscale image i to obtain a new grayscale image that only retains the text information in the grayscale image i under a white background, that is, the text image image3 is obtained, as shown in Figure 2f shown.
[0045] In an implementation of the present disclosure, the method further includes performing text recognition on the text image.
[0046] Specifically, traditional OCR recognition methods or other deep learning recognition methods may be used, and the present disclosure does not impose any restrictions on this.
[0047] In an implementation of the present disclosure, before performing text recognition on the text image, the method further includes: Perform text enhancement processing on the text image.
[0048] In the disclosed method, in order to further improve the text recognition effect, the text image can also be enhanced and then the OCR service is requested to improve the accuracy of the OCR recognition effect. The specific enhancement processing includes but is not limited to angle correction, text sharpening, image brightening, etc.
[0049] Figure 3 The structural block diagram of the device for separating text from an image according to an embodiment of the present disclosure is shown. The system can be implemented as part or all of an electronic device through software, hardware or a combination of both.
[0050] like Figure 3 As shown, the device 300 for separating text from an image includes: The acquisition module 310 is configured to acquire an original image; The generating module 320 is configured to sequentially perform a binarization operation, a reconstruction operation, and a black hat operation on the original image to obtain a text filter; The processing module 330 is configured to process the original image using the text filter to obtain a text image.
[0051] The device for separating text from an image provided by the present disclosure processes the original image by adopting a morphological operation method, and sequentially performs binarization operation, reconstruction opening operation, and black hat operation on the original image to obtain a text filter. The text filter can be used to remove the image part in the original image, and only the text image containing text information is retained. In this way, when performing text recognition, the text recognition accuracy will not be reduced due to the mistaken selection of non-text areas, which is beneficial to improving the text recognition accuracy and reducing the recognition error rate.
[0052] In one implementation of the present disclosure, the generating module 320 includes: A first generating unit is configured to perform a binarization operation on the original image to obtain a first image; A second generating unit is configured to perform an erosion operation on the first image to obtain a second image; a third generating unit, configured to perform a reconstruction operation using the second image as a seed image and the first image as a mask to obtain a third image; The fourth generating unit is configured to perform a black hat operation on the third image to obtain a text filter.
[0053] In one implementation of the present disclosure, the device further includes: A configuration module, configured to receive configuration parameters of a text filter; the configuration parameters include a binarization threshold and / or an erosion kernel and / or a rectangular kernel of a black hat operation; The first generating unit is further configured to: obtain a first image based on the binarization threshold; The second generating unit is further configured to: obtain a second image based on the erosion kernel; The fourth generating unit is further configured to obtain a text filter based on the rectangular kernel.
[0054] In one implementation of the present disclosure, the processing module includes: The operation unit is configured to add the inverted text filter to the original image to obtain a text image.
[0055] In one implementation of the present disclosure, the device further includes: The recognition module is configured to perform text recognition on the text image.
[0056] In one implementation of the present disclosure, the device further includes: The enhancement processing module is configured to perform text enhancement processing on the text image.
[0057] The present disclosure also discloses an electronic device, Figure 4 A structural block diagram of an electronic device according to an embodiment of the present disclosure is shown.
[0058] like Figure 4 As shown, the electronic device includes a memory and a processor, wherein the memory is used to store one or more computer instructions, wherein the one or more computer instructions are executed by the processor to implement the method according to an embodiment of the present disclosure: Get the original image; Performing binarization operation, reconstruction opening operation and black hat operation on the original image in sequence to obtain a text filter; The original image is processed using the text filter to obtain a text image.
[0059] In an implementation of the present disclosure, the step of sequentially performing a binarization operation, a reconstruction operation, and a black hat operation on the original image to obtain a text filter includes: Performing a binarization operation on the original image to obtain a first image; Performing an erosion operation on the first image to obtain a second image; Using the second image as a seed image and the first image as a mask to perform a reconstruction operation to obtain a third image; A black hat operation is performed on the third image to obtain a text filter.
[0060] In one implementation of the present disclosure, the method further includes: Receive configuration parameters of a text filter; the configuration parameters include a binarization threshold and / or an erosion kernel and / or a rectangular kernel of a black hat operation; The performing a binarization operation on the original image to obtain a first image comprises: Obtaining a first image based on the binarization threshold; The performing an erosion operation on the first image to obtain a second image comprises: Obtaining a second image based on the erosion kernel; The performing a black hat operation on the third image to obtain a text filter comprises: A text filter is obtained based on the rectangular kernel.
[0061] In an implementation of the present disclosure, the step of processing the original image using the text filter to obtain a text image includes: The text filter is inverted and added to the original image to obtain a text image.
[0062] In one implementation of the present disclosure, the method further includes: Perform text recognition on the text image.
[0063] In an implementation of the present disclosure, before performing text recognition on the text image, the method further includes: Perform text enhancement processing on the text image.
[0064] Figure 5 A schematic diagram showing the structure of a computer system suitable for implementing the method according to an embodiment of the present disclosure is shown.
[0065] like Figure 5 As shown, the computer system includes a processing unit, which can execute various methods in the above-mentioned embodiments according to a program stored in a read-only memory (ROM) or a program loaded from a storage part into a random access memory (RAM). In the RAM, various programs and data required for the operation of the computer system are also stored. The processing unit, ROM and RAM are connected to each other through a bus. An input / output (I / O) interface is also connected to the bus.
[0066] The following components are connected to the I / O interface: an input part including a keyboard, a mouse, etc.; an output part including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker; a storage part including a hard disk, etc.; and a communication part including a network interface card such as a LAN card, a modem, etc. The communication part performs a communication process via a network such as the Internet. The drive is also connected to the I / O interface as needed. Removable media, such as disks, optical disks, magneto-optical disks, semiconductor memories, etc., are installed on the drive as needed so that the computer program read therefrom can be installed into the storage part as needed. Among them, the processing unit can be implemented as a processing unit such as a CPU, a GPU, a TPU, an FPGA, an NPU, etc.
[0067] In particular, according to an embodiment of the present disclosure, the method described above can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program tangibly contained on a machine-readable medium, and the computer program includes a program code for executing the above method. In such an embodiment, the computer program can be downloaded and installed from a network through a communication part, and / or installed from a removable medium.
[0068] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0069] The units or modules involved in the embodiments described in the present disclosure may be implemented by software or programmable hardware. The units or modules described may also be set in a processor, and the names of these units or modules do not constitute limitations on the units or modules themselves in some cases.
[0070] As another aspect, the present disclosure further provides a computer-readable storage medium, which may be a computer-readable storage medium included in the electronic device or computer system in the above embodiment; or a computer-readable storage medium that exists independently and is not assembled into a device. The computer-readable storage medium stores one or more programs, and the programs are used by one or more processors to execute the method described in the present disclosure.
[0071] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of the invention involved in the present disclosure is not limited to the technical solution formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the inventive concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other.
Claims
1. A method for separating text from an image, characterized in that: include: Get the original image; Performing binarization operation, reconstruction opening operation and black hat operation on the original image in sequence to obtain a text filter; The original image is processed using the text filter to obtain a text image.
2. The method for separating text from an image according to claim 1, characterized in that: The step of sequentially performing a binarization operation, a reconstruction operation, and a black hat operation on the original image to obtain a text filter includes: Performing a binarization operation on the original image to obtain a first image; Performing an erosion operation on the first image to obtain a second image; Using the second image as a seed image and the first image as a mask to perform a reconstruction operation to obtain a third image; A black hat operation is performed on the third image to obtain a text filter.
3. The method for separating text from an image according to claim 2, characterized in that: Also includes: Receive configuration parameters for text filters; The configuration parameters include a binarization threshold and / or a corrosion kernel and / or a rectangular kernel of a black hat operation; The performing a binarization operation on the original image to obtain a first image comprises: Obtaining a first image based on the binarization threshold; The performing an erosion operation on the first image to obtain a second image comprises: Obtaining a second image based on the erosion kernel; The performing a black hat operation on the third image to obtain a text filter comprises: A text filter is obtained based on the rectangular kernel.
4. The method for separating text from an image according to claim 1, characterized in that: The step of processing the original image using the text filter to obtain a text image includes: The text filter is inverted and added to the original image to obtain a text image.
5. The method for separating text from an image according to claim 1, characterized in that: Also includes: Perform text recognition on the text image.
6. The method for separating text from an image according to claim 5, characterized in that: Before performing text recognition on the text image, the method further includes: Perform text enhancement processing on the text image.
7. A device for separating text from an image, characterized in that: include: An acquisition module is configured to acquire an original image; A generating module is configured to sequentially perform a binarization operation, a reconstruction operation, and a black hat operation on the original image to obtain a text filter; The processing module is configured to process the original image using the text filter to obtain a text image.
8. The device for separating text from an image according to claim 7, characterized in that: The generation module comprises: A first generating unit is configured to perform a binarization operation on the original image to obtain a first image; A second generating unit is configured to perform an erosion operation on the first image to obtain a second image; a third generating unit, configured to perform a reconstruction operation using the second image as a seed image and the first image as a mask to obtain a third image; The fourth generating unit is configured to perform a black hat operation on the third image to obtain a text filter.
9. An electronic device, characterized in that: The method comprises a memory and a processor; wherein the memory is used to store one or more computer instructions, wherein the one or more computer instructions are executed by the processor to implement the method according to any one of claims 1 to 6.
10. A computer-readable storage medium having computer instructions stored thereon, characterized in that: When the computer instructions are executed by a processor, the method according to any one of claims 1 to 6 is implemented.