Digital visual restoration system and method
Through the digital visual restoration system, the problem of traditional OCR technology being unable to recognize the text details of ancient books is solved, the visual restoration and editing of texts is realized, the reading experience and management efficiency are improved, and it is suitable for the digitization of ancient books in multiple languages.
Patent Information
- Application Number
- CN202310557343.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2022-08-03
- Filing Date
- 2023-05-17
- Publication Date
- 2024-10-22
AI Technical Summary
Traditional OCR technology cannot effectively identify and restore the font, size, color, background color, sentence position and other information of ancient books and other texts, resulting in the loss of information during the digitization process and affecting the reading experience, and the existing technology is inefficient in full-text copying and retrieval.
Provides a digital visual restoration system, including a restoration module and an editing module. The text recognized through OCR is displayed according to the original file layout, and allows editing and modification of text content and layout. It supports dual layout and online translation, and can copy and Export to multiple formats.
It achieves perfect visual restoration of ancient books and other texts, solves the problem of losing page layout effects after traditional OCR recognition, improves the reading experience, and supports copying, editing, search and multi-format export, and is suitable for various languages.
Smart Images

Figure CN118823802A_ABST
Abstract
Description
Technical Field
[0001] The present invention specifically relates to a digital visual restoration system and method. Background Art
[0002] Traditional digitization generally involves scanning the original into electronic images or PDF documents, or manually inputting and typesetting by editors to generate digital files. The former is only stored in the form of images and cannot copy or retrieve the content, while the latter requires manual input, which is costly, time-consuming and inefficient.
[0003] Traditional OCR technology, through binarization and horizontal projection, vertical projection and single-word feature library, can solve the recognition of most Chinese characters and Latin characters. However, most traditional OCR systems do not support or support only a few single characters and have low recognition accuracy.
[0004] In addition, ancient books and documents such as the palm leaf sutra and the long strip sutra were written on a variety of materials such as palm leaves, wolfsbane Tibetan paper, and blue-brown paper. On the one hand, different colors of paper were used to distinguish different document contents. On the other hand, precious materials such as gold, silver, red coral, pearl, agate, turquoise, white conch, mangrove sap, and cinnabar were widely used to write texts of different colors, fonts, and sizes in addition to ink to express the connotation of the text content. Traditional OCR technology cannot record these text fonts, text size (font size), text color, background color, sentence position (coordinates), and other information. The digitization process will lead to the loss of various information other than the text content and the inability to achieve visual restoration.
[0005] When Tibetan, Dzongkha and other scripts are wrapped in a sentence, several ' / ' are required according to grammatical specifications. As line break symbols, when copying the text content of the OCR recognition result, removing the line breaks will cause these symbols to remain in the text content and become erroneous noise.
[0006] Some PDF reader tool software has built-in text OCR function, which can recognize some text, but you can only manually select a paragraph or a few sentences for OCR. The accuracy of the recognition result is relatively low, and it cannot recognize the entire text, copy the full text, or search the full text. It does not have the ability of automatic proofreading and manual proofreading.
[0007] In the prior art, the OCR recognition results are generally displayed in the order of sentences. If the restoration process is not performed, when users read the OCR recognized file, the missing layout will affect the understanding of the content and the readability will be poor.
[0008] If you use canvas to restore the layout, although you can achieve a certain effect, the output content cannot be selected or copied, so the recognition result is still meaningless. Summary of the invention
[0009] In view of the above situation, in order to overcome the defects of the prior art, the present invention provides a digital visual restoration system and method.
[0010] In order to achieve the above object, the present invention provides the following technical solutions:
[0011] A digital visual restoration system, comprising a restoration module and an editing module.
[0012] The restoration module is configured to display the text recognized by OCR in the format of the original file;
[0013] The editing module is configured to compare the original document content and format with the text content and format after OCR recognition, and allows the text content and format after OCR recognition to be edited and modified.
[0014] The visual restoration system can be used for digital visual restoration of books, newspapers, magazines, documents, files, etc.
[0015] Furthermore, the restoration module is configured to present a double-page layout of the text page recognized by OCR and the original file page.
[0016] Furthermore, the double-page layout adopts an arrangement of upper and lower pages or an arrangement of left and right pages.
[0017] Furthermore, the restoration module includes a visual restoration unit, a sentence display unit, a paragraph display unit, an online translation unit and a Latin transcription unit.
[0018] Furthermore, in the editing module, it is allowed to edit and modify the text font, text size, text color, book background color, text direction, sentence position, header and footer, and recognition content of the text after OCR recognition.
[0019] A method for visual restoration of digital ancient books, which can be embedded in the visual restoration system described above, comprises the following steps:
[0020] (1) The OCR recognition result contains the absolute coordinates of a sentence on the page, according to x min x max ,y min y max Mark to form the absolute position rectangle of the sentence;
[0021] (2) When displaying, there will be a difference between the width of the display page and the width of the book, and the width of the display area is obtained;
[0022] (3) Compare the actual pixels of the book page with the width of the display area to obtain the zoom ratio; display area width / actual pixels of the book page=zoom ratio;
[0023] (4) Through (x max –x min )*zoom ratio, get the width of the new rectangle; through (y max –y min )*zoom ratio, get the height of the rectangle;
[0024] (5) The collision is calculated by adjusting the font size of the text in the text box and calculating the width difference between the text's own container and the parent container. If the text area is within the rectangle, it is considered correct.
[0025] Furthermore, in step (5), the properties of the two rectangles are obtained through the getComputedStyle() method, and the two property values of clientWidth and ScollerWidth are compared until the result is consistent.
[0026] A computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor can implement the steps of the above-mentioned method for digital visual restoration of ancient books when executing the computer program.
[0027] A computer-readable storage medium stores a computer program, which, when executed by a processor, can implement the steps of the above-mentioned method for digital visual restoration of ancient books.
[0028] The beneficial effects of the present invention are:
[0029] (1) The visual restoration method of the present invention can perfectly restore the original reading experience of the book, solving the problem that after traditional OCR recognition, the page layout effect is lost, affecting the reading experience. The visual restoration method of the present invention can be applied to various languages, such as Tibetan, Khmer, etc. The text after visual restoration in the present invention can be copied, edited, searched, translated, and exported into Word, PDF, image and other formats, which is convenient for digital management and storage of books.
[0030] (2) Due to the reliance on OCR recognition results, when the recognized coordinates are not very accurate, page restoration may be affected. The present invention adds an editing module, which can visually adjust the text font, text size (font size), text color, book background, text direction, sentence position (coordinates), header and footer, recognized content, etc. during the proofreading process, just like Word. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] Figure 1 This is a schematic diagram of a double-page layout.
[0032] Figure 2 It is a schematic diagram of the text in the proofreading state after visual restoration.
[0033] Figure 3 It is a flow chart of the digital visual restoration method of ancient books.
[0034] Figure 4 It is a schematic diagram of the text being edited after visual restoration.
[0035] Figure 5 This is a schematic diagram marked with a red frame during the visual restoration process. The red frame is the absolute position rectangle of the sentence (the left picture (a) is the original file image, and the right picture (b) is the text during the visual restoration process).
[0036] Figure 6 It is a schematic diagram of adjusting the font size of the text in the text box until the text area is within the red rectangle (the upper figure a shows that the text area is outside the red rectangle, and the lower figure b shows that the text area is within the red rectangle).
[0037] Figure 7 It is a schematic diagram of computer equipment.
[0038] Figure 8 It is a schematic diagram of text after OCR recognition but not visual restoration, where the left picture (a) is the original file image, and the right picture (b) is the text after OCR recognition but not visual restoration.
[0039] Fig. 9 It is a schematic diagram of the text after OCR recognition and visual restoration, where the left picture (a) is the original file image and the right picture (b) is the text after visual restoration. DETAILED DESCRIPTION
[0040] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is described and illustrated below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. Based on the embodiments provided in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.
[0041] Reference to "embodiments" in this application means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those of ordinary skill in the art that the embodiments described in this application may be combined with other embodiments without conflict.
[0042] Unless otherwise defined, the technical terms or scientific terms involved in this application should be understood by people with ordinary skills in the technical field to which this application belongs. The words "one", "a", "a", "the" and the like involved in this application do not indicate a quantitative limitation and may represent the singular or plural. The terms "include", "comprise", "have" and any of their variations involved in this application are intended to cover non-exclusive inclusions; the words "connect", "connected" and the like involved in this application are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The "multiple" involved in this application means greater than or equal to two. "And / or" describes the association relationship of associated objects, indicating that there may be three relationships. For example, "A and / or B" can represent: A exists alone, A and B exist at the same time, and B exists alone. The terms "first", "second", "third" and the like involved in this application are only used to distinguish similar objects and do not represent a specific ordering of objects.
[0043] Example 1
[0044] A digital visual restoration system includes a restoration module and an editing module, wherein the restoration module is connected to the editing module;
[0045] The restoration module is configured to display the text recognized by OCR in the format of the original file;
[0046] The editing module is configured to compare the text content and layout after OCR recognition with the original file content and layout, and allows the text content and layout after OCR recognition to be edited and modified.
[0047] The visual restoration system can be used for digital visual restoration of books, newspapers, magazines, literature, documents, archives, etc.
[0048] In some embodiments, the editing module is configured to compare the text content and layout restored by the restoration module with the original file content and layout, allowing the restored text content and layout to be edited and modified, such as Figure 2 shown.
[0049] In some preferred embodiments, the restoration module is configured to present a double layout of the text page recognized by OCR and the original file page. The original file here refers to books, newspapers, magazines, documents, files, etc. in PDF format or image format.
[0050] In some preferred methods, the dual layout can be a layout of two upper and lower layouts or a layout of two left and right layouts. The dual layout can display the restored text and the original file on the same plane or screen, which is conducive to comparison and proofreading. Specifically, the aspect ratio of the page is first calculated; if the height is greater than the width, the left and right layout is used, otherwise the upper and lower layout is used. Figure 1 As shown, the layout is in two pages, left and right.
[0051] In some preferred methods, the two layouts can be linked, and when the restored text sentence is selected, the corresponding sentence in the original layout is selected and marked. The original image and the visually restored text are marked synchronously through the coordinate position recognized by OCR to form a comparison relationship.
[0052] In some preferred embodiments, the restoration module includes some functional units, such as a visual restoration unit, a sentence display unit, a paragraph display unit, an online translation unit, a Latin transliteration unit, etc. By analyzing the semantics, such as the Tibetan The usage rules of characters such as , can be used to judge single words, sentences, and process the paragraph division parameters in the OCR recognition results, so that display by sentence or by paragraph can be achieved. Figure 1 As shown, if you select the Visual Restore option, the layout after visual restoration will be displayed. If you select the Display by Sentence option, the page will be displayed in a sentence-by-sentence mode; if you select the Display by Paragraph option, the page will be displayed in a paragraph-by-paragraph mode. When copying the text content of the OCR recognition result, you can avoid line breaks remaining in the text content as error noise.
[0053] In some preferred embodiments, Figure 2As shown, in the editing module, the text font, text size (font size), text color, book background color, text direction, sentence position (coordinates), header and footer, and recognition content of the text can be edited and modified.
[0054] like Figure 3 As shown, a method for digital visual restoration of ancient books, which can be embedded in the above-mentioned visual restoration system, includes the following steps:
[0055] (1) The OCR recognition result includes the absolute coordinate value of the page where the sentence is located. min x max ,y min y max Mark. Figure 5 As shown, the red box is the absolute position rectangle where the sentence is located.
[0056] (2) When displaying, there will be a difference between the width of the browser page and the width of the book, so it is necessary to obtain the width of the display area, such as Figure 5 The red area shown in the example is a display area with a width of 550px.
[0057] (3) Compare the actual page pixels with the width of the browser display area to obtain the zoom ratio. (Browser display area width / page actual pixels) = zoom ratio;
[0058] (4) Through (x max –x min )*zoom ratio to get the width of the new rectangle. max –y min )*zoom ratio to get the height of the rectangle.
[0059] (5) The collision is calculated by adjusting the font size of the text in the text box and calculating the width difference between the text's own container and the parent container. If the text area is within the red rectangle, it is considered correct. Figure 6 (b) This method obtains the properties of the two squares through the browser's getComputedStyle() method, and compares the two property values of clientWidth and ScollerWidth until the result is consistent.
[0060] In the present invention, a rectangle is drawn based on the coordinate positioning, text direction, text color, etc. of each sentence in the OCR recognition result, and is scaled proportionally according to the size of the page. At the same time, in order to ensure that the text size is within the coordinate range, the text is reduced from large to small until it is reduced to the rectangular range, so as to restore the typesetting display effect of the original book. Figure 1 As shown, the left side is the original book image, and the right side is the visually restored version.
[0061] Since it relies on OCR recognition results, when the recognized coordinates are not very accurate, page restoration may be affected. The present invention adds an editing module, which can perform visual editing and modification of text fonts, text size (font size), text color, book background color, text direction, recognition content, etc. during the proofreading process, just like Word. Figure 2 shown.
[0062] In the prior art, the OCR recognition results are generally displayed in the order of sentences. If the restoration process is not performed, when the user reads the layout after OCR, the missing layout will affect the understanding of the content, and the content of the page cannot be understood at all in the recognition result. In the present invention, after the visual restoration process, the readability is significantly enhanced.
[0063] The present invention uses the CSS absolute positioning attribute with very good compatibility with web browsers to achieve visual restoration. Compared with the system that uses Canvas to restore, the restored area content can be directly selected and copied. Even in a browser with a translation function, the translation operation can be directly performed, such as Figure 4 shown.
[0064] The method in the present invention can perfectly restore the original reading experience of the book, getting rid of the problem that after traditional OCR recognition, the page layout effect is lost, which affects the reading experience. At the same time, visual restoration can be achieved in a similar way for various languages. The present invention has made the following optimizations for the special writing habits of Tibetan:
[0065] 1) According to the position of the top left corner of the line head, the Y axis of the entire line of text is adjusted, including but not limited to other sentences in the current line. The Y axis is adjusted to the same height as the beginning of the sentence, and judged by the coordinates in the recognition result. If there is an overlap, it will move downward, which can effectively solve the skew caused by lens distortion.
[0066] 2) Based on the identification information in the OCR recognition result, the header is displayed, such as generating identification lines of different lengths according to the width of the page content. According to the position and size of the header text, a corresponding identification line is generated. Even according to the type of book, a vertical header is generated.
[0067] 3) Export to Word, PDF, images, etc. to facilitate digital management and storage of books.
[0068] Example 2
[0069] In some embodiments, the visual restoration system further includes an OCR recognition module for performing text recognition on the input image. The OCR recognition module may adopt a conventional OCR recognition method in the prior art.
[0070] In some embodiments, the OCR recognition module adopts an OCR recognition method, which is used to perform text recognition on the input image, including a detection step and a text recognition step. The OCR recognition method can be used not only for Brahmi characters, such as Tibetan, but also for recognizing other characters, such as Chinese.
[0071] The detection steps include:
[0072] 1. Input image, the image enters the detection module;
[0073] 2. The detection module describes the text area in the image in the form of polygon vertex coordinates;
[0074] 3. Extract the described text area map and transform it to obtain a regular shape image;
[0075] The steps of text recognition include:
[0076] 4. Pass the polygonal image into the recognition module to obtain text data;
[0077] Among them, a first backbone neural network for extracting image features is provided in the detection module, and a second backbone neural network is provided in the recognition module.
[0078] Further, step 2 includes:
[0079] 2.1 Use the first backbone neural network to extract image features;
[0080] 2.2 Based on the image features extracted by the first backbone neural network, the detection neural network is used to find the binary image of the text area;
[0081] 2.3 Process the binary image of the text area and extract the coordinates of the polygon vertices.
[0082] Furthermore, the first backbone neural network is
[0083] FPN neural network, detection neural network is optional, including DB neural network, EAST neural network, SAST neural network.
[0084] Further, step 3 includes:
[0085] 3.1 According to the polygon vertex coordinates obtained in step 2, use the Sklansky convex hull algorithm to extract the convex hull of the polygon vertex set;
[0086] 3.2 Use the shoelace algorithm to calculate the area of the original polygon and the area of the convex hull;
[0087] 3.3 Obtain R by dividing the area of the original polygon by the area of the convex hull;
[0088] 3.4 Determine whether the text area is rectangular text or curved text based on the value of R, and implement different polygon processing algorithms;
[0089] 3.5 Implement different operations according to the judgment result;
[0090] In steps 3 and 4, by comparing R with the preset text comparison value C, it is determined whether it is rectangular text or curved text. When R > C, it is determined as a rectangular text area; when R < C, it is determined as a curved text area. In step 3.5, the different operations implemented are different two-dimensional transformations, and the two-dimensional transformations include but are not limited to affine transformation, rigid body transformation, projection transformation, and tps transformation.
[0091] Further, when the first backbone neural network selects the FPN neural network, step 2.1 includes:
[0092] 2.1.1 Image scaling;
[0093] 2.1.2 Extract image features;
[0094] Specifically, for 2.1.2 to extract image features: First, a bottom-up sub-network calculates feature maps of N sizes (N ≥ 2), then a top-down sub-network and horizontal connections gradually restore the sizes of the feature maps, and the concat operation is used to fuse the features of all sizes together to obtain the feature map.
[0095] Further, when the detection neural network is the DB neural network, step 2.2 is:
[0096] 2.2 Based on the image features extracted by the FPN network, the DB neural network calculates a value between [0, 1] at each pixel position of the feature map extracted in step 2.1.2, and compares it with the preset feature comparison value B. Pixels with a value greater than B are determined as text areas, and pixels with a value less than B are determined as non-text areas, thereby obtaining a binary image;
[0097] Step 2.3 is:
[0098] 2.3 Perform connected component analysis on the binary image of the text area, extract the contours based on the connected regions, and finally find the polygon vertex coordinates of the text area.
[0099] Further, the second backbone neural network is
[0100] Optionally, it includes a CRNN convolutional recurrent neural network structure, or a RARE neural network, or a SAR neural network;
[0101] When the second backbone neural network uses CRNN, the text recognition steps include:
[0102] 4.1 Using the second backbone neural network, the polygonal image obtained by the detection module is compressed into a high-dimensional feature sequence; 4.2 The high-dimensional feature sequence output by the second backbone neural network is decoded to obtain the final text information. Further, step 4.1 includes:
[0103] 4.1.1 Image scaling;
[0104] 4.1.2CNN extraction extracts sequence features;
[0105] 4.1.3RNN enhances sequence features;
[0106] Step 4.2 includes:
[0107] 4.2.1 Calculate the component index with the highest probability at each position and obtain the same index as the number of positions;
[0108] 4.2.2 If adjacent indices in different indices are equal, they need to be collapsed into one;
[0109] 4.2.3 Delete the index used to express blank characters in the index sequence;
[0110] 4.2.4 The index sequence is mapped into a text sequence according to the dictionary.
[0111] Furthermore, the method further comprises step 5:
[0112] 5. The detection results and recognition results are packaged and output.
[0113] An OCR recognition system includes a detection module and a text recognition module. The detection module is used to identify the text area on the input image and extract it, and the text recognition module is used to recognize the extracted text area; the detection module and the text recognition module can respectively perform the above-mentioned detection steps and / or text recognition steps.
[0114] Example 3, refer to the attached Figure 7 .
[0115] In this embodiment, a computer device 100 is provided, including a memory 102, a processor 101, and a computer program 103 stored in the memory 102 and executable on the processor 101. When the processor 101 executes the computer program 103, the steps of the method for digital visual restoration of ancient books provided in the above-mentioned embodiment 1 can be implemented.
[0116] Example 4
[0117] In this embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the method for digital visual restoration of ancient books provided in the above-mentioned embodiments can be implemented.
[0118] In this embodiment, the computer program may be the computer program in Embodiment 3.
[0119] In this embodiment, the computer-readable storage medium can be executed by the computer device in Embodiment 3.
[0120] Those skilled in the art can understand that all or part of the processes in the above embodiments can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided by the present invention can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0121] Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
Claims
1. A digital visual restoration system, characterized in that: Including restore module and edit module, The restoration module is configured to display the text recognized by OCR in the format of the original file; The editing module is configured to compare the original document content and format with the text content and format after OCR recognition, and allows the text content and format after OCR recognition to be edited and modified.
2. A digital visual restoration system according to claim 1, characterized in that: The restoration module is configured to also present a double-page layout of the text page recognized by OCR and the original file page.
3. A digital visual restoration system according to claim 1, characterized in that: The double-page layout adopts an arrangement of upper and lower pages or an arrangement of left and right pages.
4. A digital visual restoration system according to claim 2, characterized in that: The restoration module includes but is not limited to a visual restoration unit, a sentence display unit, a paragraph display unit, an online translation unit, and a Latin transcription unit.
5. A digital visual restoration system according to claim 1, characterized in that: In the editing module, you can edit and modify the font, size, color, background color, direction, sentence position, header and footer, and recognized content of the text after OCR recognition.
6. A method for digital visual restoration of ancient books, characterized in that: The method can be embedded in the visual restoration system according to any one of claims 1 to 5, comprising the following steps: (1) The OCR recognition result contains the absolute coordinates of a sentence on the page, according to x min x max ,y min y max Mark to form the absolute position rectangle of the sentence; (2) When displaying, there will be a difference between the width of the display page and the width of the book, and the width of the display area is obtained; (3) Compare the actual pixels of the book page with the width of the display area to obtain the zoom ratio; display area width / actual pixels of the book page=zoom ratio; (4) Through (x max –x min )*zoom ratio, get the width of the new rectangle; through (y max –y min )*zoom ratio, get the height of the rectangle; (5) The collision is calculated by adjusting the font size of the text in the text box and calculating the width difference between the text's own container and the parent container. If the text area is within the rectangle, it is considered correct.
7. The method for digitalizing and visually restoring ancient books according to claim 6 is characterized in that: In step (5), the properties of the two rectangles are obtained through the getComputedStyle() method, and the clientWidth and ScollerWidth property values are compared until the result is consistent.
8. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, it can implement the steps in the method for digital visual restoration of ancient books described in any one of claims 6-7.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, it can implement the steps in the method for digital visual restoration of ancient books described in any one of claims 6-7.
