Document image optimization methods and media
By constructing and training a fully convolutional network model and optimizing the document images collected by the high-definition camera, the problem of image quality affected by environmental factors is solved and the image quality is improved.
Patent Information
- Application Number
- CN202210869162.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-21
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2042-07-21
AI Technical Summary
Document images collected by high-definition cameras are easily affected by environmental factors, resulting in uneven brightness, shadows and black edges in the background, and unsatisfactory image quality.
By acquiring the original image collected by the high-definition camera and the reference image collected by the scanner, a training data pair is constructed, a fully convolutional network model is trained, the network parameters are optimized to generate the final image optimization model, and the document image to be optimized is corrected and edge-edited. , output the final document image.
It realizes automatic optimization of document images collected by high-speed cameras, reduces the impact of environmental factors on image quality, and improves image quality.
Smart Images

Figure CN115273114B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to a document image optimization method and a computer-readable storage medium. Background Art
[0002] The high-resolution camera is a portable and low-carbon office product that uses a high-resolution sensor and is equipped with a high-definition lens. It is often used for image capture of paper documents.
[0003] In the related art, since the environment (for example, lighting conditions) in which the high-speed scanner collects images is uncontrollable and the document position is not fixed, the quality of the final collected image is not ideal due to environmental factors; specifically, the final image has uneven brightness, background shadows, black edges, etc. Therefore, how to reduce the impact of environmental factors on the quality of the final image and improve the quality of the final image has become one of the urgent problems to be solved by the high-speed scanner. Summary of the invention
[0004] The present invention aims to solve at least one of the technical problems in the above-mentioned technology to a certain extent. To this end, one purpose of the present invention is to propose a document image optimization method, which can automatically optimize the document image collected by the high-speed scanner to reduce the impact of environmental factors on the image quality and improve the final image quality.
[0005] A second object of the present invention is to provide a computer-readable storage medium.
[0006] To achieve the above-mentioned purpose, the first aspect of the present invention proposes a document image optimization method, comprising the following steps: obtaining an original image and a corresponding reference image, wherein the original image is a document image originally captured by a scanner, and the reference image is a document image captured by a scanner; constructing a training data tuple based on the original image and the corresponding reference image, and training a model based on the training data tuple, and optimizing network parameters based on an objective function until convergence during the training process to obtain a final image optimization model; obtaining a document image to be optimized, and correcting the document image to be optimized, and inputting the corrected document image to be optimized into the final image optimization model to output a final document image through the final image optimization model.
[0007] According to the document image optimization method of the embodiment of the present invention, first, an original image and a corresponding reference image are obtained, wherein the original image is a document image originally captured by a high-speed scanner, and the reference image is a document image captured by a scanner; then, a training data tuple is constructed according to the original image and the corresponding reference image, and a model is trained according to the training data tuple, and in the training process, network parameters are optimized based on the objective function until convergence to obtain a final image optimization model; then, the document image to be optimized is obtained, and the document image to be optimized is corrected, and the corrected document image to be optimized is input into the final image optimization model to output the final document image through the final image optimization model; thereby, automatic optimization of the document image captured by the high-speed scanner is achieved to reduce the impact of environmental factors on image quality and improve the final image quality.
[0008] In addition, the document image optimization method proposed in the above embodiment of the present invention may also have the following additional technical features:
[0009] Optionally, constructing a training data tuple based on the original image and the corresponding reference image includes: acquiring a mapping relationship between the original image and the corresponding reference image through image registration, and cropping the original image to obtain an original sub-image, and cropping the corresponding reference image according to the mapping relationship to obtain a reference sub-image; constructing a training data tuple based on the original sub-image and the reference sub-image.
[0010] Optionally, the objective function is expressed by the following formula:
[0011]
[0012] Where N represents the number of training data pairs. Indicates The original graph of training data pairs, Indicates The target graph of training data pairs, represents the matrix bi-norm, Represents the threshold parameter.
[0013] Optionally, the final image optimization model is composed of a fully convolutional network, wherein the fully convolutional network includes a convolutional layer and a transposed convolutional layer;
[0014] Among them, the activation function of the last layer of neurons in the fully convolutional network is:
[0015]
[0016] in, represents a constant greater than 1, Represents the input of the activation function.
[0017] Optionally, the document image to be optimized is corrected, including: calculating an X-axis gradient map and a Y-axis gradient map corresponding to the document image to be optimized, and generating a gradient intensity map based on the X-axis gradient map and the Y-axis gradient map; calculating an average value and a standard deviation of the gradient intensity of each pixel in the document image to be optimized, and determining a gradient intensity threshold based on the average value and the standard deviation, and binarizing the gradient intensity map based on the gradient intensity threshold to obtain an edge image; and filtering each pixel point with a value of 1 in the edge image to obtain a final edge image.
[0018] Optionally, the filtering process includes:
[0019] If x is less than / 2, abs(Gx(x, y)) is greater than abs(Gy(x, y)), and Gx(x, y) is less than 0, then the value of the pixel in the edge map is set to 0;
[0020] If x is greater than / 2, abs(Gx(x, y)) is greater than abs(Gy(x, y)), and Gx(x, y) is greater than 0, then the value of the pixel in the edge map is set to 0;
[0021] If y is less than / 2, abs(Gx(x, y)) is less than abs(Gy(x, y)), and Gy(x, y) is less than 0, then the value of the pixel in the edge map is set to 0;
[0022] If y is greater than / 2, abs(Gx(x, y)) is less than abs(Gy(x, y)), and Gy(x, y) is greater than 0, then the value of the pixel in the edge map is set to 0;
[0023] Where x represents the X-axis coordinate value of the pixel currently being processed, and y represents the Y-axis coordinate value of the pixel currently being processed. Indicates the width of the document image to be optimized. Represents the height of the document image to be optimized, Gx(x, y) represents the X-axis gradient of the pixel currently being processed, and Gy(x, y) represents the Y-axis gradient of the pixel currently being processed.
[0024] Optionally, correcting the document image to be optimized also includes: dilating the final edge image, and performing connected domain analysis on the final edge image after the dilation process to obtain the maximum connected domain, and calculating the minimum rotated circumscribed rectangle of the maximum connected domain; calculating the area to which each edge of the document in the document image to be optimized belongs according to the minimum rotated circumscribed rectangle, and performing Hough transform detection on the area to which each edge belongs based on the final edge image to obtain the straight line equation of each edge; calculating the coordinates of the four corner points of the document in the document image to be optimized according to the straight line equation of each edge, and calculating the width and height of the document according to the coordinates of the four corner points, and creating a new image according to the width and height values; calculating an affine transformation matrix, and mapping the coordinates of the four corner points of the document in the document image to be optimized to the four corner points of the new image, and intercepting the corresponding area in the document image to be optimized according to the affine transformation matrix to obtain a document area image.
[0025] Optionally, correcting the document image to be optimized also includes: binarizing the document area image to obtain a binarized document image; obtaining structural element size information, and determining the target image size based on the structural element size information and the binarized document image size information, and copying the binarized document image to the target image; performing morphological closing operation on the copied target image based on the structural element, and copying the relevant area in the target image after the closing operation to the binarized document image; searching for a connected domain with a pixel value of 0 at the edge of the copied binarized document image; obtaining the first coordinate value of any pixel point in the connected domain with a pixel value of 0, and searching for the second coordinate value of the non-zero pixel point that is closest to the current pixel point, and setting the pixel value of the pixel point with the second coordinate value in the document area image to the pixel value of the pixel point with the first coordinate value.
[0026] To achieve the above objectives, a second aspect of the present invention provides a computer-readable storage medium on which a document image optimization program is stored. When the document image optimization program is executed by a processor, the document image optimization method as described above is implemented.
[0027] According to the computer-readable storage medium of an embodiment of the present invention, by storing a document image optimization program, the processor implements the document image optimization method as described above when executing the document image optimization program, thereby realizing automatic optimization of the document image captured by the high-speed scanner, so as to reduce the impact of environmental factors on the image quality and improve the final image quality. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 Schematic diagram of the process of a document image optimization method according to an embodiment of the present invention. DETAILED DESCRIPTION
[0029] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present invention, and should not be construed as limiting the present invention.
[0030] In the related art, the final image captured by the high-speed scanner is easily affected by environmental factors, resulting in uneven brightness of the final image, shadows in the background, and redundant edges. According to the document image optimization method of an embodiment of the present invention, first, an original image and a corresponding reference image are obtained, wherein the original image is a document image originally captured by the high-speed scanner, and the reference image is a document image captured by a scanner. Then, a training data tuple is constructed according to the original image and the corresponding reference image, and a model is trained according to the training data tuple. During the training process, network parameters are optimized based on the objective function until convergence to obtain a final image optimization model. Then, the document image to be optimized is obtained, and the document image to be optimized is corrected and de-edged, and the corrected document image to be optimized is input into the final image optimization model to output the final document image through the final image optimization model. Thereby, automatic optimization of the document image captured by the high-speed scanner is realized to reduce the influence of environmental factors on image quality and improve the picture quality of the final image.
[0031] In order to better understand the above technical solution, exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present invention are shown in the accompanying drawings, it should be understood that the present invention can be implemented in various forms and should not be limited by the embodiments described herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present invention and to fully convey the scope of the present invention to those skilled in the art.
[0032] In order to better understand the above technical solution, the above technical solution will be described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0033] Figure 1 FIG. 1 is a flow chart of a document image optimization method according to an embodiment of the present invention. Figure 1 As shown, the document image optimization method includes the following steps:
[0034] S101, obtaining an original image and a corresponding reference image, wherein the original image is a document image originally captured by a high-speed scanner, and the reference image is a document image captured by a scanner.
[0035] That is to say, in the initial stage, the original image and the reference image corresponding to the original image are collected to generate training samples according to the collection results; wherein the original image is the original document image collected by the scanner, and the reference image is the document image collected by the scanner.
[0036] As an example, in the data collection stage, first, various common paper documents are collected; then, any paper document is photographed with a camera to obtain an original image, and then scanned with a scanner to obtain a corresponding reference image.
[0037] S102, constructing a training data binary according to the original image and the corresponding reference image, and training the model according to the training data binary. During the training process, the network parameters are optimized based on the objective function until convergence, so as to obtain a final image optimization model.
[0038] There are many ways to construct a training data tuple based on an original image and a corresponding reference image.
[0039] As an example, a mapping relationship between an original image and a corresponding reference image is directly established to complete the process of constructing a training data binary.
[0040] In some embodiments, constructing a training data tuple based on an original image and a corresponding reference image includes: acquiring a mapping relationship between the original image and the corresponding reference image through image registration, and cropping the original image to obtain an original sub-image, and cropping the corresponding reference image based on the mapping relationship to obtain a reference sub-image; constructing a training data tuple based on the original sub-image and the reference sub-image.
[0041] As an example, assume that the original image is image D and the reference image is image R. First, the mapping relationship between image R and image D is obtained by image registration. Then, image D is cropped to a size of m × n ×3 original sub-images, and according to the mapping relationship between image R and image D, the reference sub-image corresponding to each original sub-image is intercepted to form a training data tuple; the above steps are repeated to generate the training data tuple to obtain a large amount of training data.
[0042] Among them, there are many ways to design the network of the final image optimization model.
[0043] In some embodiments, the final image optimization model is composed of a fully convolutional network, which includes a convolutional layer and a transposed convolutional layer; wherein the activation function of the last layer of neurons in the fully convolutional network is:
[0044]
[0045] in, represents a constant greater than 1, Represents the input of the activation function.
[0046] As an example, the final image optimization model is composed of a fully convolutional network, which includes a convolutional layer and a transposed convolutional layer. The image size used to train the network parameters is m × n ×3, after network processing, the last layer of the network outputs an optimized image, size m × n ×3. The activation function used by the neurons in the last layer of the network is:
[0047]
[0048] in, is the input of the activation function, is a constant greater than 1 ( ). The neurons in other layers of the network use commonly used activation functions, such as Sigmoid function, Tanh function, ReLU function, etc. X represents the image input to the network, and T (X) represents the network's mapping of the input image, and the network output T (X) is a m × n ×3 tensor.
[0049] There are many ways to set the objective function.
[0050] In some embodiments, the objective function is expressed by the following formula:
[0051]
[0052] in, N represents the number of training data pairs, Indicates The original graph of training data pairs, Indicates the The target graph of training data pairs, represents the matrix bi-norm, Represents the threshold parameter.
[0053] It can be understood that, assuming that the training data tuple is (X, Y), X represents the original image captured by the camera, and Y represents the reference network output target image. For as many training data tuples as possible, T (X) is less than Y ,now that:
[0054] ,
[0055] in, is the matrix 2-norm, is a threshold parameter. Consider N training data pairs, the minimized objective function of network training is:
[0056]
[0057] in, ; For the training data pairs that do not meet the conditions, optimization is performed.
[0058] S103, acquiring the document image to be optimized, correcting the document image to be optimized, and inputting the corrected document image to be optimized into the final image optimization model, so as to output the final document image through the final image optimization model.
[0059] That is to say, after obtaining the document image to be optimized, in order to improve the image quality of the final document image, the document image to be optimized is first corrected (for example, cropping correction, removing black edges, etc.); and the corrected image is input into the final image optimization model to obtain the final document image; thereby reducing the impact of environmental factors on the quality of the final document image.
[0060] In some embodiments, in order to improve the correction effect and improve the accuracy of the edge detection results of the document; a gradient map is calculated and processed for the document image to be optimized, including: calculating the X-axis gradient map and the Y-axis gradient map corresponding to the document image to be optimized, and generating a gradient intensity map based on the X-axis gradient map and the Y-axis gradient map; calculating the average and standard deviation of the gradient intensity of each pixel in the document image to be optimized, and determining the gradient intensity threshold based on the average and standard deviation, and binarizing the gradient intensity map based on the gradient intensity threshold to obtain an edge image; filtering each pixel point with a value of 1 in the edge image to obtain a final edge image.
[0061] As an example, assuming that the document image to be optimized is image S, first, the Sobel operator is used to calculate the gradient map Gx in the horizontal X-axis direction and the gradient map Gy in the Y-axis direction of image S respectively; then, the gradient intensity of each pixel in image S is calculated according to the gradient map Gx and the gradient map Gy to obtain a gradient intensity map; then, the average value of the gradient intensity of each pixel in the image is calculated. and standard deviation ; and calculate the gradient intensity threshold based on the mean and standard deviation of the gradient intensity ,in, is a constant; then, the gradient intensity map is binarized using the gradient intensity threshold to obtain an edge image E. In the edge image E, if the value of a pixel is 1, it means that the gradient intensity of the pixel is large; if the value of a pixel is 0, it means that the gradient intensity of the pixel is small. Then, the pixel points with a value of 1 in the edge image E are further filtered to filter out the pixel points that will affect the subsequent processing and obtain the final edge image.
[0062] There are many ways to filter pixels.
[0063] In some embodiments, the filtering process includes:
[0064] If x is less than / 2, abs(Gx(x, y)) is greater than abs(Gy(x, y)), and Gx(x, y) is less than 0, then the value of the pixel in the edge map is set to 0;
[0065] If x is greater than / 2, abs(Gx(x, y)) is greater than abs(Gy(x, y)), and Gx(x, y) is greater than 0, then the value of the pixel in the edge map is set to 0;
[0066] If y is less than / 2, abs(Gx(x, y)) is less than abs(Gy(x, y)), and Gy(x, y) is less than 0, then the value of the pixel in the edge map is set to 0;
[0067] If y is greater than / 2, abs(Gx(x, y)) is less than abs(Gy(x, y)), and Gy(x, y) is greater than 0, then the value of the pixel in the edge map is set to 0;
[0068] Where x represents the X-axis coordinate value of the pixel currently being processed, and y represents the Y-axis coordinate value of the pixel currently being processed. Indicates the width of the document image to be optimized. Represents the height of the document image to be optimized, Gx(x, y) represents the X-axis gradient of the pixel currently being processed, and Gy(x, y) represents the Y-axis gradient of the pixel currently being processed.
[0069] In some embodiments, correcting the document image to be optimized also includes: dilating the final edge image, and performing a connected domain analysis on the final edge image after the dilation process to obtain the maximum connected domain, and calculating the minimum rotated circumscribed rectangle of the maximum connected domain; calculating the area where each edge of the document in the document image to be optimized is located according to the minimum rotated circumscribed rectangle, and performing Hough transform detection on the area where each edge is located based on the final edge image to obtain the straight line equation of each edge; calculating the coordinates of the four corner points of the document in the document image to be optimized according to the straight line equation of each edge, and calculating the width and height of the document according to the coordinates of the four corner points, and creating a new image according to the width and height values; calculating the affine transformation matrix, and mapping the coordinates of the four corner points of the document in the document image to be optimized to the four corner points of the new image, and intercepting the corresponding area in the document image to be optimized according to the affine transformation matrix to obtain the document area image.
[0070] As an example, first, the final edge image is expanded to obtain image F; then, a connected domain analysis is performed on image F to obtain the connected domain with the largest area; then, the minimum rotated circumscribed rectangle of the connected domain with the largest area is calculated to determine the approximate position of the document in the document image to be optimized through the minimum rotated circumscribed rectangle; then, the regions to which the four sides of the document belong in the image to be optimized are calculated based on the minimum rotated circumscribed rectangle; then, based on the final edge image, the positions of the straight lines are detected for the regions to which each side belongs using Hough transform to obtain the straight line equations of the positions of the four sides of the document in the document image to be optimized; then, the straight line equations of the positions of the four sides in the document image to be optimized are used to calculate the coordinates of the four corner points of the document in the image; then, the width value of the document is calculated based on the coordinates of the four corner points and height value , and create a width value of , the height value is A new image is obtained; then, an affine transformation matrix is calculated, and the coordinates of the four corner points of the document in the document image to be optimized are mapped to the four corner points of the new image; the corresponding area is intercepted in the document image to be optimized according to the affine transformation matrix to obtain a document area image C.
[0071] In some embodiments, in order to improve the optimization effect of the final document image, reduce the impact of black edges on image quality, and make the final image have better visual effects, the document image to be optimized is corrected, which also includes: binarizing the document area image to obtain a binarized document image; obtaining structural element size information, and determining the target image size based on the structural element size information and the binarized document image size information, and copying the binarized document image to the target image; performing morphological closing operation on the copied target image based on the structural element, and copying the relevant area in the target image after the closing operation to the binarized document image; searching for a connected domain with a pixel value of 0 at the edge of the copied binarized document image; obtaining the first coordinate value of any pixel point in the connected domain with a pixel value of 0, and finding the second coordinate value of the non-zero pixel point closest to the current pixel point, and setting the pixel value of the pixel point with the second coordinate value in the document area image to the pixel value of the pixel point with the first coordinate value.
[0072] As an example, in order to further remove the residual black edges of the document image, for each pixel point in the document area image C, the grayscale average value of the pixels in the circular area with the pixel point as the center and a radius of r pixels is calculated, and the difference between the grayscale average value and the constant D is calculated, and the difference is used as the pixel threshold; then, the pixel point is binarized with the threshold, and after completing the traversal of each pixel point, the document area image C is binarized to obtain the binarized document image B; then, the size information of the structural element is obtained, assuming that the structural element is a circle (the structural element can also be an ellipse) with a diameter of , assuming that the width of the binary document image B is , the height value is ;Copy the binary document image B to a width value +2 , the height value is The target image Bex is in the middle. In the target image Bex, the pixel values of the area other than the binary document image B are 0. Then, the image Bex is morphologically closed using the structural element, and the width value of the middle of the image Bex is , the height value is The area is copied to the binary document image B; then, the connected domains with pixel values of 0 are found on the edge of the copied binary document image B, and each pixel point in these connected domains is processed. Assuming that the coordinates of the current pixel point are ( x b , y b ); Find the pixel point with a non-zero distance to the current pixel point in the copied binary document image B, the coordinates of which are ( x f, y f ); Then, the coordinates of the document area image C are ( x f , y f ) is set to the pixel value of the pixel point with coordinates ( x b , y b ) pixel value of the pixel point; thereby, the black edges in the image can be effectively removed and the visual effect can be improved.
[0073] In summary, according to the document image optimization method of an embodiment of the present invention, first, an original image and a corresponding reference image are obtained, wherein the original image is a document image originally captured by a high-speed scanner, and the reference image is a document image captured by a scanner; then, a training data tuple is constructed according to the original image and the corresponding reference image, and a model is trained according to the training data tuple, and in the training process, network parameters are optimized based on the objective function until convergence to obtain a final image optimization model; then, the document image to be optimized is obtained, and the document image to be optimized is corrected, and the corrected document image to be optimized is input into the final image optimization model to output the final document image through the final image optimization model; thereby realizing automatic optimization of the document image captured by the high-speed scanner to reduce the influence of environmental factors on image quality and improve the picture quality of the final image.
[0074] In order to implement the above embodiment, the embodiment of the present invention proposes a computer-readable storage medium, on which a document image optimization program is stored. When the document image optimization program is executed by a processor, the document image optimization method as described above is implemented.
[0075] According to the computer-readable storage medium of an embodiment of the present invention, by storing a document image optimization program, the processor implements the document image optimization method as described above when executing the document image optimization program, thereby realizing automatic optimization of the document image captured by the high-speed scanner, so as to reduce the impact of environmental factors on the image quality and improve the final image quality.
[0076] It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0077] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0078] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0079] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0080] It should be noted that in the claims, any reference signs placed between brackets shall not be construed as limiting the claims. The word "comprising" does not exclude the presence of components or steps not listed in the claim. The word "a" or "an" preceding a component does not exclude the presence of a plurality of such components. The invention may be implemented by means of hardware comprising several different components and by means of a suitably programmed computer. In a unit claim enumerating several means, several of these means may be embodied by the same item of hardware. The use of the words first, second, and third etc. does not indicate any order. These words may be interpreted as names.
[0081] Although the preferred embodiments of the present invention have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.
[0082] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
[0083] In the description of the present invention, it should be understood that the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of the present invention, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.
[0084] In the present invention, unless otherwise clearly specified and limited, the terms "installed", "connected", "connected", "fixed" and the like should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, it can be the internal connection of two elements or the interaction relationship between two elements. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0085] In the present invention, unless otherwise clearly specified and limited, a first feature being "above" or "below" a second feature may mean that the first and second features are in direct contact, or the first and second features are in indirect contact through an intermediate medium. Moreover, a first feature being "above", "above" or "above" a second feature may mean that the first feature is directly above or obliquely above the second feature, or simply means that the first feature is higher in level than the second feature. A first feature being "below", "below" or "below" a second feature may mean that the first feature is directly below or obliquely below the second feature, or simply means that the first feature is lower in level than the second feature.
[0086] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms should not be understood as necessarily being directed to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, unless they are contradictory.
[0087] Although the embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present invention. A person skilled in the art may change, modify, replace and vary the above embodiments within the scope of the present invention.
Claims
1. A document image optimization method, characterized in that: The following steps are involved: Acquire an original image and a corresponding reference image, wherein the original image is a document image originally captured by a scanner, and the reference image is a document image captured by a scanner; Constructing a training data binary according to the original image and the corresponding reference image, and training a model according to the training data binary, and optimizing network parameters based on an objective function until convergence during the training process to obtain a final image optimization model; Acquire a document image to be optimized, correct the document image to be optimized, and input the corrected document image to be optimized into the final image optimization model to output a final document image through the final image optimization model; The step of correcting the document image to be optimized includes: Calculating an X-axis gradient map and a Y-axis gradient map corresponding to the document image to be optimized, and generating a gradient intensity map according to the X-axis gradient map and the Y-axis gradient map; Calculating the average value and standard deviation of the gradient intensity of each pixel in the document image to be optimized, determining a gradient intensity threshold according to the average value and the standard deviation, and binarizing the gradient intensity map according to the gradient intensity threshold to obtain an edge image; Performing filtering processing on each pixel point with a value of 1 in the edge image to obtain a final edge image; The filtering process includes: If x is less than / 2, abs(Gx(x, y)) is greater than abs(Gy(x, y)), and Gx(x, y) is less than 0, then the value of the pixel in the edge map is set to 0; If x is greater than / 2, abs(Gx(x, y)) is greater than abs(Gy(x, y)), and Gx(x, y) is greater than 0, then the value of the pixel in the edge map is set to 0; If y is less than / 2, abs(Gx(x, y)) is less than abs(Gy(x, y)), and Gy(x, y) is less than 0, then the value of the pixel in the edge map is set to 0; If y is greater than / 2, abs(Gx(x, y)) is less than abs(Gy(x, y)), and Gy(x, y) is greater than 0, then the value of the pixel in the edge map is set to 0; Where x represents the X-axis coordinate value of the pixel currently being processed, and y represents the Y-axis coordinate value of the pixel currently being processed. Indicates the width of the document image to be optimized. Represents the height of the document image to be optimized, Gx(x, y) represents the X-axis gradient of the pixel currently being processed, and Gy(x, y) represents the Y-axis gradient of the pixel currently being processed.
2. The document image optimization method according to claim 1, characterized in that: Constructing a training data tuple according to the original image and the corresponding reference image, including: Acquire a mapping relationship between the original image and the corresponding reference image through image registration, and crop the original image to obtain an original sub-image, and crop the corresponding reference image according to the mapping relationship to obtain a reference sub-image; A training data tuple is constructed according to the original sub-image and the reference sub-image.
3. The document image optimization method according to claim 1, characterized in that: The objective function is expressed by the following formula: Where N represents the number of training data pairs. Indicates The original graph of training data pairs, Indicates The target graph of training data pairs, represents the matrix bi-norm, Represents the threshold parameter.
4. The document image optimization method according to claim 1, characterized in that: The final image optimization model is composed of a fully convolutional network, which includes a convolutional layer and a transposed convolutional layer; Among them, the activation function of the last layer of neurons in the fully convolutional network is: in, represents a constant greater than 1, Represents the input of the activation function.
5. The document image optimization method according to claim 1, characterized in that: Correcting the document image to be optimized also includes: Performing dilation processing on the final edge image, and performing connected domain analysis on the final edge image after dilation processing to obtain a maximum connected domain, and calculating a minimum rotated circumscribed rectangle of the maximum connected domain; Calculating the region to which each edge of the document in the document image to be optimized belongs according to the minimum rotated circumscribed rectangle, and performing Hough transform detection on the region to which each edge belongs based on the final edge image to obtain a straight line equation of each edge; Calculating the coordinates of the four corner points of the document in the document image to be optimized according to the straight line equation of each edge, calculating the width and height of the document according to the coordinates of the four corner points, and creating a new image according to the width and height; An affine transformation matrix is calculated, and the coordinates of the four corner points of the document in the document image to be optimized are mapped to the four corner points of the new image, and corresponding areas are intercepted in the document image to be optimized according to the affine transformation matrix to obtain a document area image.
6. The document image optimization method according to claim 5, characterized in that: Correcting the document image to be optimized also includes: Binarizing the document region image to obtain a binarized document image; Acquire structural element size information, determine target image size according to the structural element size information and binary document image size information, and copy the binary document image into the target image; Performing morphological closing operation on the copied target image based on the structural element, and copying the relevant area in the target image after the closing operation to the binary document image; Find the connected domain with pixel value 0 on the edge of the copied binary document image; Obtain the first coordinate value of any pixel point in the connected domain whose pixel value is 0, find the second coordinate value of the pixel point with a non-zero pixel value closest to the current pixel point, and set the pixel value of the pixel point with the second coordinate value in the document area image to the pixel value of the pixel point with the first coordinate value.
7. A computer-readable storage medium, characterized in that: A document image optimization program is stored thereon, and when the document image optimization program is executed by a processor, the document image optimization method according to any one of claims 1 to 6 is implemented.
