Document image processing method and device
By identifying and removing black borders during document image processing, the image quality problem when smartphones capture documents is solved, improving image quality and ensuring the accuracy and stability of downstream tasks.
Patent Information
- Application Number
- CN202511368878.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-24
- Publication Date
- 2026-02-06
AI Technical Summary
Traditional desktop scanners are cumbersome to operate, and when smartphones photograph documents, irregular black borders and redundant background information appear, affecting image quality and the accuracy and stability of downstream tasks.
By acquiring the original document image, determining the document region image, and performing local extraction processing, the black border is removed based on the similarity between the first and second local images of adjacent boundaries, while retaining the effective image content.
It improves image quality, ensures the accuracy and stability of downstream tasks, and achieves efficient digital processing of document images.
Smart Images

Figure CN121482816A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] Embodiments of the present application relate to the field of image processing, and in particular to a document image processing method and device. BACKGROUND
[0002] With the rapid development of information technology, the importance of document digital collection is increasingly prominent. The traditional desktop scanner, as the main equipment for early document digitization, is based on photoelectric line scanning technology, which requires paper documents to be placed one by one in a specific position before scanning each page to convert it into a digital file. The process is tedious and requires manual flipping and fixing of the document. Moreover, when facing a large number of documents, the efficiency is extremely low, which has become a major bottleneck restricting the progress of document digitization. Therefore, with the significant improvement in the pixels and imaging quality of mobile device cameras, using smartphones or portable cameras to directly capture documents has become the mainstream method of document digital collection, replacing traditional desktop scanners due to its convenience, low cost, and mobility.
[0003] In related technologies, after capturing a document image, the document region is detected and a standard document image is output. However, due to the influence of complex background in the shooting environment, the document region detection is prone to errors, resulting in irregular black edges in the output image, introducing redundant background information, and affecting the image quality and the accuracy and stability of downstream tasks. SUMMARY
[0004] Embodiments of the present application provide a document image processing method and device, which solves the problem of irregular black edges in the output image in related technologies, introduces redundant background information, affects the image quality, and affects the accuracy and stability of downstream tasks. The content similarity can be used to accurately identify the local image corresponding to the black edge in the document region image, and the local image can be removed to retain the effective image content, improve the image quality, and ensure the accuracy and stability of downstream tasks.
[0005] In a first aspect, embodiments of the present application provide a document image processing method, which includes: obtaining an original document image, and determining a document region image from the original document image; performing local extraction processing on the document region image to obtain a first local image with adjacent boundaries and a second local image adjacent to the first local image; based on the similarity between the first local image and the second local image, removing the first local image from the document region image to obtain a target document image.
[0006] In a second aspect, embodiments of the present application also provide a document image processing device, which includes: a document region image determination module, configured to acquire an original document image, and determine a document region image from the original document image; a local image determination module, configured to perform local extraction processing on the document region image to obtain a first local image with adjacent boundaries, and a second local image adjacent to the first local image; a target document image determination module, configured to remove the first local image from the document region image based on similarity between the first local image and the second local image to obtain a target document image.
[0007] In a third aspect, an embodiment of the present application further provides a document image processing device, which comprises: one or more processors; a storage device configured to store one or more programs, when the one or more programs are executed by the one or more processors, the one or more processors implement the document image processing method provided by the embodiments of the present application.
[0008] In a fourth aspect, an embodiment of the present application further provides a nonvolatile storage medium storing computer executable instructions, which, when executed by a computer processor, are configured to perform the document image processing method provided by the embodiments of the present application.
[0009] In the embodiments of the present application, the document region image is determined from the original document image, which can exclude irrelevant backgrounds and reduce interference factors in subsequent processing. The first local image with adjacent boundaries and the second local image related to the first local image are obtained by performing local extraction processing on the document region image, which can be extracted according to the position characteristics of the black border. Based on the similarity between the first local image and the second local image, it can be accurately judged whether the first local image belongs to the black border part, so that the subsequent black border abnormal influence can be removed, and the visual purity of the image is improved. The above-mentioned scheme can accurately identify the local image corresponding to the black border in the document region image by using content similarity, remove the local image, retain effective image content, improve image quality, and ensure the accuracy and stability of downstream tasks. BRIEF DESCRIPTION OF DRAWINGS
[0010] Figure 1 a flowchart of a document image processing method provided by an embodiment of the present application; Figure 2 a schematic diagram of a process of extracting a first local image and a second local image provided by an embodiment of the present application; Figure 3 an effect schematic diagram of removing a first local image from a document region image provided by an embodiment of the present application; Figure 4 A flow chart of a process for determining a target similarity value provided by an embodiment of the present application; Figure 5 A schematic diagram of a process for segmenting and splicing a first local image to obtain a first spliced image provided by an embodiment of the present application; Figure 6 A flow chart of a document image processing method provided by an embodiment of the present application, which comprises a process for calculating a target similarity value; Figure 7 A flow chart of a process for calculating a first similarity value provided by an embodiment of the present application; Figure 8 A flow chart of a process for calculating a second similarity value provided by an embodiment of the present application; Figure 9 A flow chart of a process for calculating a third similarity value provided by an embodiment of the present application; Figure 10 A flow chart of a document image processing method provided by an embodiment of the present application, which comprises a process for determining a document region image; Figure 11 A flow chart of a process for determining a target document direction provided by an embodiment of the present application; Figure 12 A schematic diagram of a process for rotating a target region image to obtain a document region image provided by an embodiment of the present application; Figure 13 A structure block diagram of a document image processing apparatus provided by an embodiment of the present application; Figure 14 A structure schematic diagram of a document image processing device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0011] The embodiments of the present application will be described in further detail below with reference to the drawings and embodiments. It can be understood that the specific embodiments described herein are only used to explain the embodiments of the present application, but not to limit the embodiments of the present application. In addition, it should be noted that, for the convenience of description, only the parts related to the embodiments of the present application are shown in the drawings, not all the structures.
[0012] The terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such use of data can be interchanged where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class and the number of objects is not limited; for example, a first object can be one or more. Furthermore, in the specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.
[0013] The document image processing method provided in this application can be used to standardize document images, improve document image quality, and provide high-quality input for downstream tasks such as information extraction and layout analysis. This document image processing method can be applied to the electronic image processing needs in scenarios such as finance, government affairs, office work, and archives, achieving image preprocessing. The aforementioned application scenarios are merely exemplary and illustrative. In practical applications, this document image processing method can also be used in image processing in other scenarios, and this application does not limit this application. This application aims to provide a document image processing method and apparatus to solve the problems in related technologies where irregular black borders exist in the output image results, introducing redundant background information, affecting image quality and the accuracy and stability of downstream tasks.
[0014] The document image processing method provided in this application embodiment can be executed by a computer device. The computer device refers to any document image processing device with data computing, processing and storage capabilities, such as mobile phones, PCs (Personal Computers), tablet computers and other terminal devices, or servers and other devices. This application embodiment does not limit the scope of the method.
[0015] Figure 1 A flowchart of a document image processing method provided in this application embodiment is shown below. Figure 1 As shown, the document image processing method includes the following steps: Step S101: Obtain the original document image and determine the document region image from the original document image.
[0016] The original document image can be a photograph taken by a user using a terminal device of books, tickets, manuscripts, etc. This original document image can contain both valid document content and interfering information, such as irrelevant background or noise. The document region image can be a core region image located and extracted from the original document image; it contains valid document content and removes irrelevant background and noise areas from the original document image.
[0017] Step S102: Perform local extraction processing on the document region image to obtain a first local image of the adjacent boundary and a second local image related to the first local image.
[0018] In this process, document region detection is prone to errors, resulting in black borders in the document region image. These black borders can be continuous or discontinuous black borders, stripes, or blocks appearing in the image edge region, constituting image interference. The local extraction process can extract a local image from the document region image according to a preset size ratio. Since the black border is located in the edge region of the document region image, a first local image of the adjacent boundary and a second local image related to the first local image can be selected for extraction. The first local image can be extracted based on a certain boundary of the document region image according to a preset size ratio. This preset size ratio can be the ratio of the width of the first local image perpendicular to the boundary direction to the width of the document region image perpendicular to the boundary direction. This preset size ratio can be adaptively set based on empirical data from actual application scenarios, and is not limited in this application. The second local image is related to the first local image; specifically, it can be the same size as the first local image and located in a neighboring position. For example, the first local image is located at an adjacent boundary, and the second local image is located adjacent to the first local image. For example, the second local image may be located at a preset pixel distance from the first local image, but this application does not limit this. It should be noted that, since the black border portion differs significantly from the non-black border portion, and the black border portion has irregular characteristics with significant differences between different regions within it, the similarity between the first local image and the second local image can be judged to prioritize determining whether the first local image at the adjacent boundary belongs to the black border portion, thereby achieving the purpose of subsequent black border removal.
[0019] In one embodiment, Figure 2 A schematic diagram illustrating the process of extracting a first local image and a second local image provided in an embodiment of this application is shown below. Figure 2 As shown, taking the removal of black borders from the left edge of the document region image 201 as an example, the document region image 201 is partially extracted along the left edge according to a preset size ratio to obtain a first local image 202 adjacent to the boundary. The first local image 202 is a thin segment of the left edge of the document region image 201. After extracting the first local image 202, a local image of the same size can be extracted at the adjacent position of the first local image 202 to obtain a second local image 203.
[0020] Step S103: Based on the similarity between the first local image and the second local image, remove the first local image from the document region image to obtain the target document image.
[0021] Determining the similarity between the first local image and the second local image can specifically involve calculating a target similarity value based on the similarity between the first and second local images. This target similarity value can be a numerical value that quantifies the degree of similarity between the first and second local images. By comparing the calculated target similarity value with a preset threshold, it can be determined whether the first local image and the second local image are similar, and thus decide whether to remove the first local image from the document region image. In one embodiment, if the target similarity value is greater than or equal to the preset threshold, it can be considered that the similarity between the first and second local images is high, and the first local image can be determined to be a non-black border portion, so it does not need to be removed from the document region image. In another embodiment, if the target similarity value is less than the preset threshold, it can be considered that the similarity between the first and second local images is low, and the first local image can be determined to be a black border portion, so it needs to be removed from the document region image. The preset threshold can be adaptively set based on empirical data from actual application scenarios, and is not limited in this application. It should be noted that the aforementioned steps are applicable to removing black borders from a specific boundary of a document region image. By repeating these steps, black borders can be removed from each boundary of the document region image to achieve an overall black border removal effect. Specifically, removing the first partial image from the document region image can be done by cropping the first partial image from the document region image or by replacing the first partial image in the document region image with a preset background; this application does not limit this to any particular method. Figure 3 This application provides an embodiment of an illustration showing the effect of removing a first local image from a document region image, as shown below. Figure 3 As shown, the first local image is removed from the document region image 201 to obtain the target document image 301.
[0022] In one embodiment, Figure 4 A flowchart illustrating a process for determining a target similarity value is provided in this application embodiment, as follows: Figure 4 As shown, the specific implementation process of similarity calculation based on the first local image and the second local image includes the following steps: Step S1031: The first local image is segmented and stitched together to obtain the first stitched image.
[0023] Step S1032: The second local image is segmented and stitched together to obtain the second stitched image.
[0024] Since the black borders are only anomalies appearing near the image edges, and the first local image is extracted based on a certain boundary of the document region image according to a preset size ratio, the preset size ratio of the extracted first local image is set relatively small. This results in a larger difference between the width of the first local image perpendicular to the boundary direction and the width of the document region image perpendicular to that boundary direction, thus refining the granularity of each black border removal process. Consequently, the first local image may exhibit a large difference between its width and height, for example, a width-to-height ratio of 1:70. If the second local image associated with the first local image has the same size, performing similarity calculations on the first and second local images with a large difference in width and height will lead to significant errors in the subsequent calculation of the target similarity values between the first and second local images. Therefore, in this embodiment, while maintaining the image content, the first and second local images are converted into a first stitched image and a second stitched image with a smaller difference in width and height, respectively.
[0025] In one embodiment, taking a first partial image as an example, the specific implementation process of segmenting and stitching the first partial image to obtain a first stitched image is as follows: The number of segments is determined based on the aspect ratio of the first local image, and the long side direction and short side direction are determined by boundary direction recognition of the first local image; the first local image is segmented along the long side direction according to the number of segments to obtain multiple image segments; the multiple image segments are stitched together along the short side direction to obtain the first stitched image.
[0026] The aspect ratio of the first local image can be the ratio of its width to its height. To maintain the image content while minimizing the difference between the image width and height, the number of segments can be determined based on the aspect ratio of the first local image. For example, if the aspect ratio is... And m is greater than n, assuming the demand is divided into the following segments: Then, the first local image is segmented and stitched according to the number of segments, and the new aspect ratio can be... To reduce the difference between the image width and the image height, it is required that... Therefore, it can be calculated that For example, if the aspect ratio is 1:70, then The number of segments can be set to a value close to 8.36, specifically 7, 8, or 9, which is not limited in this application. Furthermore, for accurate segmentation and stitching, boundary direction identification can be performed on the first local image to determine the direction of its long side and short side. By uniformly dividing the first local image along the long side according to the number of segments, multiple image segments can be obtained, each with the same width and length. Then, these multiple image segments are stitched together along the short side to obtain the first stitched image. For example, if the aspect ratio is 1:70 and the selected number of segments is 8, then after segmentation and stitching according to the aforementioned steps, a new aspect ratio of 8:8.75 can be obtained, achieving the goal of reducing the difference between the image width and image height.
[0027] For example, taking the first partial image as an example, Figure 5 This is a schematic diagram illustrating a process of segmenting and stitching a first partial image to obtain a first stitched image, as provided in an embodiment of this application. Figure 5 As shown, in Figure 2 Based on this, after performing local extraction processing on the document region image to obtain the first local image 202 of the adjacent boundary, the first local image 202 can be divided along the long side direction according to a preset number of parts to obtain at least one image segment 501, and then the at least one image segment 501 can be re-stitched along the short side direction to obtain the first stitched image 502.
[0028] Step S1033: Perform similarity calculation on the first stitched image and the second stitched image to obtain the target similarity value.
[0029] The similarity between the first and second stitched images can be comprehensively evaluated from different dimensions, specifically one or more of the statistical feature dimension, structural dimension, and pixel distribution dimension. From the statistical feature dimension, similarity values can be calculated using preset formulas based on statistical features such as pixel mean and pixel variance to measure the similarity between the first and second stitched images in terms of statistical features. From the structural dimension, similarity values can be calculated using preset formulas based on factors such as image brightness, contrast, and correlation between images to measure the structural similarity between the first and second stitched images. From the pixel distribution dimension, similarity values can be calculated using preset formulas based on factors such as the frequency and distribution pattern of pixel values to measure the similarity in pixel distribution pattern between the first and second stitched images. Detailed calculation processes can be found in subsequent embodiments related to calculating the similarity values between the first and second local images, and will not be repeated here. Taking the simultaneous selection of statistical feature dimension, structural dimension and pixel distribution dimension as an example, the similarity value corresponding to each dimension can be calculated respectively for the statistical feature dimension, structural dimension and pixel distribution dimension, and any one of them can be selected as the target similarity value, or at least two or three can be selected at the same time for weighted summation to obtain the target similarity value. This application does not limit this.
[0030] Therefore, by converting the first local image and the second local image into the first stitched image and the second stitched image respectively, the difference between the image width and height can be reduced, which facilitates subsequent similarity calculation and improves the accuracy of the target similarity value.
[0031] In one embodiment, since the target similarity value is less than a preset threshold, the second local image may still retain black border content. Therefore, after removing the first local image from the document region image to obtain the target document image, the target document image can be used as a new document region image to continue local extraction processing to obtain new first and second local images. The relevant processing operations of steps S102 and S103 are repeated until the calculated target similarity value is greater than the preset threshold, thus obtaining the final target document image.
[0032] Optionally, repeatedly removing local images too many times can easily lead to the erroneous removal of valid document content. Therefore, before removing the first local image from the document region image to obtain the target document image, the cumulative number of local image removal operations on the document region image can be counted. If the cumulative number of operations has not reached a preset number, the first local image is removed from the document region image to obtain the target document image. This allows for reasonable control of the number of local image removal operations, ensuring the integrity of the valid document content.
[0033] Optionally, after removing the first local image from the document region image to obtain the target document image, text detection models such as EAST and PSENet can be used to locate the text regions in the target document image. Based on the localization results, the target document image is then split into a text region image and a background region image. Morphological recognition is performed on the text region image to obtain a stroke skeleton with a single pixel width. Then, the text region image is input into a super-resolution model such as TextSR or ESRGAN to obtain a text-enhanced image. The text edges in the text-enhanced image are corrected based on the recognized stroke skeleton to obtain the target text-enhanced image. Finally, the target text-enhanced image and the background region image are stitched together according to their original positional relationship to obtain the enhanced target document image.
[0034] As described above, determining the document region image from the original document image can eliminate irrelevant backgrounds and reduce interference factors in subsequent processing. Local extraction processing of the document region image yields a first local image of the adjacent boundary and a second local image adjacent to the first local image, allowing for local image extraction tailored to the location characteristics of the black border. Based on the similarity between the first and second local images, their similarity can be quantified to accurately determine whether the first local image belongs to the black border region. When the target similarity value is less than a preset threshold, removing the first local image from the document region image to obtain the target document image removes the abnormal influence of the black border, improving the visual purity of the image. This scheme can accurately identify the local image corresponding to the black border in the document region image using content similarity, remove this local image, retain valid image content, improve image quality, and ensure the accuracy and stability of downstream tasks.
[0035] Figure 6 A flowchart of a document image processing method, including a process for calculating target similarity values, is provided for embodiments of this application. Figure 6 As shown, the document image processing method includes the following steps: Step S601: Obtain the original document image and determine the document region image from the original document image.
[0036] Step S602: Perform local extraction processing on the document region image to obtain a first local image of the adjacent boundary and a second local image related to the first local image.
[0037] Step S603: Perform statistical feature similarity calculation on the first local image and the second local image to obtain a first similarity value; and / or perform structural similarity calculation on the first local image and the second local image to obtain a second similarity value; and / or perform pixel distribution similarity calculation on the first local image and the second local image to obtain a third similarity value.
[0038] The similarity between the first and second local images can be comprehensively evaluated from different dimensions, specifically combining one or more of the following dimensions: statistical features, structural features, and pixel distribution. Specifically, statistical feature similarity calculation can involve extracting statistical features corresponding to the first and second local images, such as pixel mean and pixel variance, and determining the degree of similarity based on these statistical features. This first similarity value can be used to quantify the similarity between the first and second local images in terms of statistical features.
[0039] In one embodiment, Figure 7 A flowchart illustrating the process of calculating a first similarity value provided in this application embodiment is shown below. Figure 7 As shown, the specific implementation process for calculating the statistical feature similarity of the first local image and the second local image includes the following steps: Step S6031: Calculate the mean and variance of the first pixel corresponding to the first local image, and calculate the mean and variance of the second pixel corresponding to the second local image.
[0040] Wherein, the first pixel mean can be the arithmetic mean of all pixel values in the first local image. The first pixel variance can be the average of the squares of the deviations of all pixel values in the first local image from the mean. The second pixel mean can be the arithmetic mean of all pixel values in the second local image. The second pixel variance can be the average of the squares of the deviations of all pixel values in the second local image from the mean.
[0041] Step S6032: Calculate the first similarity value based on the first pixel mean, the second pixel mean, the first pixel variance, and the second pixel variance.
[0042] Therefore, the similarity between the first local image and the second local image can be quantified in two dimensions: mean feature and variance feature. The larger the first similarity value, the more similar the first local image and the second local image are in the statistical feature dimension.
[0043] In one possible implementation, since the pixel mean reflects the average trend of image pixel values and the pixel variance reflects the dispersion of image pixel values, two similar images will have a high degree of consistency in both the average trend and dispersion of their pixel values. Based on this, the formula for calculating the first similarity value provided in this embodiment is as follows:
[0044] in, The first similarity value, It is a natural exponential function. The average value of the first pixel. The average value of the second pixel. The variance of the first pixel. The variance of the second pixel. As a preset constant, This is a hyperparameter. This preset constant can be used to prevent the denominator from being zero. This hyperparameter can be used to control the impact of the difference between the mean and variance on the first similarity value. Specifically, it can be adaptively set according to empirical data of actual application scenarios, and this application does not limit it.
[0045] It should be noted that, in order to compare the difference between the average value of the first pixel and the average value of the second pixel, it is possible to calculate... Similarly, by comparing the difference between the variance of the first pixel and the variance of the second pixel, we can calculate... However, because it is necessary to simultaneously consider the difference between the pixel mean and pixel variance, and All are absolute differences, so we directly use... and Summing may result in unreasonable similarity results due to large mean or variance values or calculation errors. Therefore, it is advisable to... Divide by ( ), and will Divide by ( This transforms absolute differences into relative differences. and Normalization is performed. Additionally, to prevent the denominator from being zero and to ensure computational robustness, a local minimum can be added. Perform calculations, that is Divide by ( ),as well as Divide by ( ). By ( )as well as( ( Direct summation can be considered as the average trend and dispersion of pixel values contributing equally to similarity. Excessive difference in either will increase the overall difference, and the summation result represents the total difference between the two images. To facilitate subsequent fusion calculations involving similarity values of different dimensions, the compressibility and monotonicity of the exponential function can be utilized to... ( )as well as( ( The summation result is mapped to the interval between 0 and 1. In this embodiment, we use... If the summation result is larger, it means the total difference value is larger. The closer the converted result is to 0, the smaller the summation value, meaning the smaller the total difference. The closer the converted value is to 1, the better. This is a hyperparameter used to control the sensitivity of the first similarity value relative to the total difference value. The larger the value, the steeper the descent of the exponential function curve, meaning a lower tolerance for total differences. As the total differences increase, the calculated first similarity value decreases relatively quickly. The smaller the value, the gentler the descent of the exponential function curve, meaning a higher tolerance for total differences. As the total difference increases, the calculated first similarity value decreases relatively slowly. Therefore, based on the aforementioned formula, the similarity between the first and second local images in terms of the average trend and dispersion of pixel values can be accurately quantified; this is achieved through relative difference calculation and the introduction of a preset constant. This can avoid large errors in similarity values due to large numerical values of statistical features or extreme cases, thus improving the accuracy of black border judgment; by introducing hyperparameters It allows for flexible adjustment of the sensitivity of the first similarity value to feature differences, meeting the needs of different application scenarios.
[0046] In another possible implementation, the formula for calculating the first similarity value is as follows:
[0047]
[0048]
[0049] in, The first similarity value, These are the weighting coefficients. This is the mean similarity value. This represents the variance similarity value. The average value of the first pixel. The average value of the second pixel. The variance of the first pixel. The variance of the second pixel. As a preset constant, It is a function for maximizing the value.
[0050] The structural similarity calculation can focus on the consistency of structural information between the first and second local images, specifically by evaluating the degree of similarity based on factors such as image brightness, contrast, and correlation between images. The second similarity value can be used to quantify the structural similarity between the first and second local images.
[0051] In one embodiment, Figure 8A flowchart illustrating the process of calculating a second similarity value provided in this application embodiment is shown below. Figure 8 As shown, the specific implementation process for calculating the structural similarity of the first local image and the second local image includes the following steps: Step S6033: Calculate the first average brightness and first contrast corresponding to the first local image, and calculate the second average brightness and second contrast corresponding to the second local image.
[0052] The first average brightness can be the arithmetic mean of the brightness values of all pixels in the first local image, used to quantify the overall brightness level of the image. The first contrast ratio can be the standard deviation or variance of the brightness values of all pixels in the first local image, used to quantify the difference in brightness between bright and dark areas in the image. The second average brightness can be the arithmetic mean of the brightness values of all pixels in the second local image. The second contrast ratio can be the standard deviation or variance of the brightness values of all pixels in the second local image.
[0053] Step S6034: Calculate the covariance based on the first local image and the second local image.
[0054] Covariance can be a measure of the linear correlation between the pixel brightness values of the first local image and the second local image, used to quantify whether the brightness change trends of corresponding pixels in the two images are consistent.
[0055] Step S6035: Calculate the second similarity value based on the first average brightness, the first contrast ratio, the second average brightness, the second contrast ratio, and the covariance.
[0056] Therefore, the similarity between the first local image and the second local image can be quantified in three dimensions: overall brightness, brightness variation range, and brightness variation trend. The larger the second similarity value, the more similar the first local image and the second local image are in the structural dimension.
[0057] In one possible implementation, the formula for calculating the second similarity value is as follows:
[0058] in, The second similarity value, The first average brightness, The second average brightness, The highest contrast ratio is... For the second contrast, For covariance, and This is a preset constant. Specifically, It can be used to measure the synergy of average brightness, while It can be used to measure the positive correlation of covariance. and This can be used to suppress abnormal results caused by excessive differences in average brightness or contrast. The second similarity value ranges from [-1, 1], with values closer to 1 indicating greater similarity between the two images. The above formula quantifies the matching degree between the first and second local images in terms of central trend and fluctuation correlation, thus determining whether the two images are similar.
[0059] In another possible implementation, the formula for calculating the second similarity value is as follows:
[0060]
[0061]
[0062]
[0063] in, The second similarity value, This is a brightness comparison function. This is a contrast comparison function. For structural comparison functions, The first average brightness, The second average brightness, The highest contrast ratio is... For the second contrast, For covariance, , and As a preset constant, , and The preset coefficient is greater than 0.
[0064] The pixel distribution similarity calculation can be achieved by comparing the pixel value probability distributions of two local images, such as the frequency of pixel values and their distribution patterns, to determine similarity. The third similarity value can be used to quantify the degree of similarity between the first and second local images in terms of pixel distribution patterns.
[0065] In one embodiment, Figure 9 A flowchart illustrating the process of calculating a third similarity value is provided for embodiments of this application, as follows: Figure 9 As shown, the specific implementation process for calculating the pixel distribution similarity of the first local image and the second local image includes the following steps: Step S6036: Count the number of first pixels in each preset color interval of the first local image, and count the number of second pixels in each preset color interval of the second local image.
[0066] The preset color range can be a pre-defined color spectrum used to segment color values for easier pixel distribution analysis. The first pixel count can be the total number of pixels in the first local image located within a preset color range, reflecting the pixel proportion of the first local image in that color range. The second pixel count can be the total number of pixels in the second local image located within a preset color range, reflecting the pixel proportion of the second local image in that color range.
[0067] Step S6037: Calculate the first average value based on the number of first pixels corresponding to each preset color interval, and calculate the second average value based on the number of second pixels corresponding to each preset color interval.
[0068] The first average value reflects the average distribution of the number of pixels in the first local image across the color range. The second average value reflects the average distribution of the number of pixels in the second local image across the color range.
[0069] Step S6038: Calculate the third similarity value based on the first average value, the first average value, and the first and second pixel counts corresponding to each preset color interval.
[0070] Therefore, the similarity between the first local image and the second local image in terms of pixel value distribution can be quantified. The larger the third similarity value, the more similar the first local image and the second local image are in terms of pixel distribution dimension.
[0071] In one possible implementation, the formula for calculating the third similarity value is as follows:
[0072] in, The third similarity value, The first pixel number, The second pixel number, The first average value, The second average, This specifies the number of preset color ranges. Specifically, It calculates the sum of the products of the deviations of the first pixel count and the second pixel count from the mean, which can reflect the consistency of the changing trends of the first pixel count and the second pixel count. and It can be used to normalize molecules so that the third similarity value ranges from [-1, 1]. The closer it is to 1, the more similar the two images are.
[0073] In another possible implementation, the formula for calculating the third similarity value is as follows:
[0074] in, The third similarity value, For the first The first pixel number of a preset pixel range For the first The second pixel number of a preset pixel range The first average value, The second average, The number of preset color ranges, For the first Preset weight values for each preset pixel interval are used to assign weights to different preset pixel intervals, highlighting the impact of key color intervals on image similarity.
[0075] Step S604: Determine the target similarity value based on at least one of the first similarity value, the second similarity value, and the third similarity value.
[0076] Specifically, any one of the first similarity value, the second similarity value, and the third similarity value can be selected as the target similarity value. Alternatively, at least two or all three of the first similarity value, the second similarity value, and the third similarity value can be selected and weighted to calculate the target similarity value. This application does not impose any limitations on this.
[0077] Step S605: If the target similarity value is less than a preset threshold, remove the first local image from the document region image to obtain the target document image.
[0078] As described above, by referring to one or more of the statistical feature dimension, structural dimension, and pixel distribution dimension for similarity calculation, the similarity between the first local image and the second local image can be comprehensively evaluated from multiple perspectives, thereby improving the accuracy of the calculation results.
[0079] Figure 10 A flowchart of a document image processing method, including a process of determining a document region image, is provided for embodiments of this application. Figure 10 As shown, the document image processing method includes the following steps: Step S1001: Obtain the original document image.
[0080] Step S1002: Perform document region detection on the original document image to determine the target region image.
[0081] Specifically, document region detection can be achieved by locating the quadrilateral region containing the document content through edge detection and contour analysis. Edge detection involves first denoising with Gaussian filtering, then calculating the gradient magnitude and direction, and finally extracting strong edges using non-maximum suppression and a double thresholding method to obtain the contour edges of the original document image. Contour analysis involves extracting all contours from the original document image based on the edge detection results, first filtering out tiny contours with areas smaller than a threshold, then performing polygon approximation on the remaining contours, calculating the number of vertices of the approximate polygon, and finally selecting the quadrilateral region with four vertices and the largest area. Based on this quadrilateral region, the aspect ratio of the target can be estimated. Specifically, this can be done by calculating the average width and average height based on the lengths of two pairs of opposite sides of the quadrilateral, and then dividing the average width by the average height to obtain the target aspect ratio. Then, the quadrilateral region is transformed into a rectangular region through perspective transformation. Specifically, the four vertices of the target region image are determined based on the target aspect ratio and preset resolution. Then, the perspective transformation matrix is solved based on the four vertices of the quadrilateral region and the four vertices of the target region image. Finally, the quadrilateral region is mapped through the perspective transformation matrix to obtain the target region image of the rectangular region, so as to eliminate perspective distortion and obtain the target region image with a rectangular shape.
[0082] Step S1003: Perform text detection on the target region image to obtain at least one text line, and perform text direction recognition based on the at least one text line to obtain the target document direction.
[0083] Since the document's orientation is determined by the text's orientation, the document's orientation can be determined based on the text content. Text detection can employ models such as EasyOCR and PP-OCR, which are not limited in this application. Text detection can locate the text portion in the target region image and extract at least one text line. A text line can be a horizontally or vertically arranged sequence of consecutive characters. Text orientation recognition can employ models such as PP-LCNet and VGG16, which are not limited in this application. In one embodiment, there are multiple text lines, and text orientation recognition is performed based on at least one text line. Specifically, text orientation recognition can be performed on each text line, and the text orientation that appears most frequently is selected as the target document orientation.
[0084] In another embodiment, Figure 11 A flowchart illustrating a process for determining the direction of a target document is provided in this application embodiment. The number of text lines is multiple, such as... Figure 11 As shown, the specific implementation process for text direction recognition based on at least one text line includes the following steps: Step S10031: Perform clustering processing on multiple text lines to obtain a set of text lines of a preset number of categories.
[0085] The preset number of categories can be a pre-defined total number of clustering categories. The clustering process can be based on the length of multiple text lines to classify and aggregate them; specifically, algorithms such as K-means and K-medoids can be used, which are not limited in this application. Specifically, the clustering process can calculate a corresponding number of cluster centers based on the preset number of categories. Each cluster center corresponds to a length value. For example, multiple initial cluster centers of the preset number of categories are randomly selected from the length values of the multiple text lines. The distance between the length value of each text line and these initial cluster centers is calculated, and the text lines are assigned to the category of the center with the smallest distance, forming multiple temporary text line sets of the preset number of categories. For each temporary text line set, the mean of the lengths of all text lines can be calculated as a new cluster center, and this text line assignment is repeated until the change in the number of cluster centers is less than a preset threshold, for example, the length change is less than a preset number of characters. Therefore, by aggregating multiple text lines based on the final obtained cluster centers, a corresponding text line set can be obtained.
[0086] Step S10032: Select a preset number of target text lines from the text line set according to the cluster center corresponding to each text line set.
[0087] In cases with a large number of text lines, identifying the orientation of each line would be inefficient. Therefore, for each set of text lines, the line with the smallest difference based on its corresponding cluster center can be selected to represent that set for orientation identification. This allows for the selection of a predetermined number of target text lines across different clusters.
[0088] Step S10033: Perform text direction recognition on a preset number of target text lines of each category, and determine the target document direction based on the recognition results.
[0089] Each target text line can be identified by its text direction to obtain a corresponding text direction. For example, horizontal... vertical Inverted And the vertical 270°. This text direction recognition can employ a direction classification model based on a CNN network or a Transformer network. By inputting each target text line image into the trained direction classification model, the probability of each text direction can be output, and the text direction with the highest probability is selected as the recognition result for that target text line. Optionally, the direction classification model can include an input layer, a feature extraction layer, and a classification layer. The input layer can be used to receive the target text line image. The feature extraction layer can include multiple convolutional blocks to extract the direction features of the target text line. The classification layer can include a fully connected layer and an activation function to output the probability value of the set text direction category. The target document direction is determined based on the recognition result. Specifically, it can be done by counting the number of times each set text direction appears among multiple text directions in the recognition result, and selecting the text direction with the most occurrences as the target document direction. For example, if the text direction corresponding to two target text lines is 0°, and the text direction corresponding to one target text line is 90°, since 0° appears most frequently, the target document direction should be 0°. Therefore, by clustering and filtering target text lines and then performing text direction recognition based on the target text lines, processing efficiency can be improved, and the recognition accuracy can be ensured by determining the target document direction based on the recognition results.
[0090] Step S1004: Rotate and correct the target region image based on the target document orientation to obtain the document region image.
[0091] Specifically, after determining the orientation of the target document, the target region image can be rotated and corrected to correspond to the orientation of the target document to obtain the document region image. Figure 12 This is a schematic diagram illustrating a process for obtaining a document region image from a rotation-corrected target region image, as provided in an embodiment of this application. Figure 12 As shown, rotation correction is performed on the target region image 1201 to obtain the document region image 201.
[0092] Optionally, for the rotated corrected document region image, grayscale distribution statistics or edge density and direction statistics can be performed to determine whether the document region image has non-rigid deformation (e.g., curling, wavy paper surface, etc.). For example, the document region image can be divided into multiple sub-regions of preset size, and the grayscale mean and variance of each sub-region can be calculated. If the grayscale mean and variance of different sub-regions differ significantly, exceeding a preset fluctuation range, it can be determined that the document region image has non-rigid deformation. Another example is that edge detection can be performed on the document region image to extract the edges. Then, the image can be divided into multiple sub-regions of preset size, and the edge density and main direction of each sub-region can be statistically analyzed. This density can be the ratio of the number of edge pixels to the total number of pixels in the sub-region. By comparing the edge density and main direction of different sub-regions, if there is obvious discontinuity or abnormal distribution, it can be determined that the document region has non-rigid deformation. Of course, other technical means for determining non-rigid deformation are also possible, and this application does not limit them. If the document region image exhibits non-rigid deformation, the SIFT or ORB algorithm can be used to detect feature points and extract multiple keypoints. Then, the document region image is divided into an equidistant two-dimensional network, with each network vertex serving as a control point. By matching multiple keypoints with a pre-defined flat document feature template, the correspondence between keypoints and control points can be determined. For each network unit, the pixel deformation parameters of that region can be calculated using the TPS or RBF interpolation formula based on this correspondence. Then, the coordinates of the pixels in that region are adjusted according to the deformation parameters of the network unit. Finally, all deformed network units are stitched together to obtain the document region image, restoring its original geometric structure and resulting in a flat document region image. Optionally, operations such as shadow removal, moiré suppression, and text transparency elimination can also be performed on the document region image to improve background purity and enhance text clarity.
[0093] Step S1005: Perform local extraction processing on the document region image to obtain a first local image of the adjacent boundary and a second local image related to the first local image.
[0094] Step S1006: Based on the similarity between the first local image and the second local image, remove the first local image from the document region image to obtain the target document image.
[0095] As described above, by recognizing the text direction based on the detected text lines, the orientation of the document content can be accurately determined, providing a reliable basis for rotation correction operations and providing document area images that conform to users' reading habits.
[0096] Figure 13This is a structural block diagram of a document image processing apparatus provided in an embodiment of this application. The apparatus is configured to execute the document image processing method provided in the above embodiments, and possesses corresponding functional modules and beneficial effects for executing the method. For example... Figure 13 As shown, the device specifically includes: The document region image determination module 1301 is configured to acquire an original document image and determine a document region image from the original document image; The local image determination module 1302 is configured to perform local extraction processing on the document region image to obtain a first local image of the adjacent boundary and a second local image related to the first local image; The target document image determination module 1303 is configured to remove the first local image from the document region image based on the similarity between the first local image and the second local image to obtain the target document image.
[0097] As described above, determining the document region image from the original document image can eliminate irrelevant backgrounds and reduce interference factors in subsequent processing. Local extraction processing of the document region image yields a first local image of the adjacent boundaries and a second local image related to the first local image, allowing for local image extraction tailored to the location characteristics of the black border. Based on the similarity between the first and second local images, their similarity can be quantified to accurately determine whether the first local image belongs to the black border region. When the target similarity value is less than a preset threshold, removing the first local image from the document region image to obtain the target document image removes the abnormal influence of the black border, improving the visual purity of the image. This scheme can accurately identify the local image corresponding to the black border in the document region image using content similarity, remove this local image, retain valid image content, improve image quality, and ensure the accuracy and stability of downstream tasks.
[0098] In one possible embodiment, the target document image determination module 1303 is further configured to: The target similarity value is obtained by performing similarity calculation based on the first local image and the second local image. If the target similarity value is less than a preset threshold, the first local image is removed from the document region image to obtain the target document image.
[0099] In one possible embodiment, the target document image determination module 1303 is further configured to: A first similarity value is obtained by performing statistical feature similarity calculation on the first local image and the second local image; and / or a second similarity value is obtained by performing structural similarity calculation on the first local image and the second local image; and / or a third similarity value is obtained by performing pixel distribution similarity calculation on the first local image and the second local image. The target similarity value is determined based on at least one of the first similarity value, the second similarity value, and the third similarity value.
[0100] In one possible embodiment, the target document image determination module 1303 is further configured to: Calculate the mean and variance of the first pixel corresponding to the first local image, and calculate the mean and variance of the second pixel corresponding to the second local image; The first similarity value is calculated based on the mean of the first pixel, the mean of the second pixel, the variance of the first pixel, and the variance of the second pixel.
[0101] In one possible embodiment, the target document image determination module 1303 is further configured to: Calculate the first average brightness and first contrast corresponding to the first local image, and calculate the second average brightness and second contrast corresponding to the second local image; Calculate the covariance based on the first local image and the second local image; The second similarity value is calculated based on the first average brightness, the first contrast ratio, the second average brightness, the second contrast ratio, and the covariance.
[0102] In one possible embodiment, the target document image determination module 1303 is further configured to: Count the number of first pixels in each preset color interval of the first partial image, and count the number of second pixels in each preset color interval of the second partial image; The first average value is calculated based on the number of first pixels corresponding to each preset color interval, and the second average value is calculated based on the number of second pixels corresponding to each preset color interval. The third similarity value is calculated based on the first average value, the first average value, and the number of first and second pixels corresponding to each preset color interval.
[0103] In one possible embodiment, the target document image determination module 1303 is further configured to: The first local image is segmented and stitched together to obtain the first stitched image; The second local image is segmented and stitched together to obtain the second stitched image; The similarity value of the target image is obtained by performing similarity calculation on the first stitched image and the second stitched image.
[0104] In one possible embodiment, the target document image determination module 1303 is further configured to: The number of segments is determined based on the aspect ratio of the first local image, and the long side direction and short side direction are determined by boundary direction recognition of the first local image. The first local image is divided into multiple image segments along the long side according to the number of segments; The first stitched image is obtained by stitching together multiple image segments along the short side.
[0105] In one possible embodiment, the document region image determination module 1301 is further configured to: Document region detection is performed on the original document image to determine the target region image; Text detection is performed on the target region image to obtain at least one text line, and text direction recognition is performed based on the at least one text line to obtain the target document direction; The document region image is obtained by rotating and correcting the target region image based on the target document orientation.
[0106] In one possible embodiment, the document region image determination module 1301 is further configured to: Clustering multiple lines of text yields a set of text lines with a preset number of categories; Based on the cluster center corresponding to each set of text lines, select a preset number of target text lines of each category from the set of text lines; The system identifies the text direction of a preset number of target text lines and determines the target document direction based on the identification results.
[0107] In one possible embodiment, a count module is also included, configured as follows: The cumulative number of times local image removal was performed on a document region image; The target document image determination module 1303 is also configured as follows: If the cumulative count does not reach the preset count, the first local image is removed from the document region image to obtain the target document image.
[0108] Figure 14 This is a schematic diagram of the structure of a document image processing device provided in an embodiment of this application, such as... Figure 14 As shown, the device includes a processor 1401, a memory 1402, an input device 1403, and an output device 1404; the number of processors 1401 in the device can be one or more. Figure 14 Taking a processor 1401 as an example; the processor 1401, memory 1402, input device 1403, and output device 1404 in the device can be connected via a bus or other means. Figure 14Taking a bus connection as an example, the memory 1402, as a computer-readable storage medium, can be configured to store software programs, computer-executable programs, and modules, such as the program instructions / modules corresponding to the document image processing method in this embodiment. The processor 1401 executes various functional applications and data processing of the device by running the software programs, instructions, and modules stored in the memory 1402, thereby implementing the aforementioned document image processing method. The input device 1403 can be configured to receive input digital or character information and generate key signal inputs related to user settings and function control of the device. The output device 1404 may include a display device such as a screen.
[0109] The document image processing device provided above can be used to execute the document image processing method provided in any of the above embodiments, and has corresponding functions and beneficial effects.
[0110] This application also provides a non-volatile storage medium containing computer-executable instructions, which, when executed by a computer processor, are configured to perform a document image processing method described in the above embodiments, comprising: acquiring an original document image; determining a document region image from the original document image; performing local extraction processing on the document region image to obtain a first local image of adjacent boundaries and a second local image related to the first local image; and removing the first local image from the document region image based on the similarity between the first local image and the second local image to obtain a target document image.
[0111] Storage medium – any type of memory device or storage device. The term “storage medium” is intended to include: mounting media, such as CD-ROMs, floppy disks, or magnetic tape devices; computer system memory or random access memory, such as DRAM, DDR RAM, SRAM, EDO RAM, Rambus RAM, etc.; non-volatile memory, such as flash memory, magnetic media, optical storage; registers or other similar types of memory elements, etc. Storage media may also include other types of memory or combinations thereof. Furthermore, storage media may reside in a first computer system in which the program is executed, or may reside in a different second computer system connected to the first computer system via a network (such as the Internet). The second computer system can provide program instructions to the first computer for execution. The term “storage medium” can include two or more storage media residing in different locations (e.g., in different computer systems connected via a network). Storage media may store program instructions (e.g., specifically implemented as a computer program) executable by one or more processors.
[0112] Of course, the computer-executable instructions provided in the embodiments of this application are not limited to the document image processing method described above, but can also perform related operations in the document image processing method provided in any embodiment of this application.
[0113] It should be noted that the numbering of each step in this solution is only used to describe the overall design framework of this solution and does not indicate a necessary sequential relationship between the steps. As long as the overall implementation process conforms to the overall design framework of this solution, it falls within the protection scope of this solution. The literal order in the description is not an exclusive limitation on the specific implementation process of this solution. Those skilled in the art should understand that the embodiments of this application can be provided as methods, systems, or computer program products. In a typical configuration, a computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory. Memory may include non-persistent memory in computer-readable media, random access memory (RAM), and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0114] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0115] Note that the above description is merely a preferred embodiment of the present invention and the technical principles employed. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and various obvious changes, readjustments, and substitutions can be made without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in detail through the above embodiments, the present invention is not limited to the above embodiments, and may include many other equivalent embodiments without departing from the concept of the present invention, the scope of which is determined by the scope of the appended claims.
Claims
1. A document image processing method, characterized in that, include: Acquire the original document image, and determine the document region image from the original document image; The document region image is subjected to local extraction processing to obtain a first local image of the adjacent boundary and a second local image related to the first local image; Based on the similarity between the first local image and the second local image, the first local image is removed from the document region image to obtain the target document image.
2. The document image processing method according to claim 1, characterized in that, The step of removing the first local image from the document region image based on the similarity between the first local image and the second local image to obtain the target document image includes: A target similarity value is obtained by performing similarity calculations based on the first local image and the second local image. If the target similarity value is less than a preset threshold, the first local image is removed from the document region image to obtain the target document image.
3. The document image processing method according to claim 2, characterized in that, The step of calculating the target similarity value based on the first local image and the second local image includes: A first similarity value is obtained by performing statistical feature similarity calculation on the first local image and the second local image; and / or a second similarity value is obtained by performing structural similarity calculation on the first local image and the second local image; and / or a third similarity value is obtained by performing pixel distribution similarity calculation on the first local image and the second local image. The target similarity value is determined based on at least one of the first similarity value, the second similarity value, and the third similarity value.
4. The document image processing method according to claim 3, characterized in that, The step of calculating the first similarity value by performing statistical feature similarity calculation on the first local image and the second local image includes: Calculate the first pixel mean and first pixel variance corresponding to the first local image, and calculate the second pixel mean and second pixel variance corresponding to the second local image; A first similarity value is calculated based on the first pixel mean, the second pixel mean, the first pixel variance, and the second pixel variance.
5. The document image processing method according to claim 3, characterized in that, The step of calculating the structural similarity between the first local image and the second local image to obtain a second similarity value includes: Calculate the first average brightness and first contrast corresponding to the first local image, and calculate the second average brightness and second contrast corresponding to the second local image; Calculate the covariance based on the first local image and the second local image; A second similarity value is calculated based on the first average brightness, the first contrast ratio, the second average brightness, the second contrast ratio, and the covariance.
6. The document image processing method according to claim 3, characterized in that, The step of calculating the pixel distribution similarity between the first local image and the second local image to obtain a third similarity value includes: The number of first pixels in each preset color interval of the first partial image is counted, and the number of second pixels in each preset color interval of the second partial image is counted. A first average value is calculated based on the number of first pixels corresponding to each of the preset color intervals, and a second average value is calculated based on the number of second pixels corresponding to each of the preset color intervals. A third similarity value is calculated based on the first average value, the first average value, and the number of first and second pixels corresponding to each of the preset color intervals.
7. The document image processing method according to claim 2, characterized in that, The step of calculating the target similarity value based on the first local image and the second local image includes: The first local image is segmented and stitched together to obtain the first stitched image; The second local image is segmented and stitched together to obtain the second stitched image; The target similarity value is obtained by performing similarity calculation on the first stitched image and the second stitched image.
8. The document image processing method according to claim 7, characterized in that, The step of segmenting and stitching the first local image to obtain the first stitched image includes: The number of segments is determined based on the aspect ratio of the first local image, and the long side direction and short side direction are determined by boundary direction recognition of the first local image. The first local image is divided into multiple image segments along the long side according to the number of segments. The multiple image segments are stitched together along the short side to obtain the first stitched image.
9. The document image processing method according to claim 1, characterized in that, Determining the document region image from the original document image includes: The original document image is subjected to document region detection to determine the target region image; Text detection is performed on the target region image to obtain at least one text line, and text direction recognition is performed based on the at least one text line to obtain the target document direction; The target region image is obtained by rotating and correcting the target region image based on the target document orientation.
10. The document image processing method according to claim 9, characterized in that, The number of text lines is multiple, and the step of obtaining the target document direction based on the text direction recognition of at least one text line includes: Clustering is performed on multiple text lines to obtain a preset number of text line sets in each category; Based on the cluster center corresponding to each set of text lines, a preset number of target text lines of each category are selected from the set of text lines. The text direction of the preset number of target text lines is identified, and the direction of the target document is determined based on the identification results.
11. The document image processing method according to any one of claims 1-10, characterized in that, Before removing the first local image from the document region image to obtain the target document image, the method further includes: The cumulative number of times local image removal was performed on the document region image is counted; The step of removing the first local image from the document region image to obtain the target document image includes: If the cumulative number of times does not reach the preset number, the first local image is removed from the document region image to obtain the target document image.
12. A document image processing apparatus, characterized in that, include: The document region image determination module is configured to acquire an original document image and determine a document region image from the original document image; The local image determination module is configured to perform local extraction processing on the document region image to obtain a first local image of the adjacent boundary and a second local image adjacent to the first local image; The target document image determination module is configured to remove the first local image from the document region image based on the similarity between the first local image and the second local image to obtain the target document image.