Method and device for repairing damaged archives

By performing color histogram matching, local adaptive enhancement, sharpening processing and perspective correction on the image, the problem of lack of targeted image enhancement in the prior art is solved, and efficient image repair and detail recovery are achieved.

CN120198330AInactive Publication Date: 2025-06-24NEW GENERATION INTELLIGENT TECHNOLOGY DEVELOPMENT (SHANDONG) CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510326939.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-19
Publication Date
2025-06-24
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The prior art lacks targetedness in the image enhancement process, making it difficult to accurately identify and process image damage features of varying degrees, such as color deviation, uneven contrast, blurred detail texture and perspective deformation distortion.

Method used

By selecting damaged and undamaged archival images, color histogram data of undamaged images are collected, histogram matching adjustment is performed, and color correction images are generated. Then, local adaptive enhancement and sharpening are performed, perspective distortion is identified and corrected, and finally quality evaluation is performed to complete image repair.

Benefits of technology

Accurate reproduction of image color features is achieved, the authenticity and color consistency of the image is improved, local contrast is enhanced, image details are refined, the spatial structure of the image is reconstructed, and visual authenticity and recognition are improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120198330A_ABST
    Figure CN120198330A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of image enhancement, in particular to a damaged archive restoration method and device, and the method comprises the following steps: selecting a group of damaged archive images and undamaged archive images, and collecting a color histogram of the undamaged archive images to obtain color histogram data; and based on the color histogram data, adjusting a color histogram of the damaged archive image through a histogram matching technology, matching histogram distribution of the undamaged archive image, and generating a color correction image. According to the method, through matching correction of the image color histograms of the damaged archives and the undamaged archives, the original color features of the archives are accurately reproduced, the interference of human subjective factors on the restoration result is effectively reduced, and the authenticity and color consistency of the restored image are improved; due to the introduction of the local adaptive enhancement technology, the contrast ratio of each local area of the archive image is more prominent, and the problem of overexposure or detail missing possibly caused by overall unified enhancement is avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image enhancement, and particularly to a method and device for repairing damaged archives. Background Art

[0002] Image enhancement is a technical field that improves, optimizes, or reconstructs images through digital image processing techniques. Its goal is to enhance the visual effect, clarity of the image, or facilitate subsequent analysis and processing.

[0003] In the existing technology, there are deficiencies in the single and lack of pertinence in the image enhancement process during actual operation. Usually, the overall optimization or simple single operation is directly implemented on the image, ignoring the complex and diverse damage characteristics of the damaged archive images, such as different degrees of color deviation, uneven contrast, blurred detail texture, and perspective distortion. It is difficult to accurately identify and take differential processing. Therefore, improvements are needed. Summary of the Invention

[0004] The purpose of the present invention is to solve the disadvantages existing in the prior art, and to propose a method and device for repairing damaged archives.

[0005] To achieve the above purpose, the present invention adopts the following technical solutions. A method for repairing damaged archives includes the following steps: Select a group of damaged archive images and undamaged archive images, collect the color histogram of the undamaged archive images to obtain color histogram data; based on the color histogram data, adjust the color histogram of the damaged archive images through histogram matching technology to match the histogram distribution of the undamaged archive images, and generate a color-corrected image; Receive the color-corrected image, perform local adaptive enhancement processing on the color-corrected image to enhance the local contrast of the image, and obtain a contrast-enhanced image; perform sharpening processing on the contrast-enhanced image to refine the details and textures in the image, and obtain a detail-sharpened image; Analyze the geometric structure of the detail-sharpened image, identify the perspective distortion part that needs to be corrected, and obtain a perspective analysis result; based on the perspective analysis result, calculate the ideal viewing angle, and automatically adjust the perspective of the image to generate a perspective-corrected image; Perform quality assessment on the perspective-corrected image, check the clarity of the image, and verify whether the image details are restored to complete the repair of the damaged archive image.

[0006] Preferably, the step of obtaining the color histogram data is as follows: Select a group of undamaged archive images and the same number of damaged archive images to obtain a damaged archive image group and an undamaged archive image group; For each image in the group of undamaged archival images, collect the color histogram, analyze the color channel distribution of each image one by one, and record the data of the color channels to obtain the color histogram data set of the undamaged archival images; Based on the color histogram data set of the undamaged archival images, organize and unify the data formats of the color histograms of each image to form color histogram data.

[0007] Preferably, the steps for obtaining the color-corrected image are as follows: Based on the color histogram data, select damaged archival images and undamaged archival images, set the same number of histogram bins for each color channel of each image, uniformly collect and record the color value distribution in each bin, and generate the color histogram data sets of the damaged archival images and the undamaged archival images; Based on the color histogram data sets of the damaged archival images and the undamaged archival images, calculate the color adjustment amount; Based on the color adjustment amount, adjust the color values of the damaged image bin by bin, approximate the color histogram of the damaged image to the histogram distribution of the undamaged image, and obtain the color-corrected image.

[0008] Preferably, the steps for obtaining the contrast-enhanced image are as follows: Receive the color-corrected image, analyze the local regions in the image, evaluate the contrast level of each region, identify the low-contrast regions, and form a low-contrast region marker set; Based on the low-contrast region marker set, calculate the enhanced color values; Based on the enhanced color values, perform color reconstruction on the low-contrast regions of the image, adjust the color histogram of the low-contrast regions, and generate the contrast-enhanced image.

[0009] Preferably, the steps for obtaining the detail-sharpened image are as follows: Receive the contrast-enhanced image, analyze the texture and detail levels of the entire image, identify the regions that need to be sharpened, and obtain the texture region data set; Based on the texture region data set, calculate the sharpening intensity for each point; Based on the sharpening intensity, apply the sharpening intensity to the image, refine the texture and details by enhancing the contrast of the image details, and form the detail-sharpened image.

[0010] Preferably, the steps for obtaining the perspective analysis result are as follows: Extract geometric features from the detail-sharpened image, analyze the straight lines, intersection points and edges in the image, apply the Hough transform to detect the perspective-deformed edges, calculate the angles and intersection point information of each straight line, screen the regions with perspective distortion, and generate the preliminary perspective distortion candidate region data set; Calculate the perspective distortion deviation based on the preliminary perspective distortion candidate region dataset; Based on the perspective distortion deviation, evaluate the deformation degree of each region, screen out the parts with perspective distortion exceeding the threshold, and generate a perspective analysis result.

[0011] Preferably, the steps for obtaining the perspective correction image are as follows: Based on the perspective analysis result, extract the four corner point coordinates of the deformed region, establish a projection transformation matrix, calculate the mapping positions of the corner points in the standard rectangular coordinate system, analyze the offset degree between the corner points and the theoretical corner points, and obtain a perspective offset coordinate set; Calculate the viewing angle offset based on the perspective offset coordinate set; Based on the viewing angle offset, construct a projection transformation matrix, perform coordinate mapping on the perspective distortion region in sequence, convert the deformed region to the standard rectangular coordinate system, and generate a perspective correction image.

[0012] Preferably, the steps for performing quality evaluation on the perspective correction image, checking the clarity of the image, and verifying whether the image details are restored to complete the repair of the damaged archive image are as follows: Calculate the image quality index based on the perspective correction image; Based on the image quality index, identify the blurred regions and optimize them by sharpening and contrast enhancement to complete the repair of the damaged archive image.

[0013] The present invention provides a repair device, including: a processor and a memory. The memory is used to store a computer program, and the processor is used to call and run the computer program stored in the memory, so that the repair device executes the damaged archive repair method.

[0014] Compared with the prior art, the advantages and positive effects of the present invention are as follows: Through the matching correction of the color histograms of the damaged archive and the undamaged archive image, the present invention accurately reproduces the original color characteristics of the archive, effectively reduces the interference of human subjective factors on the repair result, and improves the authenticity and color consistency of the repaired image; the introduction of the local adaptive enhancement technology makes the contrast of each local region of the archive image more prominent, avoiding the problems of overexposure or missing details that may be caused by overall unified enhancement; further sharpening the image detail texture, mining and strengthening the subtle features that are easily overlooked in the archive image, realizing a deeper level of mining of the image detail information, and improving the recognition degree and information identification ability of the image; by analyzing the geometric structure of the image and identifying the perspective distortion, the present invention pertinently corrects the possible deformation and distortion in the image, thereby accurately reconstructing the spatial structure of the image and improving the visual authenticity and spatial sense of the archive image. Description of the Drawings

[0015] Figure 1 Schematic diagram of the steps of the present invention. Specific implementation manners

[0016] In order to make the objectives, technical solutions and advantages of the present invention more clear and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0017] Please refer to Figure 1 , the present invention provides a technical solution, a method for repairing damaged archives, including the following steps: Select a group of damaged archive images and undamaged archive images, collect the color histogram of the undamaged archive images to obtain color histogram data; based on the color histogram data, adjust the color histogram of the damaged archive images through histogram matching technology to match the histogram distribution of the undamaged archive images and generate a color-corrected image; Receive the color-corrected image, perform local adaptive enhancement processing on the color-corrected image to enhance the local contrast of the image and obtain a contrast-enhanced image; perform sharpening processing on the contrast-enhanced image to refine the details and textures in the image and obtain a detail-sharpened image; Analyze the geometric structure of the detail-sharpened image, identify the perspective distortion parts that need to be corrected to obtain a perspective analysis result; based on the perspective analysis result, calculate the ideal viewing angle and automatically adjust the perspective of the image to generate a perspective-corrected image; Perform quality assessment on the perspective-corrected image, check the clarity of the image, and verify whether the image details are restored to complete the repair of the damaged archive image.

[0018] The steps for obtaining the color histogram data are as follows: Select a group of undamaged archive images and the same number of damaged archive images to obtain a damaged archive image group and an undamaged archive image group; For each image in the undamaged archive image group, perform color histogram collection, analyze the color channel distribution of each image one by one, and record the data of the color channels to obtain an undamaged archive image color histogram data set; Based on the undamaged archive image color histogram data set, organize and unify the data formats of the color histograms of each image to form color histogram data.

[0019] Specifically, to determine which archival images belong to the categories of undamaged and damaged, it is necessary to first determine the degree of damage for all accessible archival images in the storage medium. When making the determination, a damage ratio threshold set according to experience can be used for comparison. For example, first calculate the ratio of the intact pixel area to the damaged pixel area for any archival image, and divide the damaged pixel area by the total number of pixels in the image to obtain the damage ratio. Suppose the threshold for this damage ratio is set to 0.15, which is summarized through multiple actual tests. If the damage ratio of a certain image exceeds 0.15, it is judged as a damaged image; otherwise, it is judged as an undamaged image. Subsequently, randomly select a specified number of images from the damaged images to form a candidate set of damaged archival images, and randomly select the same number of images from the undamaged images to form a candidate set of undamaged archival images. To ensure that different shooting resolutions or the diversity of document appearances from different eras are taken into account during random sampling, all images can be first divided according to resolution intervals and era intervals. For example, the resolution is divided into two intervals: 200 to 600 dpi and 600 to 1200 dpi, and the era is divided into intervals of five years each. Then, the determination of the damage ratio and sampling statistics are completed separately in each interval, and the images extracted from each interval are merged into a unified library. Finally, these damaged and undamaged samples are combined and classified and marked, and ultimately, a group of damaged archival images and a group of undamaged archival images are obtained.

[0020] When performing histogram statistics on the color channels of each image in the group of undamaged archival images, it is necessary to first parse each image into multiple pixel points and read the three-channel brightness values. If standard RGB encoding is used, the values of each channel can be defined as ranging from 0 to 255. Then, a fixed number of histogram bins are set using the method of equal-width division. For example, 256 bins are defined, with each bin having a width of 1. All pixels are traversed in sequence, and the channel values of the corresponding pixels are mapped to the corresponding bins for counting. To exclude the interference of extreme outliers, a reference interval can be set separately, such as determining the effective brightness range to be between 0 and 255. If the pixel value is not within this range, it will be recorded as an abnormal pixel, and after the statistics are completed, additional comparison will be made based on the number of abnormal pixels. If the proportion of abnormal pixels is higher than the 5% threshold given by empirical statistics, the image needs to be re-verified in subsequent analysis. If the proportion of abnormal pixels does not exceed this threshold, it is regarded as a normal image and the corresponding histogram count is retained. After traversing all the pixels of all images, the histogram count results of the three channels can be generated in the software and recorded one by one, and finally, a color histogram data set of undamaged archival images is obtained.

[0021] Based on the color histogram dataset of undamaged archival images, it is necessary to uniformly process the histograms generated by different images in terms of format. For example, first concatenate the three-channel histograms of each image into a one-dimensional array in the same order, and ensure that each channel uses the same number of bucket counts. To examine the difference in brightness or contrast between different images, a control step can also be added after the statistics. Superimpose all histogram distributions and compare the gap between the maximum and minimum values. If the channel counts of a certain image are too concentrated in some bucket positions and exceed the maximum concentration threshold determined by practice, for example, set this threshold to 80% and use the proportion of the total number of pixels as a measurement reference, then it is necessary to check again whether there is overexposure or underexposure when the image was taken or scanned. If there is no problem, keep it; otherwise, decide whether to exclude or re-acquire the image according to actual needs. After the above steps, the trimmed histogram data of each image is uniformly classified into the same representation dimension and serialized for subsequent calls, finally forming the color histogram data.

[0022] The steps to obtain the color-corrected image are as follows: Based on the color histogram data, select damaged archival images and undamaged archival images, set the same number of histogram bins for each color channel of each image, uniformly collect and record the color value distributions in each bin, and generate the color histogram dataset of damaged archival images and undamaged archival images; Based on the color histogram dataset of damaged archival images and undamaged archival images, calculate the color adjustment amount through the calculation formula: ; where, the color adjustment amount, represents the color value of the undamaged archival image in the th histogram bin, represents the color value of the damaged archival image in the same histogram bin, is the total number of histogram bins; Based on the color adjustment amount, adjust the color values of the damaged image bucket by bucket to approximate the color histogram of the damaged image to the histogram distribution of the undamaged image, and obtain the color-corrected image.

[0023] Specifically, based on the color histogram data, during the execution process, it is necessary to first select the corresponding original image data and confirm the damaged or undamaged type of each image. Specifically, it can be classified by judging the damaged pixel ratio or other integrity indication information recorded in the previous step. Then, the pixel values of these images are compared in multiple directions according to the previously obtained color histogram data. If the comparison result shows that the proportion of the complete pixel area corresponding to the image is lower than a pre-set threshold. For example, a damaged ratio threshold of 0.10 can be determined through actual statistics of multiple batches of samples, then it is regarded as damaged. If the damaged ratio does not exceed 0.10, it is regarded as undamaged. On this basis, during the process of reading the three-channel color distribution of each image, the pixels need to be divided into a fixed number of histogram bins. For example, the value range of the channel from 0 to 255 is divided into 256 bins. Each pixel point is traversed to determine its position in the corresponding bin, and at the same time, the cumulative pixel count in each bin is recorded at the software level. When all pixels are processed, the corresponding statistical results can be obtained. To enhance the stability during the troubleshooting process, an auxiliary verification step can also be added after the statistics are completed. For example, calculate the proportion distribution of each bin in the total number of pixels. If it is found that the proportion of a certain bin exceeds an empirical threshold, the color aggregation areas of the damaged image and the undamaged image can be further compared. And this empirical threshold also needs to be set through multiple rounds of comparison and verification. For example, it can be summarized and statistically analyzed from the distribution results of 200 damaged images and 200 undamaged images. When the pixel proportion of a single bin is greater than 0.30 for a long time, it often indicates that there is an over-concentrated distribution phenomenon in the image, and it can be inferred whether there is additional scanning or abnormal shooting. After the obtained clustering results are verified with the original classification information, the statistical data of the damaged images and the undamaged images are respectively integrated and marked, and then the corresponding mapping data is established according to the same channel order and the number of bins. In this way, a complete set of color histogram datasets of damaged archive images and undamaged archive images is formed. After all the preparatory work is completed, all the above data are summarized, and finally, the color histogram datasets of damaged archive images and undamaged archive images are obtained.

[0024] The benefit of the formula is that by comparing the color distribution differences between the undamaged and damaged images bin by bin, a quantified difference value is obtained, and the same number of bins is uniformly used within the same channel, making the difference calculation comparable and consistent. Thus, in the subsequent image adjustment, it can be gradually corrected bin by bin, making the color correction process more targeted and refined.

[0025] The steps for obtaining the parameter are that it represents the undamaged image at the The color values of each histogram bucket need to be statistically counted pixel by pixel based on the real scanned image file. First, clarify the color value range corresponding to each bucket, and then traverse all the pixels of the image, map the pixel values to the corresponding buckets and accumulate the counts. After completing the traversal, the histogram distribution of the R channel of this image can be obtained. Perform the same operation on multiple undamaged images and merge the corresponding R channel counts in a fixed order. Finally, compare the merged data to determine the average count or total count of each bucket. Example: During the traversal of the R channel, if a total of 200,000 pixels of a batch of undamaged images enter the th bucket, then let .

[0026] The steps to obtain the parameter are as follows. It represents the color value of the damaged image in the th histogram bucket. The acquisition method is similar to that of the undamaged image, and it needs to be accumulated pixel by pixel during the traversal of the damaged image. The noise pixels also need to be included in a separate record and removed. In addition, since the damaged image may have larger areas or random damaged blocks, the proportion of the damaged area needs to be monitored additionally during the traversal. If the proportion of the damaged area exceeds the pre-set 0.10, it is determined as an image with a high degree of damage. Example: If after the R channel bucket value statistics of a certain damaged image, the number of pixels corresponding to the th bucket is 105,000, then .

[0027] The steps to obtain the parameter are as follows. It represents the total number of histogram buckets, which can be determined by analyzing the resolution of the target image, the shooting or scanning environment, and the requirements for dividing the brightness range. When usually performing statistics on grayscale or single-channel R, G, B, if the pixel values are equally divided from 0 to 255, then ; Example: When processing the scanned images of a certain collection in the archive, the R & D personnel collected 1,000 scanned copies from different years. After analyzing, the brightness range of their R channels mainly concentrated in 50 to 200, and the remaining pixels were less distributed in 0 to 50 and 200 to 255. At the same time, testing 64 segments would cause the frequency of some segments to be overly concentrated and unable to distinguish the damaged details, while testing 256 segments would make the calculation amount slightly large. After comprehensive balance, it is more appropriate to adopt 128 segments. So set .

[0028] Calculation process: The following gives an actual operation example. Let , and at the same time select some bucket values of a certain group of images in the R channel for calculation. Assume that in the comparison result, the number of buckets of a certain damaged image in the th bucket is , and at the same time the number of buckets of the corresponding undamaged image in the th bucket is , After the comparison is completed for all 128 buckets, for the sake of brevity, only a part of the calculation process is given here: First step, calculate the squared difference for each bucket: ; Second step, accumulate this value to the sum of the squared differences of all buckets and divide by , assuming that the sum of the squared difference values of the other 127 buckets is , then: ; ; Third step, finally take the square root to get : ; This result indicates that if the value is larger, it means that the color distribution difference between the damaged image and the undamaged image is more obvious. If the value is smaller, it means that the degree of closeness between the two is higher. After the calculation and summary of all channels are completed, subsequent color compensation or correction of different amplitudes can be carried out according to the value in the refined correction of the buckets, thus laying a foundation for finally generating a color-corrected image that is closer to the distribution of the undamaged image.

[0029] Based on the color adjustment amount, during the execution process, it is necessary to combine the value obtained previously to perform bucket comparison on the pixel values of each channel of the damaged image. First, disperse all the pixels of the damaged image in the R, G, and B channels into the corresponding multiple histogram buckets. Each bucket can find the comparison benchmark from the obtained previously and the relevant histogram statistical data. When comparing, it can be in units of single buckets. For example, first calculate the color correction ratio of the corresponding bucket, and this correction ratio can be based on Divide several intervals between 0 and a certain upper limit, and increase them step by step according to the degree of color difference. Then, perform a larger pixel value correction on the buckets with a higher degree of difference, and perform a smaller correction on the buckets with a lower degree of difference. To avoid excessive distortion during the correction process, a smoothing threshold can be set. This smoothing threshold is determined by referring to the color change range of the same batch of images before. For example, statistically analyze the brightness correction amplitude of a series of archival images. When the difference ratio is greater than 0.20, perform stretching or compression of larger color values. If it is less than 0.20, perform a smaller adjustment. It should be noted that the value of 0.20 can be determined by statistically analyzing the color value distribution after scanning 500 pieces of archival data on-site and comparing whether there are prominent faults. When the fault frequency is greater than 5 times, it indicates that the color transition is not smooth enough, and this parameter needs to be reduced or increased. Therefore, in specific implementation, multiple rounds of tests are usually carried out first to finally lock a smoothing threshold. Next, when performing color correction on each bucket, the recorded pixel average value will be read, compared with the average value of the undamaged image, and combined with the overall numerical distribution to obtain a new pixel value. For example, when the average value of a certain bucket in the R channel of the damaged image is 100 and the corresponding undamaged image is 128, and it is determined that the difference in this bucket belongs to the higher interval according to obtained previously, the pixel value can be stretched in the direction of 128. If the difference belongs to the lower interval, it can approach 128 while retaining a small amount of original image information. After such bucket-by-bucket adjustments, a global balancing operation is performed on the entire image to maintain the basic consistency between channels. When the entire bucket correction process is completed, a color-corrected image is obtained.

[0030] The steps to obtain a contrast-enhanced image are as follows: Receive the color-corrected image, analyze the local regions in the image, evaluate the contrast level of each region, identify the low-contrast regions, and form a low-contrast region marker set; Based on the low-contrast region marker set, calculate the enhanced color value. The calculation formula is: ; where, is the enhanced color value, represents the original color value of the image at position (x, y), is a small constant, and respectively represent the average value and standard deviation of the color values within the local region; Based on the enhanced color values, perform color reconstruction on the low-contrast regions of the image, adjust the color histogram of the low-contrast regions, and generate a contrast-enhanced image.

[0031] Specifically, after receiving the color-corrected image, it is necessary to statistically calculate the brightness and color values point by point for each local area and evaluate its contrast level. The evaluation of the contrast can be completed by calculating the difference range of the gray or color values within the area. In specific operations, the image can be first divided into several grid blocks of equal size. The size of each grid block can be set according to the scanning resolution and the density of the archival text or graphics. For example, each grid block contains 20×20 pixel points. Then, all pixel values are read one by one and their local contrast is obtained through differential calculation. If the local contrast value is less than a certain contrast threshold, the grid block is marked as a low-contrast area. The setting of the threshold can be determined through multiple rounds of sampling tests. For example, 300 sample images are selected from the data of a certain archive, the average contrast distribution of the normally readable areas in each image is recorded, and the median is calculated after summarizing these distributions. If the median statistical value is 0.15, then 0.15 is used as the contrast threshold. When the contrast of a single area is lower than 0.15, it is recorded as a low-contrast area, and the area with a contrast higher than or equal to 0.15 is marked as a normal area. At the same time, a verification step can be added after the marking. For example, if multiple consecutive adjacent grid blocks are identified as low-contrast areas, it is necessary to re-scan or re-check the brightness difference of local pixels. After all grid blocks are compared, the coordinate ranges of all the marked low-contrast areas are sorted out and classified and summarized, and finally a functional data set is formed as the main input data for subsequent color enhancement processing to obtain the low-contrast area marking set.

[0032] The advantage of the formula is that by introducing both the average value and the standard deviation of the local area into the denominator, it can dynamically adjust the original color value. When the average value of the local area is higher or the standard deviation is larger, the enhanced pixel color value will be correspondingly reduced, so as to balance the light and dark distribution of the image as a whole and avoid over-amplifying some brighter or darker pixels.

[0033] The steps for obtaining the parameter are that this parameter represents the original color value of the image at the position and usually comes from reading the pixel data in the image file. Example: For a pixel in the local area, its R-channel reading is 120, G-channel reading is 110, and B-channel reading is 100, then record and it can be substituted into the formula respectively or first converted into a gray value and then processed during subsequent operations.

[0034] The steps for obtaining the parameter are that this parameter is a small constant to prevent the denominator from being too small or zero.

[0035] The steps for obtaining the parameter are as follows. This parameter represents the average color value within a local area. Different pixel channels can calculate and take corresponding values separately. During specific operations, the neighborhood of the current pixel point will be traversed, such as N pixel points in each of the up, down, left, and right directions, thus forming a local area. Then, the color values of all pixels within this area are added together, and the sum is divided by the number of pixels to obtain the average value. To reduce the interference of extreme outliers, abnormal pixels with a proportion exceeding a certain fixed threshold can be excluded before calculation. The method for setting the threshold can be determined in combination with the statistical distribution of the scanned samples. For example, if it is found in the statistical analysis of the local areas of 200 images that the proportion of extreme outliers is usually below 0.02, then 0.03 can be set as the exclusion threshold. The following gives an example of obtaining: When the number of pixels in the local area is 49 and the sum of the total brightness values is 4410, then .

[0036] The steps for obtaining the parameter are as follows. This parameter represents the standard deviation of the color values within a local area. It is necessary to calculate each pixel in the local area one by one and accumulate them. Then, the accumulated value is divided by the total number of pixels in the area to obtain the variance. Then, the square root of the variance is taken to obtain . In the operation, if it is necessary to avoid the variance inflation caused by extreme pixels, it can also be the same as the calculation of . Some outliers that appear more than a specific threshold are excluded in advance, so that this standard deviation is closer to the true distribution. The following gives an example of obtaining: If there are 49 pixels in the local area and the sum , then the variance is , and the standard deviation .

[0037] Calculation process: When calculating the pixels at position in a certain archival image, first obtain , then the average value of the pixels in the neighborhood , the standard deviation of the pixels in the neighborhood , and set , obtained from the previous statistics. Substitute these values into the formula: ; First step, calculate ; Second step, take the square root ; Third step, add the denominators ; Fourth step, do the division ; Therefore. .

[0038] This result indicates that the current position The enhanced value is approximately 5.356. If other pixels are calculated in a similar manner after actual sampling, a complete enhanced image matrix can be formed. When the enhanced value is significantly less than 10, it usually indicates that the original pixel value is relatively high or the local contrast is large. If the enhanced value is greater than a certain range, it means that the original pixel value is relatively low or the local contrast is low. For different values, other auxiliary processing means can be used in subsequent steps to re - distribute the pixel brightness distribution.

[0039] Based on the enhanced color values, during the color reconstruction process for low - contrast regions, it is necessary to first obtain the pixel groups corresponding to each low - contrast region, and then re - distribute and map the original color histograms of these pixel groups. During the operation, the current brightness levels of all pixels in the region can be read first to establish a basic distribution table, and then compared with the distribution table of the nearby normal region. For example, the brightness distribution in the normal region is defined as a reference range first. When it is found that the brightness distribution in the low - contrast region is concentrated at the lower end of the reference range and the offset ratio compared with the reference range is greater than a certain threshold, such as the offset ratio threshold of 0.25 can be obtained by statistical analysis of 200 images according to experience. If it is detected that the offset ratio exceeds 0.25, the brightness of the corresponding pixels is gradually increased to form a more balanced distribution closer to the normal level. At the same time, the brightness variance of the region can be recalculated after each increase. If the increased brightness variance is still lower than a pre - set reference value, it can be continuously increased until it reaches the reference interval. For example, when the average brightness of a certain pixel segment is 40, and the difference ratio with the mean value of 80 in the neighboring normal region is 0.50, exceeding the aforementioned 0.25, then 40 can be adjusted towards 80. First, a step size of 10 is set for the increase, and then the standard deviation and variance are recalculated. If it is still lower than the normal reference interval, it is increased by several more step sizes. All pixels are adjusted one by one and counted, so that a reconstructed distribution pattern can be formed after multiple iterations. When the reconstructed distribution meets the pre - set variance range, for example, the variance is not greater than 15 when approaching the neighboring mean value, the adjustment can be ended and the new pixel values can be retained. Finally, after all low - contrast regions have completed similar adjustments, a contrast - enhanced image is generated.

[0040] The steps to obtain the detail - sharpened image are as follows: Receive the contrast - enhanced image, analyze the texture and detail levels of the entire image, identify the regions that need to be sharpened, and obtain the texture region data set; Based on the texture region data set, calculate the sharpening intensity of each point, and calculate the sharpening formula: ; Among them, is the sharpening intensity at position (x, y), represents the original pixel value at position (x, y), represents the gradient modulus at position (x, y). is the sharpening adjustment parameter, and is a non - linear factor used to control the sharpening intensity and scale; Based on the sharpening intensity, apply the sharpening intensity to the image, and refine the texture and details by enhancing the contrast of the image details to form a detail - sharpened image.

[0041] Specifically, after receiving the contrast - enhanced image, it is necessary to perform multi - directional detection and recognition on the local texture and edge features of the entire image. First, the image is divided into several small blocks, each small block containing a certain pixel range. For example, it can be divided into a 20×20 grid according to the document scanning specification of 600 dpi resolution. Then, the texture direction of each block is analyzed and the edge gradient is measured one by one. When analyzing, the gray - level difference values of each pixel in the small block can be summed, and then the overall difference result is summarized and judged whether the difference exceeds a pre - set threshold. The determination of the threshold can be obtained by comparing the texture difference statistics of multiple batches of sample images. For example, after statistically analyzing 200 archive scanning samples, it is found that when the sum of differences is lower than 1000, it usually means that the texture of this area is relatively smooth, so 1000 can be used as the texture threshold. When the sum of differences is higher than 1000, it is marked as having obvious texture. After traversing and calculating all the small blocks in the area, the small blocks determined to have significant texture are collected into a set. If the difference values of adjacent multiple small blocks are all significant, then these small blocks will be merged and marked as the same texture area, so that the subsequent sharpening process can be uniformly adjusted for the entire continuous texture area. At the same time, the marked small blocks can also be refined and classified. If the local gradient value exceeds another gradient judgment threshold, such as 50, it can be classified as a higher - priority sharpening area. If it is lower than 50, it is classified as a lower - priority sharpening area. All the information is summarized to form a texture area data set.

[0042] The advantage of the formula is that in the sharpening calculation of each pixel, the gradient modulus and several adjustable parameters are introduced at the same time, and the enhancement amplitude of the details is amplified or reduced in a non - linear way, so as to achieve a more flexible sharpening strategy in the overall image and can perform differential processing on the details according to the differences in local gradients.

[0043] The steps for obtaining the parameter are: This parameter represents the position of the original pixel value, usually from the pixel readings of the contrast - enhanced image. To obtain the exact value of, it is necessary to query the brightness or color channel corresponding to (x, y) point - by - point in the image data and quantify it according to the previously known channel depth. For example, if the contrast - enhanced image uses 8 - bit - depth gray - level values to represent, and each pixel ranges from 0 to 255, then It is the grayscale value at that coordinate. If it is a color image, you can store the R, G, and B channels separately and decide which channel to sharpen, or convert it into brightness information in a suitable color space (such as Lab) and then extract it. The following example is used to illustrate: at the pixel coordinate (300, 400), the gray value is 190 after contrast enhancement processing, and this value is used as the input data of EI (300, 400).

[0044] The steps to obtain the parameter are: This parameter represents the position The gradient modulus of the original pixel value at the position needs to be calculated based on the brightness difference in the neighborhood direction. The Sobel operator or Prewitt operator is used to obtain the horizontal gradient. With vertical gradient , then according to The gradient modulus is obtained by the formula. In the implementation, the operator convolution is performed on the horizontal and vertical adjacent pixel values ​​of each pixel in the contrast-enhanced image pixel matrix that has been read, and then the corresponding gradient components are obtained and the gradient modulus is finally synthesized. For example, when the Sobel operator is used to calculate the horizontal gradient = 20 and the vertical gradient = 10 at (300, 400), then .

[0045] The steps to obtain the parameter are as follows: This parameter is a sharpening adjustment parameter, which plays a role in amplifying or reducing the gradient effect in the calculation formula. Its value can be set based on the overall sharpening requirements of the image and the previous test results. Before doing this, we need to conduct gradient and visual contrast experiments on a large number of images, record the human eye contrast threshold and subjective score of the sample clarity, and then Assign a suitable value range. If you want to enhance the edge, you can For example, in a batch test of 300 archive images, the statistics show that When the value is between 3 and 5, most of the clarity requirements can be met. This will result in overly enhanced stroke edges. Achieved relatively balanced performance in many tests and can be used as a demonstration value in this section.

[0046] The steps to obtain the parameter are as follows: This parameter is used to control the denominator component in the gradient normalization process so that The ratio can be restricted within a reasonable range, thereby avoiding a sharp increase in S(x, y) when the gradient value is too large, and also avoiding insufficient contribution to the sharpening effect due to too small a gradient. In actual operation, the resolution of the image, the sampling depth, and the sample gradient statistics will be combined first to be assigned a value. For example, in the test of archival images with a scanning resolution of 600 dpi, the gradient value distribution at all edge positions can be centrally statistically analyzed, and its average value can be found or the distribution can be truncated at a certain percentile, and then is set to this statistical value. If it is determined after experimental analysis that the average gradient is about 15, then can be set to the range of 15 to 20, where the sharpening effect is more obvious at 15 and more gentle at 20. For this example, .

[0047] The steps for obtaining the parameter are as follows: This parameter is a key quantity that controls the non-linear exponent, which can make the edges and textures be enhanced more significantly when the gradient is large, and can also maintain a slight increase when the gradient is small. Its setting method needs to be determined through multiple experiments. When performing image processing, different types of documents can be evaluated, for example, the sharpening requirements for text documents and pattern documents are different, so the values of will also vary slightly. Researchers usually unify a basic test value first, and then make fine-tuning after evaluating its sharpening effect through subjective and objective indicators. If it is found in multiple experiments that

[0048] Calculation process: The following gives a practical example. Select a pixel point at (x = 300, y = 400) to calculate the sharpening intensity: First step, read EI(300, 400) = 190, , , , . Second step, calculate the denominator . Third step, the non-linear power . Fourth step, multiply by . Fifth step, add to EI(300, 400): .

[0049] Therefore . This result shows that in the above parameter environment, the sharpening intensity at the coordinate (300, 400) is approximately 196.1724, which has a certain degree of improvement compared to the original pixel value of 190. The larger the value, the higher the sharpening amplitude. When traversing and calculating on the entire image and completing the synthesis, a sharper detailed sharpening image will be obtained.

[0050] Based on the sharpening intensity, each pixel of the image needs to be processed one by one to complete the final detail rendering. During the execution, the pixel coordinate range of each recognized texture area will be read first, and the actual display brightness of the corresponding pixels will be updated according to the S(x, y) value obtained from the previous calculation. If it is found that the gradient of some areas far exceeds other positions, they will be segmented. All S(x, y) values can be globally statistically analyzed, and the span and standard deviation between the maximum value and the minimum value will be summarized and analyzed. If it is detected that the difference between the maximum value and the minimum value exceeds a predefined threshold, which can be determined by referring to large-scale sample statistics. For example, after analyzing 1000 archival samples, it is found that if the difference between the maximum and minimum sharpening intensities exceeds 40, it will cause over-enhancement in some areas of the image. Then 40 can be used as the difference limit, and if it exceeds 40, additional overshoot suppression will be performed by reducing the contrast superposition amount of several pixel points at the peak position to suppress extreme brightness or extreme darkness, so as to maintain the overall visual consistency. After completing the per-pixel update of all texture areas, the neighborhood mean can be combined to smooth the transition area and avoid obvious step effects at the sharpening boundary. When this set of processes is completed, a detail-sharpened image can be formed.

[0051] The steps to obtain the perspective analysis result are as follows: Extract geometric features from the detail-sharpened image, analyze the straight lines, intersections and edges in the image, apply the Hough transform to detect perspective distortion edges, calculate the angles and intersection information of each straight line, screen the areas with perspective distortion, and generate a preliminary dataset of perspective distortion candidate areas; Based on the preliminary dataset of perspective distortion candidate areas, calculate the perspective distortion deviation, and the calculation formula is: ; where, is the perspective distortion deviation, and respectively represent the angles between the th detected straight line and the reference straight line, represents the intersection coordinates of the th detected straight line, is the estimated perspective center coordinate; Based on the perspective distortion deviation, evaluate the deformation degree of each area, screen the parts with perspective distortion exceeding the threshold, and generate the perspective analysis result.

[0052] Specifically, select the pixel range to be analyzed from the detail-sharpened image, formulate a grayscale or color distribution determination criterion in advance according to the scanning resolution and content characteristics of the image, and then perform edge detection and preliminary line tracking on these pixels. When operating, the pixel brightness or color data can be differentially calculated in the horizontal and vertical directions. If the differential cumulative value exceeds the reference threshold obtained by sampling statistics, for example, this reference threshold can be set to 500 based on the summary statistics of the detection results of 300 scanned images as the judgment basis, then mark this pixel point as a suspected edge pixel. After accumulating a large number of suspected edge pixels, integrate the point sets with concentrated distributions and similar directions into line segments. To reduce the influence of noise, line segments that are too short can be deleted when screening all line segments. The setting of the length threshold can refer to the comparison of the pixel height and width of the scanned document. For example, when the image width reaches 2000 pixels, line segments less than 50 pixels can be removed. After filtering the noise, use the Hough transform to convert these remaining line segments into points in the polar coordinate system, and aggregate the possible perspective deformation line segments according to the amplitude statistical value in the polar coordinate space. Then, read the polar coordinate data of each suspicious line segment to obtain the angle and radius information and analyze its corresponding position in the original image coordinates. Make a comprehensive judgment on the aggregation degree of the polar coordinate space according to the empirical threshold. For example, a clustering radius threshold can be set. When the polar coordinate values of several line segments are concentrated in a radius interval and the covered angle interval is less than 3 degrees, these line segments are regarded as the same candidate straight line group. Read the coordinates of these candidate straight line groups and calculate the intersection points. When determining the position of the intersection points, the center point of the image and the reference angle of each line segment can be compared. If the distance from the intersection point of two line segments to the center point of the image exceeds a certain range, for example, set a center offset threshold of 100 pixels obtained by combining the scanning format size and sample statistics, then judge that it may belong to different regions and split it into independent candidate groups. Through repeated aggregation and splitting operations, finally form a more accurate set of suspicious perspective deformation line segments and intersection points. After the processing is completed, record the straight lines that meet the suspicious perspective deformation and their intersection points in sequence according to the coordinate numbers, and integrate the mapping relationship between this record and the image area into a dataset to form a preliminary dataset of perspective distortion candidate regions.

[0053] The advantage of the formula is that it couples the angle difference and the center offset, and can quantitatively measure the inclination amplitude of each detected straight line relative to the reference straight line and its position information in the image plane. Thus, a more accurate determination of the perspective deformation degree of different regions can be made, and more targeted adjustments can be made in subsequent correction operations.

[0054] The steps for obtaining the parameter are as follows. This parameter represents the angle between the , it is necessary to first calculate the direction angle of the line segment through polar coordinate or vector dot product operations, and then compare it with the direction of the reference line. If a horizontal reference is selected, the angle between the line segment direction and the horizontal direction can be recorded as , if a vertical reference is selected, it is the angle with the vertical direction. In specific implementation, it may first use the Hough transform to obtain the representation form in polar coordinates, which can become the basic angle information. If the horizontal is used as the reference, will be converted into the angle value relative to the horizontal direction, and thus the degree is obtained. By conducting experiments on a batch of scanned images and statistically analyzing the distribution range of the angles of all line segments, the common inclination range can be known. If in most cases the line inclination is distributed between 0 degrees and 45 degrees, it can ensure that the measurement will not produce excessive errors. The following is an example: In a certain detection, the angle between the th line segment and the horizontal reference line is calculated to be .

[0055] The steps for obtaining the parameter are as follows. This parameter represents the angle between the reference straight line for comparison and another reference line, or in a multi-reference scenario, it can specifically refer to the more standardized straight line direction within the same region. If the system only compares with a single reference line, then the angles of all line segments may be measured with respect to this reference line, and the results are marked as , similar to , its acquisition process will refer to the value returned by the Hough transform and perform conversions according to the corresponding reference direction. To ensure the rationality of the data, one or several reference directions need to be unified during the acquisition stage, and these reference directions are fixed to the image coordinate system through rotation correction or external calibration methods. For example, in a document scanning device, a standard scale plate is placed and the edge straight line is identified, then this edge straight line serves as the reference direction, and the angle differences of all detected line segments are calculated. The following is an example: During an actual detection, the angle between the reference line and another reference straight line is measured to be .

[0056] The steps for obtaining the parameter are as follows. It represents the intersection coordinates of the th detected straight line. Usually, after applying the Hough transform, the polar coordinate forms of many lines are obtained, and further operations on the intersecting lines or interpolation calculations on the intersection points after the lines are extended are required. If each line in the image can be restored to an explicit equation using its slope and intercept formula, then for the th line and the intersection point with the reference line or other lines can be obtained by simultaneously solving the equations of the two straight lines , it is necessary to ensure that the noise has been filtered or the duplicate line segments have been removed before extracting the intersection points, and verify whether the two lines actually intersect. If they are parallel, no actual intersection points will be generated. When the intersection condition is met, record the coordinates of the intersection point and put them into a list according to the pixel coordinate system. The following is an example: when the th line equation is , and the reference line equation is , make the two equal and solve for , Similarly, assign the solved value to .

[0057] The steps to obtain the parameter are as follows. It is the estimated perspective center coordinate. It is necessary to first establish a hypothetical or known image center position in the system or obtain the approximate center position according to the intersection points of the key reference lines. To obtain an accurate value, multiple sample images can be used to repeatedly locate multiple intersecting lines and record the intersection point area with the densest distribution. This area is often close to the true perspective center. Then, use the average coordinate of this area as through clustering or statistical methods. A more refined method can also be adopted. For example, mark the reference edge of the paper surface during scanning, and analyze the offset between the paper surface and the image coordinates to obtain a perspective center closer to the true value. The following is an example: after scanning 200 different-sized files, it is statistically found that the most frequently occurring intersection points are concentrated in the middle area of the image size, and the average coordinate is approximately (1000, 1500). Then, can be set, , and record this value for use as the perspective center.

[0058] Calculation process: The following gives a practical example. Let = 30 degrees (i.e., 0.5236 radians), = 10 degrees (i.e., 0.1745 radians), the intersection point coordinates of the rd line segment , the estimated perspective center ; First, calculate ; The first step is to calculate the absolute difference ; The second step is to calculate the denominator ; The third step is to calculate the distance between two points ; ; The fourth step is to combine the above values to obtain: ; This result shows that the After the angular difference between a line segment and the reference line is converted, it is then multiplied by the distance between the intersection point of the line segment and the perspective center to obtain a perspective distortion deviation of approximately 336.29. If it is determined through the reference threshold set in the system, assuming the threshold was determined to be 300 in the previous experiment, when the value is greater than 300, it indicates that there may be obvious perspective distortion in this line segment area, and it will be given key treatment in the subsequent correction steps.

[0059] Based on the above perspective distortion deviation, all detected line segments can be traversed and the value of each line segment can be calculated. If it is found that the of any line segment is greater than the set threshold, such as 300, the image part where the line segment is located will be regarded as a severely perspective-distorted area. Finally, these distorted parts that exceed the threshold are gathered together to summarize the perspective analysis result.

[0060] The steps to obtain the perspective-corrected image are as follows: Based on the perspective analysis result, extract the four corner point coordinates of the deformed area, establish a projective transformation matrix, calculate the mapping positions of the corner points in the standard rectangular coordinate system, analyze the deviation degree of the corner points from the theoretical corner points, and obtain the perspective deviation coordinate set; According to the perspective deviation coordinate set, calculate the viewing angle offset. The calculation formula is: ; where, is the viewing angle offset, and represent the upper boundary corner point coordinates of the perspective-deformed area, and represent the lower boundary corner point coordinates; Based on the viewing angle offset, construct a projective transformation matrix, and perform coordinate mapping on the perspective-distorted area in sequence to convert the deformed area to the standard rectangular coordinate system and generate the perspective-corrected image.

[0061] Specifically, based on the perspective analysis results, it is necessary to first read the coordinates of the four corner points of the deformed area and mark them according to the image coordinate system. Each corner point coordinate can be selected from the candidate edge or intersection information determined previously. During the specific operation, it is possible to judge which corner points jointly form the vertex combination of a rectangular area according to their positional relationship in the image. If both the long side and the short side of the area meet the pre-established side length range, for example, by statistically calculating the average pixel width and height of the scanned image, it is determined that the side length of this area should not be less than 200 pixels and should not be greater than 800 pixels, then it is considered that this area meets the perspective deformation condition that can be corrected. Then, when performing coordinate mapping processing on these four corner points, the position of each corner point can be compared with the corresponding point in the theoretical standard rectangular coordinate system. The theoretical standard rectangular coordinate system is usually set by combining the scanning resolution and the size standard of the requirement document. For example, its upper left corner is set to (0, 0), and the lower right corner is set to (600, 800). During the matching process, the distance and direction difference between each actual corner point and the ideal corner point are calculated and accumulated one by one. If this difference does not exceed a certain threshold obtained through statistics, for example, the maximum offset threshold of 300 pixels determined after testing 300 images, then the coordinates of these four corner points are marked as valid data. If it is found that the coordinate offset of a certain corner point compared to the standard rectangle is too large, for example, exceeding 600 pixels, then additional inspection or elimination processing will be performed on it. Finally, when all valid corner points are uniformly mapped to the standard coordinate system, a corresponding perspective offset coordinate set will be generated.

[0062] The benefit of the formula is that by capturing the product difference of two opposite corner points in the numerator and introducing the product of the lengths of two sides in the denominator, the perspective shift degree can be quantified from the perspective of spatial geometry. Combining with the arctangent function, a more intuitive angular form can be obtained, which is convenient for judging the perspective bending condition of the deformed area in the horizontal or vertical direction and making the subsequent projection transformation more accurate.

[0063] and The steps for obtaining the parameters are as follows. These two coordinates respectively represent the positions of the upper boundary corner points of the perspective deformation area, and it is necessary to confirm their pixel positions in the image item by item during the corner point recognition operation in the previous stage. If a certain area is determined to be a rectangle, the two endpoints of the upper edge of this rectangle will be extracted and numbered as (1) and (2). For example: when the coordinates of the upper left corner point (200, 400) and the upper right corner point (800, 420) are detected, and after judgment, it is satisfied that the length is about 600 pixels and greater than 80, then and. .

[0064] and The steps for obtaining the parameters are as follows. These two coordinates respectively represent the positions of the lower boundary corner points of the perspective deformation area. Similar to the confirmation process of the upper boundary, it is also necessary to find the lower edge endpoints paired with the upper boundary in the preliminary screening. Usually, it is necessary to judge whether a certain area is a rectangle based on the logical structure of the actual content in the scanned document. If confirmed, the left and right endpoints of the lower edge are respectively corresponding to (3) and (4). When extracting the coordinates, it is also necessary to compare whether their offsets in the vertical direction exceed the threshold. For example, if the minimum vertical margin should be more than 100 pixels, this can distinguish different structural areas. The following is an example: If (300, 900) and (880, 930) are confirmed as the left and right ends of the lower boundary of this area, then it can be marked and 。

[0065] Calculation process: The following gives an actual calculation example. Assume the upper boundary corner points , ,the lower boundary corner points , 。First, calculate the numerator part: ; ; Next, calculate the denominator part: ; Divide the numerator by the denominator: ; Then take the arctangent: 。

[0066] This result shows that the viewing angle offset of the perspective deformation area defined by the above corner points is approximately 1.05 degrees. If a tolerance range is set in the system, for example, when the viewing angle offset is less than 5 degrees, it belongs to mild deformation, then there is no need for excessive correction or only a small amount of mapping is required. If it is greater than 5 degrees, a complete projection transformation is performed on this area.

[0067] Based on the perspective offset, when constructing the projection transformation matrix, it is necessary to first read all the coordinate data of the previously confirmed deformed regions and clarify the pixel boundaries occupied by this region in the image. When analyzing these pixel boundaries, a pixel number range determination benchmark can be set first. For example, in the statistics of 600dpi resolution scans, it is found that the width of most pages is between 2000 and 3000 pixels. If the width of the target region is less than 200 pixels or greater than 1800 pixels, it may belong to an invalid deformed region and be ignored. For the regions that meet the range, the corresponding relationships between the four corner point coordinates and the standard rectangular coordinate system are matched one by one to form a comparison table to record the mapping sequence between the original image coordinates and the target coordinates. During this process, if it is found that the offset of some corner point coordinates from the target coordinates exceeds the threshold established through testing, for example, more than 400 pixels, verification will be carried out to determine whether there is incorrect extraction or misjudgment. If it is determined to be a real corner point after verification, it will be retained in the mapping sequence. If it is a pseudo-corner point caused by noise, it will be deleted and an attempt will be made to reselect from the alternative corner points. Next, the parameters of the projection transformation matrix will be calculated according to the mapping sequence. This usually requires determining multiple coefficients in the matrix and linearly or non-linearly mapping the coordinates of all pixels in the actual transformation operation. Subsequently, the new pixel arrangement after mapping is placed in a standard rectangular coordinate system. For example, the origin of the standard coordinates can be set as (0, 0), the width of the target coordinates can be set as a relatively fixed 1000 pixels or other values, and the height is determined according to the aspect ratio of the original image. After the projection calculation is completed, all pixels will be traversed and resampled. If missing pixels occur during the resampling process, bilinear interpolation or cubic interpolation can be used to fill in the points. When all pixels are completely converted to the new coordinate system, the corrected image array can be obtained and presented in grayscale or color, thereby generating a perspective-corrected image.

[0068] To evaluate the quality of the perspective-corrected image, check the clarity of the image, and verify whether the image details are restored, the steps to complete the repair of damaged archival image are as follows: According to the perspective-corrected image, calculate the image quality index, and the calculation formula is: ; where Q is the image quality index, is the gray value of the perspective-corrected image at the coordinate point ; is the gradient modulus, is the pixel value after Laplace transform, is the local region entropy value; Based on the image quality index, identify the blurred regions and optimize them by sharpening and contrast enhancement to complete the repair of the damaged archival image.

[0069] Specifically, the advantage of the formula lies in combining the image gradient, Laplace transform result, and local entropy information into the same evaluation index. Through the high-order gradient and Laplace operation terms in the numerator, the edge and detail intensity of the image can be better quantified. At the same time, a combined term of the overall image brightness and local entropy is introduced in the denominator, enabling the evaluation result to take into account both the detail richness and the global average distribution, facilitating a more global measurement of the imaging quality.

[0070] The steps for obtaining the parameter are as follows. This parameter represents the gray value at the coordinate and is obtained by reading the pixel data of the image that has been perspective-corrected. Each pixel's brightness is stored in a two-dimensional matrix. If the image is 24-bit color, it will be first converted to single-channel grayscale. The method can use to perform weighted summation of the color channels. After conversion, directly reading the result of the coordinate is the gray value. To prevent interference from abnormal pixels, invalid pixels can be marked and excluded during reading. If there are hardware scanning failures in some areas resulting in all-white or all-black, the outlier ratio can also be statistically analyzed first and then a decision can be made on whether to exclude. For example, when processing the (300, 200)th pixel, if its R = 100, G = 150, B = 200, then the gray .

[0071] The steps for obtaining the parameter are as follows. It represents the gradient magnitude of the current pixel in the x and y directions and can be obtained by performing a first-order difference on the image. For example, in the x direction, the gray values of and can be subtracted. In the y direction, the gray values of and can be subtracted, and the resulting values are then squared and square-rooted to obtain the gradient magnitude. When using the Sobel operator, a weighted operation needs to be performed on the 3×3 pixel neighborhood. The horizontal gradient and the vertical gradient are combined into . The following is an example: when the horizontal gradient at (300, 200) is 15 and the vertical gradient is 9, then .

[0072] The steps for obtaining the parameter are as follows. It represents the output value of the Laplacian operator for this pixel point. Second-order differentiation is performed in the x and y directions respectively. On a discrete image, the Kirsch or Laplacian operator can be used to obtain it. For example, the classic Laplacian template: . After performing convolution of this template with the 3×3 pixel neighborhood at (300, 200), the value of can be obtained. The acquisition example: if the convolution result is -28, then , which will be used in subsequent operations to participate in the integration.

[0073] The steps to obtain the parameter are as follows. It represents the local area entropy value at the position. First, a neighborhood size can be established. For example, a 5×5 pixel window is used. The brightness frequencies of all pixels within the window are statistically formed into a probability distribution , and then the entropy value of the window is calculated using the information entropy formula . Then the result is used as and stored in the matrix. If the local entropy value is large, it indicates that the brightness or texture distribution within the area is more complex; otherwise, it is more uniform. When obtaining, invalid pixels need to be excluded. If the proportion of invalid pixels is greater than a certain threshold, such as 0.15, it can be regarded as insufficient data and processed separately. Example: When it is found that the gray value distribution in the neighborhood of (300, 200) is concentrated and the frequency is relatively dispersed, and the entropy value is calculated as 4.2 bit after statistically obtaining pi, that is, H(300, 200) = 4.2.

[0074] Calculation process: The following gives a numerical example. An operation is performed on a perspective - corrected image with a size of 100×80. Assume that after calculation, there are: ; For ease of explanation, these integral values are all obtained by accumulating the corresponding values of each pixel. Their respective orders of magnitude are related to the image size, gradient intensity, Laplacian amplitude, and entropy distribution. Now substitute into the formula: The numerator part = ; The denominator part = ; First calculate ; So ; Then calculate ; , ; Thus .

[0075] The denominator part = (In contrast, 565.35 is smaller).

[0076] Therefore ; The result shows that the comprehensive quality index of this image is 0.0233. If a large number of images with similar resolution and content are tested and a reference range is formed, for example, statistics show that most common Q values ​​are concentrated between 0.02 and 0.05, then 0.0233 can be regarded as being in a relatively low segment or a relatively high segment. Specifically, it can be classified according to the previously established threshold. When the classification is completed, the image quality represented by the Q value can be used to identify the relatively blurred area and further use sharpening or contrast enhancement operations for subsequent repairs.

[0077] Based on the image quality index, it is necessary to traverse all pixels of the entire image and further analyze the corresponding Q value contribution data. First, the gradients and Laplace values ​​of each pixel counted in the previous step are screened. When it is found that the Q value contribution of some local areas is significantly low, it indicates that there may be blur or excessive grayscale concentration in the local area. More refined sharpening operations can be applied to these areas. For example, traverse its grayscale pixels. When it is found that the contrast difference between it and the neighboring pixels is less than a threshold summarized from a large number of samples, such as the threshold is set to 10, and the corresponding Laplace value remains below the absolute value of 10 for a long time, it indicates that the area is in a stage of lack of texture details. The sharpening coefficient can be increased in the sharpening operation to increase the grayscale difference between adjacent pixels. At the same time, if the local area is concentrated in a certain interval on the histogram, contrast enhancement measures can be introduced. The local Q value increment is calculated again after each contrast adjustment. If the increment is still lower than the baseline value pre-established in the system, such as 0.005, it indicates that the improvement is not enough and it is necessary to continue to increase or use other methods to improve the resolution. When the Q value increment is close to or exceeds 0.005, the adjustment can be ended and the current area can be recorded as improved. Finally, all blurred areas will be sharpened and contrast enhanced. The entire image will have clearer details and meet the scanning and repair requirements, completing the repair of damaged archival images.

Claims

1. A damaged file repair method, characterized in that: The following steps are involved: A group of damaged archival images and undamaged archival images are selected, and color histograms of the undamaged archival images are collected to obtain color histogram data; Based on the color histogram data, the color histogram of the damaged archival image is adjusted by a histogram matching technique to match the histogram distribution of the undamaged archival image to generate a color-corrected image; Receive the color-corrected image, perform local adaptive enhancement processing on the color-corrected image, enhance the local contrast of the image, and obtain a contrast-enhanced image; perform sharpening processing on the contrast-enhanced image, refine the details and texture in the image, and obtain a detail-sharpened image; Analyzing the geometric structure of the detail-sharpened image, identifying the perspective distortion portion that needs to be corrected, and obtaining a perspective analysis result; calculating an ideal viewing angle based on the perspective analysis result, and automatically adjusting the perspective of the image to generate a perspective-corrected image; The perspective-corrected image is quality-evaluated to check image clarity and verify whether image details are restored, thereby completing the restoration of the damaged archival image.

2. The damaged file repair method according to claim 1, characterized in that: The steps for obtaining the color histogram data are as follows: Selecting a group of undamaged archival images and the same number of damaged archival images to obtain a damaged archival image group and an undamaged archival image group; For each image in the undamaged archive image group, a color histogram is collected, the color channel distribution of each image is analyzed one by one, and the data of the color channel is recorded to obtain a color histogram data set of the undamaged archive image; Based on the undamaged archive image color histogram data set, the data format of the color histogram of each image is sorted and unified to form color histogram data.

3. The damaged file repair method according to claim 1, characterized in that: The steps of obtaining the color correction image are: Based on the color histogram data, a damaged archival image and an undamaged archival image are selected, the same number of histogram buckets are set for each color channel of each image, the color value distribution in each bucket is uniformly collected and recorded, and a color histogram data set of the damaged archival image and the undamaged archival image is generated; Calculating a color adjustment amount based on a color histogram dataset of the damaged archival image and the undamaged archival image; Based on the color adjustment amount, the color value of the damaged image is adjusted bucket by bucket, and the color histogram of the damaged image is approximated to the histogram distribution of the undamaged image, so as to obtain a color-corrected image.

4. The damaged file repair method according to claim 1, characterized in that: The steps of acquiring the contrast enhanced image are: Receiving the color-corrected image, analyzing local regions in the image, evaluating the contrast level of each region, identifying low-contrast regions, and forming a low-contrast region tag set; Calculating enhanced color values ​​based on the low contrast region marker set; Based on the enhanced color value, the low contrast area of ​​the image is reconstructed in color, and the color histogram of the low contrast area is adjusted to generate a contrast enhanced image.

5. The damaged file repair method according to claim 1, characterized in that: The steps of obtaining the detail sharpened image are: Receiving the contrast-enhanced image, analyzing the texture and detail level of the entire image, identifying the area that needs to be sharpened, and obtaining a texture area data set; Based on the texture area data set, calculating the sharpening intensity of each point; Based on the sharpening strength, the sharpening strength is applied to the image to refine textures and details by enhancing the contrast of image details, thereby forming a detail-sharpened image.

6. The damaged file repair method according to claim 1, characterized in that: The steps for obtaining the perspective analysis results are: Extracting geometric features from the detail-sharpened image, analyzing straight lines, intersections and edges in the image, applying Hough transform to detect perspective deformation edges, calculating the angle and intersection information of each straight line, screening areas with perspective distortion, and generating a preliminary perspective distortion candidate area data set; Calculating perspective distortion deviation based on the preliminary perspective distortion candidate region dataset; Based on the perspective distortion deviation, the deformation degree of each area is evaluated, and the part with perspective distortion exceeding a threshold is screened to generate a perspective analysis result.

7. The damaged file repair method according to claim 1, characterized in that: The steps of obtaining the perspective-corrected image are as follows: Based on the perspective analysis results, the coordinates of the four corner points of the deformation area are extracted, a projection transformation matrix is ​​established, the mapping position of each corner point in the standard rectangular coordinate system is calculated, the degree of deviation between the corner point and the theoretical corner point is analyzed, and a perspective deviation coordinate set is obtained; Calculating a viewing angle offset according to the perspective offset coordinate set; Based on the viewing angle offset, a projection transformation matrix is ​​constructed, and coordinate mapping is performed on the perspective distortion area in turn, and the deformed area is converted into a standard rectangular coordinate system to generate a perspective-corrected image.

8. The damaged file repair method according to claim 1, characterized in that: The steps of evaluating the quality of the perspective-corrected image, checking the clarity of the image, and verifying whether the image details are restored are as follows: Calculating an image quality index based on the perspective-corrected image; Based on the image quality index, blurred areas are identified and optimized using sharpening and contrast enhancement to complete the restoration of damaged archival images.

9. The repair device of the damaged file repair method according to any one of claims 1 to 8, characterized in that: include: A processor and a memory, the memory being used to store a computer program, the processor being used to call and run the computer program stored in the memory, so that the repair device executes the method as claimed in any one of claims 1 to 8.

Citation Information

Cited By

  • Intelligent document detection method and system based on OCR and ES

    CN120954012A