Digital archive rectification correction method and system
By combining Fourier transform and boundary fitting, along with radical and text component detection, the problem of tilted and inverted archival images was solved, achieving accurate correction and flipping of archival images and improving the efficiency of digital archival management.
Patent Information
- Application Number
- CN202211147662.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-19
- Publication Date
- 2026-02-27
- Estimated Expiration
- 2042-09-19
AI Technical Summary
Archival images are prone to tilting and inversion during scanning, which is difficult to correct effectively using existing methods, affecting subsequent processing operations.
The tilt angle of the archive image is determined by a combination of Fourier transform and boundary fitting, and then corrected by spatial affine transformation. Preset radical and text components are used to detect inversion and flip the image.
It enables accurate tilt correction and inversion detection of archival images, improving the efficiency and quality of digital archival management.
Smart Images

Figure CN115619656B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of file processing, and particularly relates to a digital file rectification and correction method and system. BACKGROUND
[0002] In the digital processing of files, due to the serious wear of the outer frame of old files, the diversification of file edition, etc., the inclination angle of the files is difficult to calculate, and there are great subjective factors in the scanning process of file processing personnel, so that the scanned file image will have different degrees of inclination angle and direction inversion, thereby affecting the post-processing of the file image and related operations. For the inclination correction problem of the file image, there are currently mainly projection-based methods, Hough transform-based methods and K-nearest neighbor-based methods. However, the projection method is only suitable for pure text image inclination detection, the Hough transform is only suitable for straight line detection, the K-nearest neighbor method has poor timeliness, and the above algorithms cannot detect file inversion problems. SUMMARY
[0003] Therefore, the application provides a digital file rectification and correction method and system, which can process various file images, has good processing effect on old file images of long time and inversion conditions, and can meet the actual needs of current projects in real time, and is convenient for application in digital file management.
[0004] According to the design scheme provided by the application, a digital file rectification and correction method is provided, which includes the following contents:
[0005] The scanned file image to be rectified and corrected is read, and the file image is preprocessed, and the preprocessing at least includes white edge cropping and grayscale processing;
[0006] The Fourier transform is used to obtain the inclination angle a of the preprocessed file image, the boundary fitting is used to determine the outer boundary line and the inclination angle b of the file image, and the space affine transformation is used to correct the inclination of the file image;
[0007] The text picture list in the file image is extracted, the preset component and / or text component are used to match the text picture in the file image, the upside-down condition of the file image is determined, and the inverted file image is flipped to obtain a file image with correct text content and inclination angle.
[0008] As the digital archive rectification correction method in the application, further, in the process of obtaining the inclination angle of the archive image by using Fourier transform, first, the frequency domain distribution of the archive image is obtained by two-dimensional discrete Fourier transform of the archive image; then, the straight line is drawn on the frequency domain distribution by using Hough transform to detect the straight line, and the corresponding frequency domain graph is obtained; the noise on the frequency domain graph is eliminated by traversing the whole connected domain of the frequency domain graph, and the skew base graph and the skew auxiliary graph are obtained by frequency channel separation, and the skew angle a of the archive image is obtained by using the skew base graph and the skew auxiliary graph.
[0009] As the digital archive rectification correction method in the application, further, in the process of obtaining the inclination angle of the archive image by using the skew base graph and the skew auxiliary graph, the following contents are contained: the skew base graph feature distribution is obtained by using FAST feature detection, and the coordinates of each straight line end point are calculated according to the feature point distribution; in the skew auxiliary graph, whether the archive image meets the inclination requirement is determined according to the preset inclination determination condition, and the inclination angle of the archive image is obtained by the horizontal straight line slope included angle of the archive and the vertical straight line slope included angle of the archive, wherein the preset inclination determination condition is that the horizontal and vertical mark bit is true and the maximum circumscribed rectangle area of the skew base graph meets the preset area requirement.
[0010] As the digital archive rectification correction method in the application, further, in the process of determining the outer boundary line of the archive image by boundary fitting, first, the preprocessed gray archive image is binarized, and each top corner rectangular block of the archive image is cropped, and whether the archive image has black edge is determined according to the average value of the rectangular block; then, the boundary position of the archive image is located and the boundary hash point set is drawn according to the preset color pixel point and the corresponding pixel point coordinates; then, the least square method is used to fit the boundary line of the archive image, and the inclination angle β of the outer frame of the archive image is calculated by using the fitting straight line slope.
[0011] As the digital archive rectification correction method in the application, further, the process of fitting the boundary line of the archive image by using the least square method contains the following contents: first, the regional node is determined by using the shortest distance from each vertex of the archive image to the boundary hash point, the archive image is regionally divided by connecting the regional node with the center point of the archive image respectively, and a straight line is arranged in each region, and in the process of straight line fitting, the nearest two vertices of the current straight line fitting region and other regions are combined to form a mask polygon, and the polygon is obtained by the hash point image and or the corresponding direction point set; the fitting straight line equation is obtained by using the least square method to fit the direction point set.
[0012] As the digital archive rectification correction method of the application, further, in the step of calculating the tilt angle of the outer frame of the archive image by using the slope of the fitting straight line, first, the slope of the fitting straight line is converted into a direction identifier, the tilt direction of the archive image is obtained according to the direction identifier, and the slope of the fitting straight line is converted into an included angle in the horizontal direction; then, the two most similar angles in the horizontal direction are obtained by using the shortest distance formula, and the horizontal tilt angle is obtained according to the two most similar angles; finally, the tilt angle of the archive image is determined according to the tilt angle and the tilt direction.
[0013] As the digital archive rectification correction method of the application, further, the text information in the archive image is extracted, first, each text in the archive image is calibrated, the text calibration frame is filtered by checking whether the calibration frame meets the text size, then the filtered text calibration frame is cropped to obtain a text picture list.
[0014] As the digital archive rectification correction method of the application, further, in the step of determining the upside-down situation of the archive image by matching the text information in the archive image with the preset component and / or text component, first, the occlusion rectangular region is generated according to the component type and the preset proportion, the text component external rectangle is determined according to the occluded picture, and the component image scaling ratio is calculated according to the size of the external rectangle and the component specification; then, the extracted archive text picture and the component image are matched with the template similarity in two directions of positive and negative inversion according to the template matching method, the number of high similarity of the text in the archive picture with the positive and negative templates is counted respectively, and finally whether the archive image is inverted is determined by the number.
[0015] As the digital archive rectification correction method of the application, further, in the step of obtaining the preset component and / or text component, the font specified in the personnel archive digitization technical specification is used to draw the component picture and text component picture with the corresponding size specification requirements, and the component picture and text component picture are converted into picture data with the preset background and proportion requirements through mask operation and proportion setting; the corresponding feature key point map is generated by performing FAST feature detection on the picture data, the component list configuration file is generated according to the preset component type and text type, and the configuration file is used to obtain the preset component and text component.
[0016] Further, the application also provides a digital archive rectification correction system, which comprises an image data reading module, an image angle correction module and an image direction flip module, wherein,
[0017] The image data reading module is used for reading the scanned archive image to be rectified and corrected, and pre-processing the archive image, wherein the pre-processing at least includes white edge cropping and grayscale processing.
[0018] An image angle correction module is configured to obtain a tilt angle alpha of a preprocessed archive image by Fourier transform, to determine an outer boundary line of the archive image and a tilt angle beta by boundary fitting, and to correct the tilt of the archive image by spatial affine transform.
[0019] An image direction flipping module is configured to extract a list of text pictures in the archive image, to match the text pictures in the archive image by using preset component radicals and / or component characters, to determine whether the archive image is upside down, and to flip the upside-down archive image to obtain an archive image with correct text content and tilt angle.
[0020] The present application has the following advantages:
[0021] The present application can correct the tilt of the archive image by fitting the frame of the scanned archive image and performing Fourier transform, can solve the problem that a straight line cannot be accurately fitted due to paper damage caused by long-term storage of the archive, can shield irrelevant information on the page content, and thus can improve the accuracy of tilt correction. BRIEF DESCRIPTION OF DRAWINGS
[0022] Figure 1 An archive rectification flowchart in the embodiment;
[0023] Figure 2 A Fourier transform processing schematic diagram in the embodiment;
[0024] Figure 3 A boundary fitting schematic diagram in the embodiment;
[0025] Figure 4 An outer frame processing schematic diagram in the embodiment;
[0026] Figure 5 A component generation flowchart schematic diagram in the embodiment;
[0027] Figure 6 A component detection flowchart schematic diagram in the embodiment;
[0028] Figure 7 A component type schematic diagram in the embodiment;
[0029] Figure 8 A width-height schematic diagram in the embodiment;
[0030] Figure 9 A component radical schematic diagram in the embodiment;
[0031] Figure 10 A component radical proportion schematic diagram in the embodiment;
[0032] Figure 11 for the text frame in the embodiment;
[0033] Figure 12 for the text frame in the embodiment;
[0034] Figure 13 for the text frame in the embodiment; DETAILED DESCRIPTION:
[0035] In order to make the objects, technical solutions and advantages of the present application clearer and more apparent, the present application will be further described in detail below with reference to the drawings and technical solutions.
[0036] In view of the problems of inclination correction, black edge cutting and direction inversion in the process of digitalizing archives, the embodiment of the present application provides a digital archive rectification and correction method. Firstly, a scanned archive image to be rectified and corrected is read, and the archive image is preprocessed, wherein the preprocessing at least includes white edge cutting and grayscale processing. Then, the Fourier transform is used to obtain the inclination angle a of the preprocessed archive image, the outer boundary line of the archive image and the inclination angle b are determined through boundary fitting, and the inclination of the archive image is corrected by using spatial affine transformation. Then, the text picture list in the archive image is extracted, and the text pictures in the archive image are matched by using the preset component and / or text component, the upside-down condition of the archive image is determined, and the inverted archive image is flipped to obtain an archive image with correct text content and inclination angle.
[0037] The archive image can be scanned and read by using a flatbed scanner, and the white edge with a width of 20 pixels read is cut and processed by grayscale. In view of the problems of inclination correction and black edge cutting in the process of digitalizing archives, referring to Figure 1As shown, in the embodiment, the inclination angle of the archive image is obtained by Fourier transform combined with outer border fitting. The method is suitable for monochrome background archive image, and the effect is poor for archive image with black border. The border fitting method can effectively solve the problem and accurately obtain the inclination angle of the archive image with black border. For old archives with damaged outer border, the outer border fitting algorithm still has good robustness. At the same time, the real outer border line of the archive is obtained by border fitting, and the same angle of the outer border line is corrected, so that the size of the archive to be cut can be obtained. In the inversion detection method, according to the requirement of font format as Songti in the Digitalization Technical Specification for Cadre Personnel Archives, a plurality of component radicals and a plurality of character components can be generated by Songti in the embodiment. By analyzing the frequency of radicals and characters in the archive, the most common and obvious "wood", "Hen" and the like can be selected as radical components, and the common characters "name", "table", "special" and the like can be selected as character components. First, the input archive is segmented by character, and then the component is detected. The component detection is a template matching method by adapting to the size of the character. For the archive with more characters, the character inversion condition can be known in the radical component detection, and for the archive with less characters, the character inversion condition can be known in the character component detection stage.
[0038] As a preferred embodiment, further, in the Fourier transform for obtaining the inclination angle of the archive image, first, a frequency domain distribution of the archive image is obtained by two-dimensional discrete Fourier transform of the archive image; then, a straight line is detected by Hough transform, the straight line is drawn on the frequency domain distribution to obtain a corresponding frequency domain graph; noise on the frequency domain graph is eliminated by traversing the whole frequency domain graph connected domain, and a skew base graph and a skew auxiliary graph are obtained by frequency channel separation, and the skew base graph and the skew auxiliary graph are used to obtain the skew angle a of the archive image.
[0039] The Fourier transform and the fitting straight line are both for determining the inclination angle, and the fitting straight line can improve the accuracy. In the fitting straight line, the inclination angle of the straight line can be determined, and the real text boundary of the archive image in the archive can be determined.
[0040] The two-dimensional discrete Fourier transform (DFT) is performed on the gray-scale archive image to obtain a frequency domain distribution I b , then a straight line is detected by Hough transform, and finally the straight line is drawn on the frequency domain graph I c , wherein the horizontal and vertical lines are drawn in gray, and other straight lines are drawn in black. As shown in Figure 2 , (1) is the frequency domain distribution I b generated by Fourier transform, and (2) is the frequency domain graph I c rewritten by Hough transform. The rewritten frequency domain graph I cOften contains many line segment noise, traversal of the whole graph connected domain, keep the largest area of connected region, the rest of the connected region is cut and assigned to white, get no noise frequency domain graph I d . Then separate graph I d gray black channel to get skew base graph I e and skew auxiliary graph I f , wherein skew base graph I e There may be two straight lines in two directions, if there is a horizontal straight line, the horizontal flag bit flag h is true, the vertical straight line is the same. As shown in (3) of Figure 2 , there is a horizontal straight line flag h is true, there is no vertical straight line flag v is false. Finally, the maximum outer rectangle area S e of skew base graph I F is calculated.
[0041] In the embodiments of the present case, further, the process of obtaining the skew angle of the archive image by using the skew base graph and the skew amplitude graph, includes the following contents: using FAST feature detection to obtain the skew base graph feature distribution graph, and calculating the coordinates of each straight line end point according to the feature point distribution graph; in the skew auxiliary graph, according to the preset tilt determination condition, it is determined whether the archive image meets the tilt requirement, for the archive image which does not meet the tilt requirement, the archive image tilt angle is obtained through the archive horizontal straight line slope angle and the archive vertical straight line slope angle, wherein the preset tilt determination condition is that the horizontal and vertical flag bits are true and the maximum outer rectangle area of the skew base graph meets the preset area requirement.
[0042] Graph I e After FAST feature detection, the feature distribution graph I g is obtained, as shown in (5) of Figure 2 , the gray points are the feature point set, and the coordinates H n = {(x0, y0), (x1, y1), …, (x n , y n )}, x i ∈ [0, w), y j ∈ [0, h), n = [0, w x h). The indexes of p0, p1, p2, p3 in H n can be obtained by formula (1), and the indexes of p0, p1, p2, p3 are index0, index1, index2, index3 respectively. The coordinate set of the four end points
[0043] The end points and straight lines are shown in (6) of Figure 2 .
[0044]
[0045] If the skew auxiliary graph I f flag v and flag h are both true and S F w x n x 0.16 is satisfied, the archival image has met the skew requirement and does not need to be corrected, otherwise further slope angle calculation is needed. The straight line l v The slope angle a v can be calculated by formula (2), and the straight line l h The slope angle a h can be calculated by formula (3), and the skew angle a can be calculated by formula (4).
[0046]
[0047]
[0048]
[0049] As a preferred embodiment, further, the outer boundary line of the archival image is determined by boundary fitting. First, the pre-processed gray-scale archival image is binarized, and each top corner rectangular block of the archival image is cropped, and whether the archival image has black edges is determined according to the average value of the rectangular block; then, the boundary position of the archival image is located and the boundary hash point set is drawn according to the pre-set color pixel point and the corresponding pixel point coordinates; then, the least square method is used to fit the boundary line of the archival image, and the slope of the fitted straight line is used to calculate the tilt angle b of the outer frame of the archival image.
[0050] The gray-scale archival image is binarized, and each top corner 20*20 rectangular block of the image is cropped in turn, and whether the average value of each block is equal to 0 is calculated, and the number of blocks equal to 0 is counted. If the number is greater than or equal to 3, it is considered that there is a black edge. Otherwise, it is considered that there is no black edge. The e-th row of white pixel coordinates p e is calculated, and the first white pixel point coordinate and the last white pixel point coordinate of the e-th row are calculated, that is, the boundary position can be located. Assuming that p e = [225, 226, …, 1997, 1998], then each row is traversed to obtain the frame hash point set. As shown in (1) of Figure 4 , the gray part represents the frame hash point set.
[0051] The vertices v iThe shortest distance of i∈[0,4) to the border hash point determines four region key points, which are b0, b1, b2, and b3. The image is divided into four regions by connecting the four region key points with the image center point C, and each region has a straight line. In the process of straight line fitting, the other three regions and the nearest two vertices of the fitting straight line are combined to form a mask polygon, as shown in (2) of Figure 4 The direction point set l is obtained by performing a logical AND operation between the mask polygon and the hash point image, as shown below:
[0052] l i ={(x0,y0),(x1,y1),…,(x n ,y n )},x i ∈[0,w),y j ∈[0,h),i∈[0,4)
[0053] Finally, the least square method is used to fit the straight line y=k·x+b. The above operations are sequentially performed, and the fitting straight line e i ,i∈[0,4) is obtained. Figure 4 In (2) of the above, the gray color represents the mask polygon of l0, which is generated by combining region 1, region 2, region 3, and vertices v0 and v3. Figure 3 In the above, different color blocks represent different regions, v0, v1, v2, and v3 represent the vertices of the archive image, l0, l1, l2, and l3 represent the direction point set, and the gray line represents the shortest distance from v i to l i , and the point is the gray point b i .
[0054] Further, the process of fitting the boundary line of the archive image by using the least square method includes the following contents: first, the region key points are determined by using the shortest distance of each vertex of the archive image to the boundary hash point, the archive image is regionally divided by connecting the region key points with the center point of the archive image, a straight line is set in each region, and in the process of straight line fitting, the mask polygon is formed by combining the nearest two vertices of the current straight line fitting region and the other regions, and the direction point set is obtained by performing a logical AND operation between the mask polygon and the hash point image; the fitting straight line equation is obtained by using the least square method to fit the direction point set. Further, in the process of calculating the tilt angle of the outer frame of the archive image by using the slope of the fitting straight line, first, the slope of the fitting straight line is converted into a direction identifier, the tilt direction of the archive image is obtained according to the direction identifier, and the slope of the fitting straight line is converted into a horizontal direction angle; then, the two most similar angles in the horizontal direction angle are obtained by using the shortest distance formula, and the horizontal direction tilt angle is obtained according to the two most similar angles; finally, the tilt angle of the archive image is determined according to the tilt angle and the tilt direction.
[0055] The least square method is used to obtain four fitting straight lines e i , i∈[0, 4), wherein the straight line e0 is the fitting straight line of the direction point set l0, and the slope is k0. Similarly, k1, k2, k3 are the slopes of the fitting straight lines e1, e2, e3 respectively. The angle skew direction d is calculated, and 0 is used to represent left skew, and 1 is used to represent right skew. Considering that e0 and e2 belong to the same direction and are approximately parallel straight lines, e1 and e3 belong to the same direction and are approximately parallel straight lines, and the horizontal included angle between e0 and e1 is 90°, in order to facilitate the calculation of the skew direction, the slopes are normalized as follows, and the four slopes are converted into direction identifiers d i ′ through formulas (5) and (6). Then the skew direction d can be obtained through formula (7).
[0056]
[0057]
[0058]
[0059] According to formula (8), the slope is converted into the included angle β i , i∈[0, 4) with respect to the horizontal direction, which satisfies 0°≤β i ≤90°, i∈[0, 4).
[0060]
[0061] Two most similar angles and are obtained through the shortest distance formula (9). Then the skew angle β′ with respect to the horizontal direction is calculated through formula (10), and finally the document skew angle β is obtained according to formula (11).
[0062] D min = min(|β i -β j |), 0≤i<4, i≤j<4#(9)
[0063]
[0064]
[0065] Taking as the center coordinate point, the skew angle is α+β, the M transformation matrix is calculated, then the boundary is cropped according to the transformed fitting straight line, and finally a visual front-end image is obtained through spatial affine transformation.
[0066] As a preferred embodiment, further, the text information in the archive image is extracted, first, each text in the archive image is calibrated, the text calibration frame is filtered by checking whether the calibration frame conforms to the text size, then the filtered text calibration frame is cropped to obtain a text picture list. Further, in the preset component and / or text component, the font specified in the personnel archive digitization technical specification is used to draw the corresponding size specification required component picture and text component picture, and the component picture and text component picture are converted into picture data with a preset background and proportion requirement through mask operation and proportion setting; the corresponding feature key point map is generated by performing FAST feature detection on the picture data, the component list configuration file is generated according to the preset component type and text type, and the configuration file is used to obtain the preset component and text component
[0067] After the above inclination correction processing, the digitized archive has reached the inclination specification requirement of the “Cadre Personnel Archive Digitization Technical Specification”, but may exist upside down, therefore, the adaptive upside down correction algorithm is set in the embodiment, which is divided into a component generation module and a component detection module. The component detection module contains two parts, which are component detection and text component detection. The definition of component r =(template r ,mask r ,bone r ,type r ,threshold r ,width r ,height r ,scale r ) and the definition of text component is component w =(template w ,mask w ,type w ,threshold w ,width w ,height w ). In component r , template r represents a template picture, as shown in (1) of Figure 9 ; mask r represents a target area of interest in template matching, as shown in (2) of Figure 9 ; bone r is used to save component key point information, as shown in (3) of Figure 9 ; type rThe type of the component, there are five types, respectively, the full area class, left area class, upper area class, right area class and lower area class, as shown in Figure 7 ; r The template matching similarity threshold, the threshold is 0.81 by default in the generation module; width r , height r The maximum bounding rectangle of the template picture, as shown in Figure 8 ; scale r The proportion of the component. The basic class is composed of character components and component components, type w There is only one type, as shown in Figure 7 (6); width w , height w The maximum bounding rectangle of the template picture. Figure 5 And Figure 6 The flow chart of component generation and component detection.
[0068] The steps of the component generation algorithm can be designed as follows:
[0069] Step 1: text and component picture generation. Use the new songti specified in the digital technology specification of cadre personnel file to draw the picture template r Or template w . Its size specification: 500*500.
[0070] Step 2: calculate the width and height of the text or component. Using the method introduced in step four of the tilt correction module, the four corner points of the picture can be determined, which will extend the left corner point to the left along the vertical direction, and then extend the upper and lower corner points along the horizontal direction. The straight line extended in this way will form a rectangle, as shown in Figure 8 , the gray transparent area represents the rectangular area, and the width and height of the area represent the width and height of the text or component, that is, width w The X axis direction of the left and right corner points is subtracted, and height w The Y axis direction of the upper and lower corner points is subtracted.
[0071] Step 3: generate text mask w Or component picture mask r . Convert the generated text template w Or component picture template r To black and white, and expand the white area by erosion operation, as shown in Figure 9 (2).
[0072] Step 4: Discriminate the generated template type. There are 5 types of radical types, namely type r = {0, 1, 2, 3, 4}, which is determined by the area where the black pixels are located. The area is distinguished by the black pixel points above, below, left, and right of the center point. In (1) of 9, the black pixels occupy the upper, lower, left, and right 4 areas of the image, so it is the radical type 0; in Figure 9 (2) of, the black pixels are only distributed in the left area, so it is type 1. The discrimination of the remaining types is similar to type 1. The judgment of the remaining types can be referred to Figure 9 . The present invention further improves the accuracy of up and down inversion discrimination by establishing common words in the personnel file, and its type type w = {5}.
[0073] Step 5: Calculate the radical occupancy ratio scale r . In the radical type 0 and the character type, since the whole picture is occupied, there is no need to calculate the occupancy ratio. The shortest distance from the inner boundary of the circumscribed rectangle of the radical through the inside of the rectangle to the outer boundary of the image becomes the radical occupancy ratio. Figure 10 is a schematic diagram of the radical occupancy ratio. In step 2, the x coordinate of the right boundary of the rectangle surrounded by the radical type 1 is the radical occupancy ratio length l , and its occupancy ratio is expressed as For type 2, the y-axis coordinate of the lower boundary of the rectangle is expressed as the radical occupancy ratio length u , and the occupancy ratio is For type 3, the distance from the left boundary of the rectangle to the right boundary of the image becomes the occupancy ratio, and its occupancy ratio For the occupancy ratio of type 4, it is the distance from the upper boundary of the rectangle to the lower boundary of the image, and the occupancy ratio is
[0074] Step 6: Generate the radical feature key point map bone r . Perform FAST feature detection on the generated radical map to obtain feature points and draw them into a map. As shown in (3) of Figure 9 .
[0075] Step 7: Component generation and generation of configuration files. Considering the actual application scenario of the personnel file, introduce "辶" with radical type 0; "亻", "纟", "马", "木", "扌" with radical type 1; "宀" with radical type 2; "阝" with radical type 3, "心" with radical type 4; "表", "名", "员", "专", "学" with character type 5. Generate a radical component list The text component list is Convert the generated component list into the corresponding configuration file.
[0076] As a preferred embodiment, further, the preset component and / or character component are used to match the character information in the archive image to determine the upside-down situation of the archive image. First, the occlusion rectangular region is generated according to the component type and the preset proportion, and the character component external rectangle is determined according to the occluded picture, and the component image scaling ratio is calculated according to the external rectangle size and the component specification. Then, the extracted archive character picture and the component image are matched in the positive and negative directions according to the template matching method, and the number of characters with high similarity to the positive and negative templates in the archive picture is counted respectively. Finally, whether the archive image is upside down is determined by the number.
[0077] The steps of the component detection algorithm can be designed as follows:
[0078] Step one: component detection preprocessing. First, read the configuration file for digitized archives to generate corresponding components. Then, use NL-Means algorithm for noise reduction processing on the digitized archives processed by Fourier and outer margin fitting module. Then use the region feature extraction MSER algorithm to calibrate each Chinese character. For the screening of the calibration frame, check whether the calibration frame meets the characteristics of approximate equal height and width of Chinese characters. Finally, crop each Chinese character to generate a picture list L n ={image0, image1, …, image i , …, image n}. As shown in FIG. 8, the gray box represents an image i . Figure 11
[0079] Step two: generate the occlusion rectangular region. Suppose the component used at present is image i is the picture to be positioned. If the width of the character image image i is w t and the height is h t . First, calculate the occlusion region, generate an occlusion rectangle according to the component type and the proportion , and the position of the occlusion rectangle changes with the component type.
[0080] If the component type is 0, a white background rectangle with a width of and a height of h t is generated in the left half of the character picture; if the component type is 1, a white area with a width of w t and a height of is generated in the lower half of the character picture. Type 0 and 2 are similar, the difference is that the occlusion rectangle is in the left half of the picture, and similarly, type 3 occlusion region is in the upper half of the image. In Figure 12 (2) Display type 1 occlusion rectangle, in Figure 12 (3) shows the effect after occlusion.
[0081] Step 3: Calculate the image scaling ratio. In Step 2, only the radical portion of the occluded image remains. Using the method described in Step 4 of the tilt correction module, the bounding rectangle of the radical can be determined, such as... Figure 12 As shown in (4). Assuming the text image i The width of the bounding rectangle of the radical is w r The height is h r Then, based on the radical component type In the computing component The scaling factor.
[0082] If the radical type It is 0 or 2, and the scaling factor is... If the radical type It is 1 or 3, and the scaling factor is... Finally The width and height are reduced to 500*scale.
[0083] For text components The maximum bounding rectangle is also determined using the method in step four of the tilt correction module. Proportion Scaling is performed.
[0084] Step 4: Radical component detection. Similarity matching is performed using template matching, where the input image is an image. i The template is The target area of interest is The output is a text image. i With template Similarity. Text and image list L n Based on this, the radical components Perform template matching and count similarities greater than 1. And the number of keypoints detected is amount. Then L n The images are then inverted and matched again. The similarity after inversion is calculated to be greater than [value missing]. The number of keypoints detected is `re_amount`. If `amount + re_amount > 10` and `amount > re_amount`, the numeric file is placed in the correct orientation. If `amount + re_amount < 10`, further text component matching is required. The matching method is basically the same as radical matching, but only the similarity greater than 10 is counted. The number of elements will not be used for keypoint detection.
[0085] Key point detection refers to the text image image i with the component The similarity is greater than When, each key point to the black pixel should be within a reasonable range. The rectangular region I I Matched by the template is cropped And the AND operation is performed to obtain an image I J With only the component part In the white pixel coordinates Represent the scaled key points, calculate the shortest distance from the key points to the black pixels in I J If the shortest distance is greater than 0.12 times the width of image I J It is considered that image i And Not similar. An example of the flow in key point detection is shown in FIG. 13, Figure 13 (1) of which represents image i , Figure 13 The black region in (2) is the adaptive template box selected region I I , Figure 13 (3) of which is image I J , Figure 13 (4) of which is image I J Binaryzation Figure 13 (5) of which the gray points represent the key points.
[0086] Step five: Invert image flipping. The inverted file image determined in step four is flipped to obtain a file picture with the content of the text in the forward direction and the inclination angle conforming to the specification.
[0087] Further, based on the above method, the embodiment of the present application also provides a digital archive rectification correction system, comprising: an image data reading module, an image angle correction module and an image direction flipping module, wherein
[0088] The image data reading module is used to read the scanned archive image to be rectified and corrected, and to pre-process the archive image, wherein the pre-processing at least includes white edge cropping and grayscale processing;
[0089] The image angle correction module is used to obtain the inclination angle a of the pre-processed archive image by using Fourier transform, to determine the outer boundary line of the archive image and the inclination angle β by boundary fitting, and to correct the inclination of the archive image by using spatial affine transformation;
[0090] The image direction flipping module is used for extracting a list of character pictures in the archive image, and matching the character pictures in the archive image by using preset components of radicals and / or characters, determining the upside-down situation of the archive image, and flipping the upside-down archive image to obtain an archive image with correct character content and inclination angle.
[0091] Unless specifically stated otherwise, the relative steps, numerical expressions, and numerical values of components and steps set forth in these embodiments do not limit the scope of the present application.
[0092] The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other. For the system disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple, and the relevant parts can be referred to the method part.
[0093] The units and method steps of each example described in combination with the embodiments disclosed herein can be realized in electronic hardware, computer software or a combination of both. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been described in the above description in general terms. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation does not exceed the scope of the present application.
[0094] Those skilled in the art can understand that all or part of the steps in the above method can be instructed by a program to complete the relevant hardware, and the program can be stored in a computer readable storage medium, such as a read-only memory, a magnetic disk or an optical disk. Alternatively, all or part of the steps of the above embodiments can also be implemented using one or more integrated circuits, and accordingly, each module / unit in the above embodiments can be implemented in the form of hardware or in the form of a software function module. The present application is not limited to any specific form of combination of hardware and software.
[0095] Finally, it should be noted that the above-described embodiments are merely specific embodiments of the present application, which are used to illustrate the technical solutions of the present application, but not to limit the same. The protection scope of the present application is not limited thereto. Although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those skilled in the art that any person skilled in the art can still modify or easily think of changes to the technical solutions recorded in the foregoing embodiments, or make equivalent replacements to some of the technical features, within the technical scope disclosed by the present application. The modifications, changes or replacements do not cause the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be covered within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.
Claims
1. A method for digital archive rectification correction, characterized in that, The application relates to a method for correcting a scanned file image, and comprises the following steps: reading the scanned file image to be corrected, and performing preprocessing on the file image, wherein the preprocessing at least comprises white edge trimming and grayscale processing; acquiring the tilt angle a of the preprocessed file image by using Fourier transform, and judging whether the file image has an outer boundary; if the file image has an outer boundary, the outer boundary line of the file image is determined by boundary fitting, and the tilt angle beta of the outer frame of the file image is determined; the boundary is trimmed based on the tilt angle a of the file image and the tilt angle beta of the outer frame of the file image, and the tilt of the file image is corrected by using spatial affine transformation; if the file image does not have an outer boundary, the tilt of the file image is directly corrected by using spatial affine transformation based on the tilt angle a of the file image; extracting a list of character pictures in the file image, and matching the character pictures in the file image by using preset partial character components and / or character components; the upside-down state of the file image is determined, and the file image is flipped to obtain a file image with correct character content and tilt angle.
2. The method of claim 1, wherein, In the process of acquiring the tilt angle of the file image by using Fourier transform, firstly, the frequency domain distribution of the file image is obtained by performing two-dimensional discrete Fourier transform on the file image; then, the frequency domain distribution is redrawn by using Hough transform to detect straight lines, and the straight lines are drawn on the frequency domain distribution to obtain the corresponding frequency domain graph; the noise on the frequency domain graph is eliminated by traversing the whole connected domain of the frequency domain graph, and the skew base graph and the skew auxiliary graph are obtained by frequency channel separation; the tilt angle a of the file image is obtained by using the skew base graph and the skew auxiliary graph.
3. The method of claim 2, wherein, In the process of acquiring the tilt angle of the file image by using the skew base graph and the skew auxiliary graph, the following steps are included: the skew base graph feature distribution graph is obtained by using FAST feature detection, and the coordinates of the end points of each straight line are calculated according to the feature point distribution graph; in the skew auxiliary graph, whether the file image meets the tilt requirement is determined according to the preset tilt determination condition; for the file image that does not meet the tilt requirement, the tilt angle of the file image is obtained by using the included angle between the horizontal straight line slope of the file and the vertical straight line slope of the file, wherein the preset tilt determination condition is that the horizontal and vertical mark bits are true and the area of the maximum circumscribed rectangle of the skew base graph meets the preset area requirement.
4. The method of claim 1, wherein, When the file image has an outer boundary, the outer boundary line of the file image is determined by boundary fitting. Firstly, the preprocessed grayscale file image is binarized, and each top corner rectangular block of the file image is trimmed, and the black edges of the file image are determined according to the average value of the rectangular block; then, the boundary position of the file image is located and the boundary hash point set is drawn according to the preset color pixel point and the corresponding pixel point coordinates; then, the boundary line of the file image is fitted by using the least square method, and the tilt angle beta of the outer frame of the file image is calculated by using the slope of the fitted straight line.
5. The method of claim 4, wherein, The process of fitting the boundary line of the archive image by using the least square method comprises the following contents: firstly, the regional key nodes are determined by using the shortest distance from each vertex of the archive image to the hash points of the boundary, the archive image is divided into regions by connecting the regional key nodes with the center point of the archive image respectively, a straight line is arranged in each region, and in the process of fitting the straight line, the nearest two vertices of the current straight line fitting region and other regions are combined to form a mask polygon, and the corresponding direction point set is obtained by performing the and operation between the polygon and the hash point image; the fitting straight line equation is obtained by fitting the direction point set by using the least square method.
6. The method of claim 4, wherein, In the process of calculating the tilt angle of the outer frame of the archive image by using the slope of the fitting straight line, firstly, the slope of the fitting straight line is converted into a direction identifier, the tilt direction of the archive image is obtained according to the direction identifier, and the slope of the fitting straight line is converted into the included angle in the horizontal direction; then, the two most similar angles in the horizontal direction are obtained by using the shortest distance formula, and the horizontal tilt angle is obtained according to the two most similar angles; finally, the tilt angle of the archive image is determined according to the tilt angle and the tilt direction.
7. The method of claim 1, wherein, In the process of extracting the text information in the archive image, firstly, each text in the archive image is calibrated, the text calibration frame is filtered by checking whether the calibration frame meets the text size, and then the text calibration frame after the filtering is cropped to obtain a text picture list.
8. The method of claim 1, wherein, In the process of matching the text information in the archive image by using the preset component and / or text component to determine whether the archive image is upside down, firstly, the occlusion rectangular region is generated according to the component type and the preset proportion, the text component external rectangle is determined according to the occluded picture, and the component image scaling ratio is calculated according to the size of the external rectangle and the component specification; Then, the extracted archive text picture and the component image are matched in the template similarity in two directions of positive and negative inversion according to the template matching method, the number of texts in the archive picture with high similarity to the positive and negative templates is counted respectively, and finally whether the archive image is inverted is determined by the number.
9. The method of digital archive deskewing correction of claim 1 or 7 or 8, wherein, In the process of obtaining the preset component and / or text component, the font specified in the personnel archive digitization technical specification is used to draw the component picture and the text component picture with the corresponding size specification requirements, and the component picture and the text component picture are converted into picture data with the preset background and proportion requirements through the mask operation and the proportion setting; the corresponding feature key point map is generated by performing the FAST feature detection on the picture data, the component list configuration file is generated according to the preset component type and the text type, and the preset component and the text component are obtained by using the configuration file.
10. A digital archive deskewing correction system, characterized by, It comprises an image data reading module, an image angle correction module and an image direction flip module, wherein, The image data reading module is used for reading the scanned archive image to be corrected, and pre-processing the archive image, the pre-processing at least comprises white edge cropping and grayscale processing; The image angle correction module is configured to obtain a pre-processed archive image tilt angle a by using Fourier transform, and determine whether an outer boundary exists in the archive image. If the outer boundary exists, the outer boundary line of the archive image and the outer boundary tilt angle β of the archive image are determined by boundary fitting, the boundary is cropped based on the archive image tilt angle a+the outer boundary tilt angle β of the archive image, and the archive image tilt is corrected by using spatial affine transformation. If the outer boundary does not exist, the archive image tilt is directly corrected by using spatial affine transformation based on the archive image tilt angle a. The image direction flip module is configured to extract a list of text pictures in the archive image, match the text pictures in the archive image by using preset components of radicals and / or components of characters, determine an upside-down condition of the archive image, and flip the upside-down archive image to obtain an archive image with correct text content and a tilt angle that meets the standard requirements.
Citation Information
Patent Citations
Method and device for determining page angle of slope
CN101425142A
Inclined image corrector, inclined image correction method and storage medium
JP1999308437A