Text and image correction method, device, electronic device, and machine-readable storage medium
Through the method of text line detection and distortion curve calculation, the distortion of text images caused by the thickness of the book when shooting or scanning is corrected, improving the reading experience.
Patent Information
- Application Number
- CN201910330806.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-04-23
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2039-04-23
AI Technical Summary
When photographing or scanning paper text, due to the thickness of books and other carriers, the text content in the text image is prone to distortion, affecting the reading experience.
By obtaining the text image to be corrected, text line detection is performed to obtain designated point position information of the characters, the distortion curve of the text line is calculated, and correction mapping is performed based on these curves to obtain the corrected text image.
It effectively corrects the distorted content in text images and improves the user's reading experience.
Smart Images

Figure CN111832371B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to a text image correction method, device, electronic device and machine-readable storage medium. Background Art
[0002] With the development of electronic technology, it is often necessary to take photos or scan paper texts to meet people's needs for viewing and sharing text content. However, when taking photos or scanning paper texts, due to the certain thickness of carriers such as books, it is inevitable that the text content in the photographed or scanned text images will be distorted, affecting people's reading experience. Summary of the invention
[0003] The purpose of the embodiments of the present invention is to provide a text image correction method, device, electronic device and machine-readable storage medium to correct the distorted text content in the text image and improve the reading experience. The specific technical solution is as follows:
[0004] In a first aspect, an embodiment of the present invention provides a text image correction method, the method comprising:
[0005] Get the text image to be corrected;
[0006] Performing text line detection on the text image to obtain designated point position information of a plurality of characters in each text line of the text image;
[0007] Calculating the distortion curve of each text line according to the designated point position information of the plurality of characters in each text line;
[0008] Based on the distortion curves of the text lines, the text image is corrected and mapped to obtain a corrected text image.
[0009] Preferably, the performing text line detection on the text image to obtain the designated point position information of a plurality of characters in each text line of the text image includes:
[0010] Performing document area detection on the text image to obtain detection frame coordinates of the document area in the text image;
[0011] According to the detection frame coordinates, the designated point position information of a plurality of characters in each text line of the document area is detected from the document area.
[0012] Preferably, the step of calculating the distortion curve of each text line according to the designated point position information of the plurality of characters in each text line comprises:
[0013] Construct initialization curve;
[0014] According to the designated point position information of the plurality of characters in each text line, an error value between a first ordinate in the designated point position information and a second ordinate on the initialization curve is calculated, and an error function corresponding to the initialization curve for each text line is constructed, wherein the second ordinate is a ordinate on the initialization curve corresponding to the same abscissa as that in the designated position information;
[0015] According to the error function of each text line corresponding to the initialization curve, the distortion curve of each text line is obtained through curve fitting.
[0016] Preferably, obtaining the distortion curve of each text line by curve fitting according to the error function of each text line corresponding to the initialization curve comprises:
[0017] The error function of each text line corresponding to the initialization curve is minimized to obtain the distortion curve of each text line by fitting.
[0018] Preferably, the performing correction mapping on the text image based on the distortion curve of each text line to obtain a corrected text image includes:
[0019] The twisted curves of each text line are combined into a three-dimensional grid to form a twisted surface;
[0020] The distorted surface is mapped to a plane image to obtain a corrected text image.
[0021] Preferably, after performing correction mapping on the text image based on the distortion curves of the text lines to obtain a corrected text image, the method further comprises:
[0022] Character recognition technology is used to recognize each character in the corrected text image.
[0023] In a second aspect, an embodiment of the present invention provides a text image correction device, comprising:
[0024] An acquisition module is used to acquire the text image to be corrected;
[0025] A detection module, used to perform text line detection on the text image to obtain designated point position information of multiple characters in each text line of the text image;
[0026] A calculation module, used for calculating the distortion curve of each text line according to the designated point position information of multiple characters in each text line;
[0027] The correction module is used to perform correction mapping on the text image based on the distortion curves of each text line to obtain a corrected text image.
[0028] Preferably, the detection module is specifically used for:
[0029] Performing document area detection on the text image to obtain detection frame coordinates of the document area in the text image;
[0030] According to the detection frame coordinates, the designated point position information of a plurality of characters in each text line of the document area is detected from the document area.
[0031] Preferably, the calculation module is specifically used for:
[0032] Construct initialization curve;
[0033] According to the designated point position information of the plurality of characters in each text line, an error value between a first ordinate in the designated point position information and a second ordinate on the initialization curve is calculated, and an error function corresponding to the initialization curve for each text line is constructed, wherein the second ordinate is a ordinate on the initialization curve corresponding to the same abscissa as that in the designated position information;
[0034] According to the error function of each text line corresponding to the initialization curve, the distortion curve of each text line is obtained through curve fitting.
[0035] Preferably, when the calculation module is used to obtain the distortion curve of each text line by curve fitting according to the error function of each text line corresponding to the initialization curve, it is specifically used to:
[0036] The error function of each text line corresponding to the initialization curve is minimized to obtain the distortion curve of each text line by fitting.
[0037] Preferably, the correction module is specifically used for:
[0038] The twisted curves of each text line are combined into a three-dimensional grid to form a twisted surface;
[0039] The distorted surface is mapped to a plane image to obtain a corrected text image.
[0040] Preferably, the device further comprises:
[0041] The character recognition module is used to recognize each character in the corrected text image using character recognition technology.
[0042] In a third aspect, an embodiment of the present invention provides an electronic device, including a processor and a memory, wherein:
[0043] The memory is used to store computer programs;
[0044] The processor is used to implement the method provided in the first aspect of the embodiment of the present invention when executing the computer program stored in the memory.
[0045] In a fourth aspect, an embodiment of the present invention provides a machine-readable storage medium, wherein the machine-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method provided in the first aspect of the embodiment of the present invention is implemented.
[0046] The embodiments of the present invention provide a text image correction method, device, electronic device and machine-readable storage medium, which obtain a text image to be corrected, perform text line detection on the text image, obtain the designated point position information of multiple characters in each text line of the text image, calculate the distortion curve of each text line according to the designated point position information of multiple characters in each text line, and perform correction mapping on the text image based on the distortion curve of each text line to obtain the corrected text image. By detecting the text lines in the text image, the designated point position information of multiple characters in each text line is obtained. The designated point position information of the characters represents the specific position of the characters in the text image. Then, according to the designated point position information of multiple characters, the distortion curve of each text line can be calculated. The distortion curve represents the distortion of the text line. Based on the distortion of each text line, through correction mapping, the originally distorted text image can be corrected to a non-distorted text image, thereby realizing the correction of the distorted text content in the text image and improving the user reading experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0048] Figure 1 Schematic diagram of the flow of the text image correction method according to an embodiment of the present invention;
[0049] Figure 2 A schematic diagram of a twisted surface according to an embodiment of the present invention;
[0050] FIG3( a ) is a schematic diagram showing a picture to be corrected according to an embodiment of the present invention;
[0051] FIG3( b ) is a schematic diagram showing a corrected image according to an embodiment of the present invention;
[0052] Figure 4 A schematic diagram of a flow chart of text image character recognition according to an embodiment of the present invention;
[0053] FIG5( a ) is a schematic diagram showing a picture to be corrected according to an embodiment of the present invention;
[0054] FIG5( b ) is a schematic diagram showing a corrected image according to an embodiment of the present invention;
[0055] Figure 6 A schematic diagram of the structure of a text image correction device according to an embodiment of the present invention;
[0056] Figure 7 A schematic diagram of the structure of an electronic device according to an embodiment of the present invention;
[0057] Figure 8 FIG. 4 is a schematic diagram of the structure of a display system according to an embodiment of the present invention. DETAILED DESCRIPTION
[0058] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0059] In order to correct the distorted text content in the text image and improve the user's reading experience, the embodiment of the present invention provides a text image correction method, device, electronic device and machine-readable storage medium. Below, the text image correction method provided by the embodiment of the present invention is first introduced.
[0060] The execution subject of the text image correction method provided in the embodiment of the present invention can be a terminal device with a shooting function such as a mobile phone or a camera; it can also be a background server, after the image acquisition device captures the text image, it is sent to the background server for correction; it can also be a display device, after the image acquisition device captures the text image, it is sent to the display device for correction and display. The text image correction method provided in the embodiment of the present invention can be implemented in at least one of software, hardware circuits, and logic circuits set in the execution subject.
[0061] like Figure 1 As shown, a flow chart of a text image correction method provided by an embodiment of the present invention is provided, and the method may include the following steps:
[0062] S101, obtaining a text image to be corrected.
[0063] The text image to be corrected is a text image in which the text content is distorted. The execution subject of the embodiment of the present invention can obtain the text image to be corrected specified by the user from the storage medium for correction when receiving the correction requirement input by the user; or the execution subject can start to obtain the text image to be corrected for correction when automatically identifying the distortion in the text image collected in real time.
[0064] S102, performing text line detection on the text image to obtain designated point position information of a plurality of characters in each text line of the text image.
[0065] For text images, traditional text line detection technology can be used to detect each text line in the text image. Traditional text line detection technology mainly detects characters. After detecting the characters in each text line, the designated point position information of the characters is input. The designated point position information of the characters can be determined by the setting of the algorithm, which can be the position information of the bottom midpoint of the character, the position information of the top midpoint, the position information of the center point of the character, and so on.
[0066] Due to the influence of shooting angle, focus range, etc. when taking a text picture, the text picture may not only contain the area where the text document is located, but also contain the content of other non-document areas. In order to improve the efficiency of text line detection and reduce the influence of the content of non-document areas on the text line detection results, preferably, S102 can be specifically implemented by the following steps:
[0067] The first step is to perform document area detection on the text image to obtain the detection box coordinates of the document area in the text image.
[0068] In the second step, based on the detection frame coordinates, the designated point position information of multiple characters in each text line of the document area is detected from the document area.
[0069] For the acquired text image to be corrected, firstly, document area detection can be performed on the text image to detect the document area in the text image. The method for document area detection can be implemented by feature matching algorithm, deep learning algorithm, etc. In order to ensure the accuracy and computational efficiency of detection, a deep learning algorithm can usually be selected for document area detection. The detection frame coordinates of the document area can be obtained through detection. Among them, the deep learning algorithm can be the existing convolutional neural network (CNN), recurrent neural network (RNN) and other algorithms applied to document recognition. The algorithm used can recognize the document content in the text image, and no detailed limitation is made here.
[0070] The detection frame coordinates may be the coordinates of the four vertices of the detection frame where the document area is located, representing the specific position of the detection frame in the text image, so that the designated point position information of the character is calculated based on the detection frame coordinates and the distance between the characters in each text line in the document area and the detection frame. Exemplarily, the lower left corner of the detection frame is taken as the origin, and the designated point position information is marked based on the distance between the designated point position of the character and the lower left corner of the detection frame.
[0071] In the specific text line detection method, we can first use the connected domain recognition method to identify possible character candidate boxes, and then calculate the average height of all characters based on the recognition results of the character candidate boxes, filter out some character candidate boxes that are too large and too small, and output the center point position information of the bottom edge of the candidate box of each character that is retained as the designated point position information of the character.
[0072] S103: Calculate the distortion curve of each text line according to the designated point position information of the plurality of characters in each text line.
[0073] After detecting and obtaining the designated point position information of multiple characters in each text line, the designated point position information of the character represents the position of the character in the text line. By connecting the designated points of multiple characters in a text line, or, further, fitting the connecting lines of the designated points of multiple characters in a text line, the distortion curve of the text line can be obtained. The distortion curve represents the distortion of the text line. The greater the fluctuation of the distortion curve, the more serious the distortion of the text line.
[0074] If, after detecting and obtaining the position information of the designated points of multiple characters in each text line, the designated points of multiple characters in a text line are directly connected as a distortion curve, due to the limitation of the connection rule, there is often an error between the distortion curve and the actual distortion of the text line. In order to obtain the distortion curve of each text line more accurately, preferably, S103 can be specifically implemented by the following steps:
[0075] The first step is to construct the initialization curve.
[0076] In the second step, based on the designated point position information of multiple characters in each text line, the error value between the first vertical coordinate in the designated point position information and the second vertical coordinate on the initialization curve is calculated, and an error function corresponding to the initialization curve for each text line is constructed, wherein the second vertical coordinate is the vertical coordinate on the initialization curve corresponding to the same horizontal coordinate as in the designated position information.
[0077] The third step is to obtain the distortion curve of each text line through curve fitting according to the error function of each text line corresponding to the initialization curve.
[0078] First, a curve can be initialized as a reference line for fitting the distortion curve. In a special case, the initialization curve can also be a straight line. Using the initialization curve as a reference line, the error between the position information of the specified points of multiple characters in the text line and the coordinates of the corresponding points on the initialization curve can be obtained. The corresponding relationship can be the same horizontal coordinate, and the error is the error in the y direction between the characters on the text line and the initialization curve under the same horizontal coordinate. For a text line, the errors corresponding to multiple characters on the text line can be obtained, and further an error function can be constructed. Based on the error function, the distortion curve of each text line can be obtained by curve fitting.
[0079] Optionally, the step of obtaining the distortion curve of each text line by curve fitting according to the error function of each text line corresponding to the initialization curve can be specifically: minimizing the error function of each text line corresponding to the initialization curve to obtain the distortion curve of each text line by fitting.
[0080] Specifically, the distortion curve of the text line can be represented by a one-variable multi-time equation (for example, a one-variable quartic equation). For the error function corresponding to each text line, the parameters of the one-variable multi-time equation can be calculated by minimizing the error function. In this way, the one-variable multi-time equation can be accurately determined, and the distortion curve can be fitted to characterize the distortion of each text line.
[0081] S104, performing correction mapping on the text image based on the distortion curve of each text line to obtain a corrected text image.
[0082] After calculating the distortion curve of each text line, if the distortion curve of each text line is straightened and flattened, the corrected effect of each text line can be mapped. However, since the distortion of the entire text image needs to be limited by the distortion of all text lines, if each text line is corrected separately, the corrected effect will be less than ideal, and irregular character display may occur. Therefore, under normal circumstances, 3D mapping can be selected for text image correction mapping. Specifically, the mapping can be achieved through a three-dimensional mapping function.
[0083] Preferably, S104 can be implemented by the following steps:
[0084] The distortion curves of each text line are combined into a three-dimensional grid to form a distortion surface; the distortion surface is mapped to a plane image to obtain a corrected text image.
[0085] Based on the distortion curve of each text line, a three-dimensional grid is constructed as follows Figure 2The distorted surface shown in the figure. The process of correcting the distorted surface can be achieved by remapping, such as the CV2.remap image correction method. Remapping is the process of mapping the pixels at a certain position in an image to a specified position in another image. In this way, the deformed texture corresponding to the three-dimensional distorted surface we composed can be mapped to the plane image, thereby obtaining the corrected text image.
[0086] Figure 3(a) shows the original text image obtained. By using the method provided in the embodiment of the present invention, the text image shown in Figure 3(a) is corrected to achieve the correction effect shown in Figure 3(b). It can be seen that Figure 3(b) achieves the ideal correction effect, and the text content is flattened and corrected, making it more comfortable and intuitive for users to read.
[0087] By applying the embodiment of the present invention, a text image to be corrected is obtained, and text line detection is performed on the text image to obtain the designated point position information of multiple characters in each text line of the text image. According to the designated point position information of multiple characters in each text line, the distortion curve of each text line is calculated. Based on the distortion curve of each text line, the text image is corrected and mapped to obtain the corrected text image. By detecting the text lines in the text image, the designated point position information of multiple characters in each text line is obtained. The designated point position information of the characters represents the specific position of the characters in the text image. According to the designated point position information of multiple characters, the distortion curve of each text line can be calculated. The distortion curve represents the distortion of the text line. Based on the distortion of each text line, the originally distorted text image can be corrected to a non-distorted text image through correction mapping, thereby achieving the correction of the distorted text content in the text image and improving the user reading experience.
[0088] based on Figure 1 In the embodiment shown, after the text image is corrected, the embodiment of the present invention can also perform character recognition on the text image, such as Figure 4 As shown, the following steps may be included:
[0089] S401, obtaining a text image to be corrected.
[0090] S402, performing text line detection on the text image to obtain designated point position information of a plurality of characters in each text line of the text image.
[0091] S403: Calculate the distortion curve of each text line according to the designated point position information of the multiple characters in each text line.
[0092] S404, based on the distortion curve of each text line, the text image is corrected and mapped to obtain a corrected text image.
[0093] Steps S401 to S404 in the embodiment of the present invention are Figure 1 The steps S101 to S104 of the illustrated embodiment are the same and will not be described in detail here.
[0094] S405, using character recognition technology to recognize each character in the corrected text image.
[0095] For traditional character recognition technology, such as optical character recognition (OCR) technology, due to the text bending in the text image to be corrected, it is difficult to accurately recognize the characters during character recognition, or the recognition result may be wrong. As shown in Figure 5(a), when character recognition is performed, there is a large difference between the recognition box and the actual character, resulting in the inability to recognize the character or recognition errors.
[0096] In order to improve the accuracy of character recognition results, after executing the text image correction steps provided in the embodiment of the present invention, character recognition technologies such as OCR can be used to recognize the characters in the corrected text image. Since the corrected text image is an image without curvature or an image with very little curvature, character recognition technology can be used to accurately recognize the characters in the image. As shown in Figure 5(b), during character recognition, the recognition box can more accurately cover each corresponding text line, thereby ensuring accurate recognition of the characters in the image.
[0097] Applying the above method embodiment, the present invention also provides a text image correction device, such as Figure 6 As shown, the text image correction device may include:
[0098] An acquisition module 610 is used to acquire a text image to be corrected;
[0099] A detection module 620, configured to perform text line detection on the text image to obtain designated point position information of a plurality of characters in each text line of the text image;
[0100] A calculation module 630, configured to calculate a distortion curve of each text line according to the position information of the designated points of the plurality of characters in each text line;
[0101] The correction module 640 is used to perform correction mapping on the text image based on the distortion curves of the text lines to obtain a corrected text image.
[0102] Preferably, the detection module 620 can be specifically used for:
[0103] Performing document area detection on the text image to obtain detection frame coordinates of the document area in the text image;
[0104] According to the detection frame coordinates, the designated point position information of a plurality of characters in each text line of the document area is detected from the document area.
[0105] Preferably, the calculation module 630 may be specifically used for:
[0106] Construct initialization curve;
[0107] According to the designated point position information of the plurality of characters in each text line, an error value between a first ordinate in the designated point position information and a second ordinate on the initialization curve is calculated, and an error function corresponding to the initialization curve for each text line is constructed, wherein the second ordinate is a ordinate on the initialization curve corresponding to the same abscissa as that in the designated position information;
[0108] According to the error function of each text line corresponding to the initialization curve, the distortion curve of each text line is obtained through curve fitting.
[0109] Preferably, when the calculation module 630 is used to obtain the distortion curve of each text line by curve fitting according to the error function of each text line corresponding to the initialization curve, it can also be used to:
[0110] The error function of each text line corresponding to the initialization curve is minimized to obtain the distortion curve of each text line by fitting.
[0111] Preferably, the correction module 640 can be specifically used for:
[0112] The twisted curves of each text line are combined into a three-dimensional grid to form a twisted surface;
[0113] The distorted surface is mapped to a plane image to obtain a corrected text image.
[0114] Preferably, the device may further include:
[0115] The character recognition module is used to recognize each character in the corrected text image using character recognition technology.
[0116] By applying the embodiment of the present invention, a text image to be corrected is obtained, and text line detection is performed on the text image to obtain the designated point position information of multiple characters in each text line of the text image. According to the designated point position information of multiple characters in each text line, the distortion curve of each text line is calculated. Based on the distortion curve of each text line, the text image is corrected and mapped to obtain the corrected text image. By detecting the text lines in the text image, the designated point position information of multiple characters in each text line is obtained. The designated point position information of the characters represents the specific position of the characters in the text image. According to the designated point position information of multiple characters, the distortion curve of each text line can be calculated. The distortion curve represents the distortion of the text line. Based on the distortion of each text line, the originally distorted text image can be corrected to a non-distorted text image through correction mapping, thereby achieving the correction of the distorted text content in the text image and improving the user reading experience.
[0117] The embodiment of the present invention also provides an electronic device, as shown in FIG. Figure 7 As shown, it includes a processor 701 and a memory 702, wherein,
[0118] The memory 702 is used to store computer programs;
[0119] The processor 701 is used to implement any of the above-mentioned text image correction methods when executing the computer program stored in the memory.
[0120] Data can be transmitted between the memory 702 and the processor 701 via a wired connection or a wireless connection, and the electronic device can communicate with other devices via a wired communication interface or a wireless communication interface.
[0121] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the processor.
[0122] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0123] In this embodiment, the processor of the electronic device can achieve the following by reading the machine executable instructions stored in the machine readable storage medium and running the machine executable instructions: obtaining the text image to be corrected, performing text line detection on the text image, obtaining the designated point position information of multiple characters in each text line of the text image, calculating the distortion curve of each text line according to the designated point position information of multiple characters in each text line, and performing correction mapping on the text image based on the distortion curve of each text line to obtain the corrected text image. By detecting the text line in the text image, the designated point position information of multiple characters in each text line is obtained, and the designated point position information of the character represents the specific position of the character in the text image, then the distortion curve of each text line can be calculated according to the designated point position information of multiple characters, and the distortion curve represents the distortion of the text line. Based on the distortion of each text line, through correction mapping, the originally distorted text image can be corrected to a non-distorted text image, thereby realizing the correction of the distorted text content in the text image and improving the user reading experience.
[0124] In addition, the present invention also provides a computer-readable storage medium, in which a computing program is stored. When the computing program is executed by a processor, any of the above-mentioned text image correction methods is implemented.
[0125] In this embodiment, the machine-readable storage medium stores a machine computer program that executes the text image correction method provided by the embodiment of the present invention at runtime, so that the following can be achieved: obtaining the text image to be corrected, performing text line detection on the text image, obtaining the designated point position information of multiple characters in each text line of the text image, calculating the distortion curve of each text line based on the designated point position information of multiple characters in each text line, and performing correction mapping on the text image based on the distortion curve of each text line to obtain the corrected text image. By detecting the text line in the text image, the designated point position information of multiple characters in each text line is obtained. The designated point position information of the character represents the specific position of the character in the text image. Then, according to the designated point position information of multiple characters, the distortion curve of each text line can be calculated. The distortion curve represents the distortion of the text line. Based on the distortion of each text line, through correction mapping, the originally distorted text image can be corrected to a non-distorted text image, thereby realizing the correction of the distorted text content in the text image and improving the user reading experience.
[0126] The embodiment of the present invention also provides a display system, such as Figure 8 As shown, it includes a display screen 801 and an electronic device 802, wherein:
[0127] The display screen 801 is used to display the text image to be corrected;
[0128] The electronic device 802 is used to implement the following steps:
[0129] Get the text image to be corrected;
[0130] Performing text line detection on the text image to obtain designated point position information of a plurality of characters in each text line of the text image;
[0131] Calculating the distortion curve of each text line according to the designated point position information of the plurality of characters in each text line;
[0132] Based on the distortion curves of the text lines, the text image is corrected and mapped to obtain a corrected text image.
[0133] Optionally, the electronic device 802 may also implement any of the above-mentioned text image correction methods during operation.
[0134] By applying the embodiment of the present invention, a text image to be corrected is obtained, and text line detection is performed on the text image to obtain the designated point position information of multiple characters in each text line of the text image. According to the designated point position information of multiple characters in each text line, the distortion curve of each text line is calculated. Based on the distortion curve of each text line, the text image is corrected and mapped to obtain the corrected text image. By detecting the text lines in the text image, the designated point position information of multiple characters in each text line is obtained. The designated point position information of the characters represents the specific position of the characters in the text image. According to the designated point position information of multiple characters, the distortion curve of each text line can be calculated. The distortion curve represents the distortion of the text line. Based on the distortion of each text line, the originally distorted text image can be corrected to a non-distorted text image through correction mapping, thereby achieving the correction of the distorted text content in the text image and improving the user reading experience.
[0135] As for the electronic device, machine-readable storage medium and display system embodiments, since the method contents involved are basically similar to the aforementioned method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.
[0136] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0137] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device, electronic device, machine-readable storage medium, and display system embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.
[0138] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.
Claims
1. A text image correction method, characterized in that: The method comprises: Get the text image to be corrected; Performing text line detection on the text image to obtain designated point position information of multiple characters in each text line of the text image; wherein the designated point position information of the character is: position information of the midpoint of the bottom of the character, or position information of the midpoint of the top of the character, or position information of the center point of the character; Calculating the distortion curve of each text line according to the designated point position information of the plurality of characters in each text line; Based on the distortion curves of the text lines, correction mapping is performed on the text image to obtain a corrected text image; The step of calculating the distortion curve of each text line according to the designated point position information of the plurality of characters in each text line comprises: Construct initialization curve; According to the designated point position information of the plurality of characters in each text line, an error value between a first ordinate in the designated point position information and a second ordinate on the initialization curve is calculated, and an error function corresponding to the initialization curve for each text line is constructed, wherein the second ordinate is a ordinate on the initialization curve corresponding to the same abscissa as that in the designated point position information; According to the error function of each text line corresponding to the initialization curve, a distortion curve of each text line is obtained by curve fitting; wherein the distortion curve represents the distortion of the text line; The step of obtaining the distortion curve of each text line by curve fitting according to the error function of each text line corresponding to the initialization curve comprises: The initialization curve corresponding to each text line is represented by an equation, an error function corresponding to each text line to the initialization curve is minimized to obtain parameters of the equation, and the distortion curve of each text line is obtained by fitting according to the parameters of the equation.
2. The method according to claim 1, characterized in that The performing text line detection on the text image to obtain the designated point position information of a plurality of characters in each text line of the text image includes: Performing document area detection on the text image to obtain detection frame coordinates of the document area in the text image; According to the detection frame coordinates, the designated point position information of a plurality of characters in each text line of the document area is detected from the document area.
3. The method according to claim 1, characterized in that The step of performing correction mapping on the text image based on the distortion curves of each text line to obtain a corrected text image includes: The twisted curves of each text line are combined into a three-dimensional grid to form a twisted surface; The distorted surface is mapped to a plane image to obtain a corrected text image.
4. The method according to claim 1, characterized in that: After performing correction mapping on the text image based on the distortion curves of the text lines to obtain a corrected text image, the method further includes: Character recognition technology is used to recognize each character in the corrected text image.
5. A text image correction device, characterized in that: The device comprises: An acquisition module is used to acquire the text image to be corrected; A detection module, used to perform text line detection on the text image to obtain the designated point position information of multiple characters in each text line of the text image; wherein the designated point position information of the character is: the position information of the midpoint of the bottom of the character, or the position information of the midpoint of the top of the character, or the position information of the center point of the character; A calculation module, used for calculating the distortion curve of each text line according to the designated point position information of multiple characters in each text line; A correction module, used for performing correction mapping on the text image based on the distortion curve of each text line to obtain a corrected text image; The computing module is specifically used for: Construct initialization curve; According to the designated point position information of the plurality of characters in each text line, an error value between a first ordinate in the designated point position information and a second ordinate on the initialization curve is calculated, and an error function corresponding to the initialization curve for each text line is constructed, wherein the second ordinate is a ordinate on the initialization curve corresponding to the same abscissa as that in the designated point position information; According to the error function of each text line corresponding to the initialization curve, a distortion curve of each text line is obtained by curve fitting; wherein the distortion curve represents the distortion of the text line; When the calculation module is used to obtain the distortion curve of each text line by curve fitting according to the error function of each text line corresponding to the initialization curve, it is specifically used to: The initialization curve corresponding to each text line is represented by an equation, an error function corresponding to each text line to the initialization curve is minimized to obtain parameters of the equation, and the distortion curve of each text line is obtained by fitting according to the parameters of the equation.
6. The device according to claim 5, characterized in that The detection module is specifically used for: Performing document area detection on the text image to obtain detection frame coordinates of the document area in the text image; According to the detection frame coordinates, the designated point position information of a plurality of characters in each text line of the document area is detected from the document area.
7. The device according to claim 5, characterized in that The correction module is specifically used for: The twisted curves of each text line are combined into a three-dimensional grid to form a twisted surface; The distorted surface is mapped to a plane image to obtain a corrected text image.
8. The device according to claim 5, characterized in that The device also includes: The character recognition module is used to recognize each character in the corrected text image using character recognition technology.
9. An electronic device, characterized in that: comprising a processor and a memory, wherein: The memory is used to store computer programs; The processor is used to implement the steps of the method described in any one of claims 1 to 4 when executing the computer program stored in the memory.
10. A machine-readable storage medium, characterized in that: The machine-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 4 are implemented.
Citation Information
Patent Citations
Inclination angle correcting method of text image, page layout analysis method of text image, vision assistant device and vision assistant system
CN105989366A
Curved deformed text page image correction method
CN106778739A
Character recognition method and device, storage medium and electronic equipment
CN108885699A
Document correction method, document correction apparatus, document printer, image for error detection, and computer program
JP2017182195A
Imaged page warp correction
US20100225937A1
