Document image dotted line detection method

Through the methods of document image preprocessing, dotted line feature extraction and line segment detection, the difficulty of identifying dotted line detection in the prior art under noise and complex backgrounds is solved, and a high-precision dotted line detection effect is achieved.

CN119832560AActive Publication Date: 2025-04-15SHANGHAI ZHIYU INFORMATION TECH CO LTD +1
View PDF 11 Cites 0 Cited by

Patent Information

Application Number
CN202411857075.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-17
Publication Date
2025-04-15
Estimated Expiration
2044-12-17

AI Technical Summary

Technical Problem

The prior art When detecting dotted lines in document images, the presence of noise, background complexity and different dotted line styles leads to the challenge of identifying and extracting dotted lines, especially when there is a large amount of noise or dense text in the image, the detection effect is poor.

Method used

A method for detecting dotted line of document image is proposed, including document image preprocessing, dotted line feature extraction and line segment detection. Through image graying and binarization, horizontal and vertical feature enhancement and denoising are performed, dotted line feature maps are extracted, and horizontal and vertical line detection is combined with interference line segment removal and adjacent line segment splicing to form a dotted line segment set.

Benefits of technology

This method can effectively detect dotted lines in document images, ensure accurate acquisition of dotted line segments, and is suitable for document images containing dotted line elements, achieving high-precision dotted line detection effect.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119832560A_ABST
    Figure CN119832560A_ABST
Patent Text Reader

Abstract

The invention discloses a document image dotted line detection method, which comprises the following steps of S1, performing graying and binarization processing on an input image to extract foreground features of a document; s2, performing feature enhancement and de-noising processing on the binarized image to extract dotted line features of the binarized image and reduce noise interference; and S3, extracting straight line segments in the dotted line feature image through a straight line detection algorithm, and connecting related straight line segments to obtain a dotted line. According to the method, the dotted line features and straight line processing are combined, extraction of the dotted line features of the document image is achieved, the straight line segments in the document image can be accurately detected, the method is suitable for various document images containing dotted lines, and the accuracy and efficiency of dotted line detection of the document image are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of document image processing, and in particular relates to a document image dotted line detection method. Background Art

[0002] With the rapid development of information digitization, the processing and analysis of document images has become increasingly important. Among many document formats, dotted lines, as a common visual element, are widely used in tables, charts and various documents to separate, mark or indicate relationships. However, in the image processing process, due to factors such as noise in document images, background complexity (such as text overlap, background interference, etc.) and different dotted line styles (such as line segment length, interval, etc.), the recognition and extraction of dotted lines faces great challenges.

[0003] There is a patent document named "A straight line segment detection method and system based on prediction and correction mechanism" (publication number: CN117994222A), which uses edge detection technology to detect straight line segments through multi-scale adaptive Canny edge detection, least squares fitting and directional routing correction. However, when there is a lot of noise or dense text in the image, this method cannot accurately detect the dotted lines in the image. Another example is a patent document named "A lightweight image line segment extraction and description method based on deep learning" (publication number: CN115690444A), which constructs an end-to-end line segment detection model that can directly infer the start and end point coordinates of all line segments in the image. However, the generalization ability of the model is not strong, and the universality and accuracy are difficult to guarantee.

[0004] Therefore, it is particularly important to develop a new method that can accurately detect dotted lines in document images while taking into account adaptability and robustness. This patented technology came into being in this context, aiming to achieve efficient and accurate detection of dotted lines in document images through innovative image processing algorithms and strategies. Summary of the invention

[0005] In order to solve the above technical problems, the present invention proposes a method for detecting dotted lines in document images, which can extract dotted line feature maps from document images and accurately detect straight line segments therein.

[0006] The present invention proposes a document image dotted line detection method, which mainly includes the following steps:

[0007] Step S1: document image preprocessing: reading document image I, graying and binarizing document image I, and obtaining binarized image I b ;

[0008] Step S2: dotted line feature extraction; binary image I bPerform lateral feature enhancement and denoising to obtain the horizontal dashed line segment feature map I h , for the binary image I b Perform longitudinal feature enhancement and denoising to obtain the vertical dashed line segment feature map I v ;

[0009] Step S3: Line segment detection: Horizontal dashed line segment feature map I h Perform horizontal line detection. If a horizontal line segment is detected, store the detected horizontal line segment in the first horizontal line segment set Lh1. v Perform vertical line detection, and if a vertical line segment is detected, store the detected vertical line segment into the first vertical line segment set Lv1; remove the interfering horizontal line segments in the first horizontal line segment set Lh1 to obtain the second horizontal line segment set Lh2, and remove the interfering vertical line segments in the first vertical line segment set Lv1 to obtain the second vertical line segment set Lv2; splice the adjacent horizontal line segments in the second horizontal line segment set Lh2 to obtain the third horizontal line segment set Lh3, and splice the adjacent vertical line segments in the second vertical line segment set Lv2 to obtain the third vertical line segment set Lv3; merge the third horizontal line segment set Lh3 and the third vertical line segment set Lv3 to obtain the dotted line segment set Ld of the document image I.

[0010] Furthermore, in step S2, the binary image I b Perform lateral feature enhancement and denoising to obtain the horizontal dashed line segment feature map I h , the specific steps are as follows:

[0011] Step S211, set the horizontal expansion threshold Tdh, set the vertical expansion threshold Tdv, set the horizontal morphological opening operation threshold Toh, set the vertical morphological opening operation threshold Tov, let wi b Represents the binary image I b The width of hi b Represents the binary image I b The height of the lateral feature enhancement structure element Ka is generated with a height of 1 and a width of the lateral expansion threshold Tdh and a rectangular shape, and a height of 1 and a width of Toh×wi b And the lateral denoising structure element K with rectangular shape b ;

[0012] Step S212, using the lateral features to enhance the structural element K a For the binary image I b Perform dilation operation to obtain the horizontal feature enhanced image I c , using the lateral denoising structure element K b Enhance image I for horizontal features c Perform an open operation to obtain the horizontal dashed line segment feature map I h .

[0013] Furthermore, in step S2, the binary image I b Perform longitudinal feature enhancement and denoising to obtain the vertical dashed line segment feature map I v , the specific steps are as follows:

[0014] Step S221, generating a vertical feature enhancement structure element K with a height equal to the vertical expansion threshold Tdv, a width of 1 and a rectangular shape c , generate a height of Tov×hi b , a longitudinal denoising structural element K with a width of 1 and a rectangular shape d ;

[0015] Step S222, using the vertical feature to enhance the structural element K c For the binary image I b Perform dilation operation to obtain the longitudinal feature enhanced image I d , using the longitudinal denoising structure element K d Enhance image I for longitudinal features d Perform an open operation to obtain the vertical dashed line segment feature map I v .

[0016] Furthermore, in step S3, the interfering horizontal line segments in the first horizontal line segment set Lh1 are removed to obtain the second horizontal line segment set Lh2. The specific steps are as follows:

[0017] Step S3101, set the vertical expansion threshold Tev, set the first trough span threshold Ts1, set the first fault tolerance threshold Tt1, set lh f represents the fth horizontal line segment of the first horizontal line segment set Lh1, f=1, 2, ..., nf, nf is the number of horizontal line segments in the first horizontal line segment set Lh1; sets a first variable d and a second variable e, and the initial value of the first variable d is set to 1;

[0018] Step S3102, obtaining the dth horizontal line segment lh in the first horizontal line segment set Lh1 d The x coordinate of the left endpoint d left , get the dth horizontal line segment lh in the first horizontal line segment set Lh1 d The y coordinate of the left endpoint d left , get the dth horizontal line segment lh in the first horizontal line segment set Lh1 d The x coordinate of the right endpoint d right , get the dth horizontal line segment lh in the first horizontal line segment set Lh1 d The y coordinate of the right endpoint d right, calculate the dth horizontal line segment lh in the first horizontal line segment set Lh1 d The average y coordinate y d , the calculation formula is shown in formula (1):

[0019]

[0020] Step S3103: Set the first rectangular cropping area Ar1, and initialize the coordinates of the upper left end point of the first rectangular cropping area Ar1 to (x d left ,y d -Tev), initialize the coordinates of the lower right end point of the first rectangular cropping area Ar1 to (x d right ,y d +Tev); Binarize the image I b Cropping according to the first rectangular cropping area Ar1 obtains the horizontal line segment binary image I lh (d) ;

[0021] Step S3104: Binarize the horizontal line segment image I lh (d) Perform horizontal projection and obtain the horizontal projection vector HP (d) , let hp (d) h Represents the horizontal projection vector HP (d) The hth element in, where h=1,2,…,hi lh (d) ,hi lh (d) I is the horizontal line segment binary image lh (d) The height, horizontal projection vector HP (d) The hth element hp (d) h Represents the horizontal line segment binary image I lh (d) The number of foreground points in the hth row, where the foreground points are pixels with a pixel value of 255;

[0022] Step S3105, calculate the horizontal projection vector HP (d) The maximum projection value hp (d) max , the calculation formula is shown in formula (2):

[0023]

[0024] Step S3106, let hcr min Indicates the minimum change rate of the current horizontal projection, initializes the minimum change rate of the current horizontal projection hcr minHP (d) max ×Tt1;

[0025] Step S3107, set the upper trough flag tf up and the lower side valley mark tf down , initialize the upper valley flag tf up The value is 0, initializing the lower valley flag tf down The value of is 0; set the horizontal projection trough span hts, and initialize the horizontal projection trough span hts to 0;

[0026] Step S3108, setting the value of the second variable e to 1;

[0027] Step S3109, if hp (d) max -hp (d) e <hcr min , then the value of the horizontal projection trough span hts is set to 0, otherwise, the value of the horizontal projection trough span hts is increased by 1;

[0028] Step S3110: if hts≥Ts1, set the upper valley mark tf up The value of is set to 1, and jump to step S3112;

[0029] Step S3111, increase the value of the second variable e by 1, if e≤Tev, jump to step S3109;

[0030] Step S3112, setting the value of the horizontal projection trough span hts to 0, and setting the value of the second variable e to Tev+1;

[0031] Step S3113, if hp (d) max -hp (d) e <hcr min , then the value of the horizontal projection trough span hts is set to 0, otherwise, the value of the horizontal projection trough span hts is increased by 1;

[0032] Step S3114: if hts≥Ts1, set the lower valley mark tf down The value of is set to 1, and jump to step S3116;

[0033] Step S3115, increase the value of the second variable e by 1, if e≤hi lh (d) , then jump to step S3113;

[0034] Step S3116, if tf up=1, tf down = 1, then the dth horizontal line segment lh in the first horizontal line segment set Lh1 is d Add the second horizontal line segment set Lh2;

[0035] Step S3117, increase the value of the first variable d by 1, if d≤nf, jump to step S3102.

[0036] Furthermore, in step S3, the interfering vertical line segments in the first vertical line segment set Lv1 are removed to obtain the second vertical line segment set Lv2. The specific steps are as follows:

[0037] Step S3201, set the horizontal expansion threshold Teh, set the second trough span threshold Ts2, set the second fault tolerance threshold Tt2, set lv g represents the g-th vertical line segment of the first vertical line segment set Lv1, g=1, 2, ..., ng, ng is the number of vertical line segments in the first vertical line segment set Lv1; sets a third variable t and a fourth variable v, and the initial value of the third variable t is set to 1;

[0038] Step S3202, obtaining the tth vertical line segment lv in the first vertical line segment set Lv1 t The x coordinate of the upper endpoint x t up , get the tth vertical line segment lv in the first vertical line segment set Lv1 t The y coordinate of the upper endpoint t up , get the tth vertical line segment lv in the first vertical line segment set Lv1 t The x coordinate of the lower endpoint x t down , get the tth vertical line segment lv in the first vertical line segment set Lv1 t The y coordinate of the lower endpoint t down , calculate the tth vertical line segment lv in the first vertical line segment set Lv1 t The average x coordinate x t , the calculation formula is shown in formula (3):

[0039]

[0040] Step S3203, set the second rectangular cropping area Ar2, and initialize the coordinates of the upper left end point of the second rectangular cropping area Ar2 to (x t -Teh,y t up ), initialize the lower right end point coordinate of the second rectangular cropping area Ar2 to (x t -Teh,y t down);The binary image I b Cropping according to the second rectangular cropping area Ar2 obtains the vertical line segment binary image I lv (t) ;

[0041] Step S3204: binarize the vertical line segment image I lv (t) Perform vertical projection to obtain the vertical projection vector VP (t) , let vp (t) w Represents the vertical projection vector VP (t) The wth element in, where w=1,2,…,wi lv (t) , wi lv (t) I is the vertical line segment binary image lv (t) The width of the vertical projection vector VP (t) The wth element vp in (t) w Represents the vertical line segment binary image I lv (t) The number of foreground points in the wth column, where the foreground points are pixels with a pixel value of 255;

[0042] Step S3205, calculate the vertical projection vector VP (t) The maximum projection value vp in (t) max , the calculation formula is shown in formula (4):

[0043]

[0044] Step S3206, let vcr min Indicates the minimum change rate of the current vertical projection, initializes the minimum change rate vcr of the current vertical projection min For vp (t) max ×Tt2;

[0045] Step S3207, set the left trough flag tf left and the right trough mark tf right , initialize the left trough flag tf left The value is 0, initializing the right trough flag tf right The value of is 0; set the vertical projection trough span vts, and initialize the value of the vertical projection trough span vts to 0;

[0046] Step S3208, setting the value of the fourth variable v to 1;

[0047] Step S3209, if vp(t) max -vp (t) v <vcr min , then the value of the vertical projection trough span vts is set to 0, otherwise, the value of the vertical projection trough span vts is increased by 1;

[0048] Step S3210: If vts ≥ Ts2, set the left valley mark tf left The value of is set to 1, and jump to step S3212;

[0049] Step S3211, increase the value of the fourth variable v by 1, if v≤Teh, jump to step S3209;

[0050] Step S3212, setting the value of the vertical projection trough span vts to 0, and setting the value of the fourth variable v to Teh+1;

[0051] Step S3213, if vp (t) max -vp (t) v <vcr min , then the value of the vertical projection trough span vts is set to 0, otherwise, the value of the vertical projection trough span vts is increased by 1;

[0052] Step S3214: if vts ≥ Ts2, set the right valley mark tf right The value of is set to 1, and jump to step S3216;

[0053] Step S3215, increase the value of the fourth variable v by 1, if v≤wi lv (t) , then jump to step S3213;

[0054] Step S3216, if tf left =1, tf right = 1, then the tth vertical line segment lv in the first vertical line segment set Lv1 t Add the second vertical line segment set Lv2;

[0055] Step S3217, increase the value of the third variable t by 1. If t≤ng, jump to step S3202.

[0056] Furthermore, in step S3, adjacent horizontal line segments in the second horizontal line segment set Lh2 are spliced ​​to obtain a third horizontal line segment set Lh3, and the specific steps are as follows:

[0057] Step S3301, sorting all horizontal line segments in the second horizontal line segment set Lh2 in ascending order according to the y coordinates of the left endpoints of the horizontal line segments;

[0058] Step S3302, set the first distance threshold Td1, set the second distance threshold Td2, let lh i ' represents the i-th horizontal line segment of the second horizontal line segment set Lh2, i = 1, 2, ..., ni, ni is the number of horizontal line segments in the second horizontal line segment set Lh2; define a horizontal line segment splicing mark set Fh containing n splicing mark variables, the i-th splicing mark variable fh in the horizontal line segment splicing mark set Fh i represents the splicing mark of the i-th horizontal line segment in the second horizontal line segment set, and the splicing mark fh of the i-th horizontal line segment in the second horizontal line segment set i The initial value is set to 0; the fifth variable k and the sixth variable j are set; the initial value of the fifth variable k is set to 0;

[0059] Step S3303: increase the value of the fifth variable k by 1. If k>ni-1, jump to step S3311;

[0060] Step S3304, if fh k =1, jump to step S3303, otherwise, set the value of the sixth variable j to the fifth variable k;

[0061] Step S3305, increase the value of the sixth variable j by 1, if j>ni, jump to step S3303;

[0062] Step S3306, if fh j =1, jump to step S3305;

[0063] Step S3307, if x k right ' <x j left ', where x k right ' represents the x coordinate of the right endpoint of the kth horizontal line segment of the second horizontal line segment set Lh2, x j left ' represents the x coordinate of the left endpoint of the jth horizontal line segment of the second horizontal line segment set Lh2, then the kth horizontal line segment lh of the second horizontal line segment set Lh2 is determined k 'The jth horizontal line segment lh in the second horizontal line segment set j 'Left side; if x j right ' <x k left ', where x j right’ represents the x - coordinate of the right - endpoint of the j - th horizontal line segment in the second set of horizontal line segments Lh2, x k left ’ represents the x - coordinate of the left - endpoint of the k - th horizontal line segment in the second set of horizontal line segments Lh2, then it is determined that the j - th horizontal line segment lh j ’ in the second set of horizontal line segments is located to the left of the k - th horizontal line segment lh k ’ in the second set of horizontal line segments Lh2;

[0064] Step S3308, if the k - th horizontal line segment lh k ’ in the second set of horizontal line segments Lh2 is located to the left of the j - th horizontal line segment lh j ’ in the second set of horizontal line segments, |x k right ’ - x j left ’| < Td1, and |y k right ’ - y j left ’| < Td1, then connect the left - endpoint of the k - th horizontal line segment lh k ’ in the second set of horizontal line segments Lh2 with the right - endpoint of the j - th horizontal line segment lh j ’ in the second set of horizontal line segments to obtain a horizontal splicing line segment lc k,j ; otherwise, if the j - th horizontal line segment lh j ’ in the second set of horizontal line segments is located to the left of the k - th horizontal line segment lh k ’ in the second set of horizontal line segments Lh2, |x j right ’ - x k left ’| < Td1, and |y j right ’ - y k left ’| < Td1, then connect the left - endpoint of the j - th horizontal line segment lh j ’ in the second set of horizontal line segments with the right - endpoint of the k - th horizontal line segment lh k ’ in the second set of horizontal line segments Lh2 to obtain a horizontal splicing line segment lc k,j ; otherwise, jump to step S3305;

[0065] Step S3309, calculate the vertical distance dh k from the left - endpoint of the k - th horizontal line segment lh k,j ’ in the second set of horizontal line segments Lh2 to the horizontal splicing line segment lc k,1 and the vertical distance dh k from the right - endpoint of the k - th horizontal line segment lh k,j ’ in the second set of horizontal line segments Lh2 to the horizontal splicing line segment lck,2 and the vertical distance dh from the left endpoint of the j-th horizontal line segment lh in the second set of horizontal line segments j ’ to the horizontal splicing line segment lc k,j ; j,3 and the vertical distance dh from the right endpoint of the j-th horizontal line segment lh in the second set of horizontal line segments j ’ to the horizontal splicing line segment lc k,j ; j,4 ;

[0066] Step S3310, if dh k,1 <Td2 and dh k,2 <Td2 and dh j,3 <Td2 and dh j,4 <Td2, then set the splicing marks fh of the k-th horizontal line segment in the second set of horizontal line segments k and the splicing mark fh of the j-th horizontal line segment in the second set of horizontal line segments j to 1, and add the horizontal splicing line segment lc k,j to the third set of horizontal line segments Lh3; jump to step S3303;

[0067] Step S3311, traverse each splicing mark in the set of horizontal line segment splicing marks Fh. If the i-th variable fh in the set of horizontal line segment splicing marks Fh i is 0, then add the i-th horizontal line segment lh i ’ in the second set of horizontal line segments Lh2 to the third set of horizontal line segments Lh3.

[0068] Furthermore, in step S3, adjacent vertical line segments in the second set of vertical line segments Lv2 are spliced to obtain the third set of vertical line segments Lv3. The specific steps are as follows:

[0069] Step S3401, sort each vertical line segment in the second set of vertical line segments Lv2 in ascending order according to the x coordinate of the upper endpoint of the vertical line segment;

[0070] Step S3402, let lv j ’ represent the j-th vertical line segment in the second set of vertical line segments Lv2, where j = 1, 2,..., nj, and nj is the number of vertical line segments in the second set of vertical line segments Lv2; define a set of vertical line segment splicing marks Fv containing o splicing mark variables. The j-th splicing mark variable fv j in the set of vertical line segment splicing marks Fv represents the splicing mark of the j-th vertical line segment in the second set of vertical line segments. The initial value of the splicing mark fv j of the j-th vertical line segment in the second set of vertical line segments is set to 0; set the seventh variable u and the eighth variable s; the initial value of the seventh variable u is set to 0;

[0071] Step S3403, increment the value of the seventh variable u by 1. If u > nj - 1, then jump to step S3411;

[0072] Step S3404, if fv u = 1, then jump to step S3403; otherwise, set the value of the eighth variable s to the seventh variable u;

[0073] Step S3405, increment the value of the eighth variable s by 1. If s > nj, then jump to step S3403;

[0074] Step S3406, if fv j = 1, then jump to step S3405;

[0075] Step S3407, if y s down ’ < y u up ’, where y s down ’ represents the y - coordinate of the lower endpoint of the s - th vertical line segment in the second vertical line segment set Lv2, and y u up ’ represents the y - coordinate of the upper endpoint of the u - th vertical line segment in the second vertical line segment set Lv2, then determine that the s - th vertical line segment lv s ’ in the second vertical line segment set Lv2 is above the u - th vertical line segment lv u ’; if y u down ’ < y s up ’, where y u down ’ represents the y - coordinate of the lower endpoint of the u - th vertical line segment in the second vertical line segment set Lv2, and y s up ’ represents the y - coordinate of the upper endpoint of the s - th vertical line segment in the second vertical line segment set Lv2, then determine that the u - th vertical line segment lv u ’ in the second vertical line segment set Lv2 is above the s - th vertical line segment lv s ’;

[0076] Step S3408, if the u - th vertical line segment lv u ’ in the second vertical line segment set Lv2 is above the s - th vertical line segment lv s ’, |x u down ’ - x s up ’| < Td1, and |y u down’-y s up ’| <Td1, then connect the upper endpoint of the u-th vertical line segment lv u ’ in the second set of vertical line segments Lv2 to the lower endpoint of the s-th vertical line segment lv s ’ in the second set of vertical line segments Lv2 to obtain the vertical splicing line segment lc u,s ; otherwise, if the s-th vertical line segment lv s ’ in the second set of vertical line segments Lv2 is above the u-th vertical line segment lv u ’ in the second set of vertical line segments Lv2, |x s down ’-x u up ’| <Td1 and |y s down ’-y u up ’| <Td1, then connect the upper endpoint of the s-th vertical line segment lv s ’ in the second set of vertical line segments Lv2 to the lower endpoint of the u-th vertical line segment lv u ’ in the second set of vertical line segments Lv2 to obtain the vertical splicing line segment lc u,s ; otherwise, jump to step S3405;

[0077] Step S3409, calculate the vertical distance dv u from the upper endpoint of the u-th vertical line segment lv u,s ’ in the second set of vertical line segments Lv2 to the vertical splicing line segment lc u,1 , the vertical distance dv u from the lower endpoint of the u-th vertical line segment lv u,s ’ in the second set of vertical line segments Lv2 to the vertical splicing line segment lc u,2 , the vertical distance dv s from the upper endpoint of the s-th vertical line segment lv u,s ’ in the second set of vertical line segments Lv2 to the vertical splicing line segment lc s,3 and the vertical distance dv s from the lower endpoint of the s-th vertical line segment lv u,s ’ in the second set of vertical line segments Lv2 to the vertical splicing line segment lc s,4 ;

[0078] Step S3410, if dv u,1 <Td2, dv u,2 <Td2, dv s,3 <Td2, dv s,4 <Td2, then set the splicing flag fv u of the u-th vertical line segment in the second set of vertical line segments and the splicing flag fvs The values ​​are all set to 1, and the vertical splicing line segment lc u,s Add the third vertical line segment set Lv3; jump to step S3403;

[0079] Step S3411, traverse each splicing mark in the vertical line segment splicing mark set Fv, if the j-th variable fv in the vertical line segment splicing mark set Fv j is 0, then the jth vertical line segment lv in the second vertical line segment set Lv2 j 'Add the third vertical line segment set Lv3.

[0080] The beneficial effects of the present invention are as follows: the present invention provides a method for detecting dotted lines in document images, which effectively utilizes the dotted line features in the document images to ensure the accurate acquisition of dotted line segments, is suitable for dotted line feature extraction and detection of various document images containing dotted line elements, and can achieve high-precision dotted line detection effects. BRIEF DESCRIPTION OF THE DRAWINGS

[0081] The present invention will be further described in detail below in conjunction with the accompanying drawings and specific embodiments.

[0082] Figure 1 is a method flow chart of an embodiment of the present invention;

[0083] Figure 2 is the original image of Example 1 of the present invention;

[0084] Figure 3 is the binary image obtained in step S2 of embodiment 1 of the present invention;

[0085] Figure 4 is the horizontal dashed line segment characteristic graph obtained in step S2 of embodiment 1 of the present invention;

[0086] Figure 5 is the vertical dashed line segment feature graph obtained in step S2 of embodiment 1 of the present invention;

[0087] Figure 6 This is a diagram of the dotted line segment detection result obtained in step S3 of Example 1 of the present invention. DETAILED DESCRIPTION

[0088] The specific implementation of the present invention will be further described in detail below in conjunction with the accompanying drawings in the embodiments of the present invention. It should be noted that the specific embodiment of the document image dotted line detection method according to the present invention is only used as an example and is not intended to limit the present invention.

[0089] This embodiment is combined with a dotted line document image I with a width of 857 and a height of 1228 to illustrate a document image dotted line detection method proposed by the present invention. Figure 1As shown in the method flow chart, the present invention adopts the following steps to detect dotted lines in a document image:

[0090] Step S1: document image preprocessing; reading document image I, such as Figure 2 As shown, the document image I is grayed and binarized to obtain a binary image I b ,like Figure 3 As shown;

[0091] The image binarization algorithm in the above steps is a common method for image binarization. For details, see Tensmeyer, Chris and Tony R.Martinez. "Historical Document Image Binarization: A Review." SN Computer Science 1, 2020;

[0092] Step S2: dotted line feature extraction; binary image I b Perform lateral feature enhancement and denoising to obtain the horizontal dashed line segment feature map I h ,like Figure 4 As shown, for the binary image I b Perform longitudinal feature enhancement and denoising to obtain the vertical dashed line segment feature map I v ,like Figure 5 As shown;

[0093] Step S3: Line segment detection: Horizontal dashed line segment feature map I h Perform horizontal line detection, detect horizontal line segments, store the detected horizontal line segments in the first horizontal line segment set Lh1, and perform vertical dashed line segment feature map I v Perform vertical line detection, detect vertical line segments, and store the detected vertical line segments in the first vertical line segment set Lv1; remove the interfering horizontal line segments in the first horizontal line segment set Lh1 to obtain the second horizontal line segment set Lh2, remove the interfering vertical line segments in the first vertical line segment set Lv1 to obtain the second vertical line segment set Lv2; splice the adjacent horizontal line segments in the second horizontal line segment set Lh2 to obtain the third horizontal line segment set Lh3, splice the adjacent vertical line segments in the second vertical line segment set Lv2 to obtain the third vertical line segment set Lv3; merge the third horizontal line segment set Lh3 and the third vertical line segment set Lv3 to obtain the dotted line segment set Ld of the document image I. The dotted line segment detection result is shown in FIG. Figure 6 shown.

[0094] The line segment detection algorithm in the above steps is a common method for line segment detection in images. For details, see Lin X, Zhou Y, Liu Y, et al. A Comprehensive Review of Image Line Segment Detection and Description: Taxonomies, Comparisons, and Challenges [J]. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2024;

[0095] Furthermore, in step S2, the binary image I b Perform lateral feature enhancement and denoising to obtain the horizontal dashed line segment feature map I h , the specific steps are as follows:

[0096] Step S211, set the lateral expansion threshold Tdh = 5, set the longitudinal expansion threshold Tdv = 5, set the lateral morphological opening operation threshold Toh = 0.167, set the longitudinal morphological opening operation threshold Tov = 0.034, and set wi b Represents the binary image I b The width of hi b Represents the binary image I b The height of the lateral feature enhancement structure element Ka is generated with a height of 1 and a width of the lateral expansion threshold Tdh and a rectangular shape, and a height of 1 and a width of Toh×wi b And the lateral denoising structure element K with rectangular shape b ;

[0097] Step S212, using the lateral features to enhance the structural element K a For the binary image I b Perform dilation operation to obtain the horizontal feature enhanced image I c , using the lateral denoising structure element K b Enhance image I for horizontal features c Perform an open operation to obtain the horizontal dashed line segment feature map I h .

[0098] Furthermore, in step S2, the binary image I b Perform longitudinal feature enhancement and denoising to obtain the vertical dashed line segment feature map I v , the specific steps are as follows:

[0099] Step S221, generating a vertical feature enhancement structure element K with a height equal to the vertical expansion threshold Tdv, a width of 1 and a rectangular shape c, generate a height of Tov×hi b , a longitudinal denoising structural element K with a width of 1 and a rectangular shape d ;

[0100] Step S222, using the vertical feature to enhance the structural element K c For the binary image I b Perform dilation operation to obtain the longitudinal feature enhanced image I d , using the longitudinal denoising structure element K d Enhance image I for longitudinal features d Perform an open operation to obtain the vertical dashed line segment feature map I v .

[0101] Furthermore, in step S3, the interfering horizontal line segments in the first horizontal line segment set Lh1 are removed to obtain the second horizontal line segment set Lh2. The specific steps are as follows:

[0102] Step S3101, set the vertical expansion threshold Tev = 5, set the first trough span threshold Ts1 = 3, set the first fault tolerance threshold Tt1 = 0.7, and set lh f represents the fth horizontal line segment of the first horizontal line segment set Lh1, f=1, 2, ..., nf, nf is the number of horizontal line segments in the first horizontal line segment set Lh1; sets a first variable d and a second variable e, and the initial value of the first variable d is set to 1;

[0103] Step S3102, obtaining the dth horizontal line segment lh in the first horizontal line segment set Lh1 d The x coordinate of the left endpoint d left , get the dth horizontal line segment lh in the first horizontal line segment set Lh1 d The y coordinate of the left endpoint d left , get the dth horizontal line segment lh in the first horizontal line segment set Lh1 d The x coordinate of the right endpoint d right , get the dth horizontal line segment lh in the first horizontal line segment set Lh1 d The y coordinate of the right endpoint d right , calculate the dth horizontal line segment lh in the first horizontal line segment set Lh1 d The average y coordinate y d , the calculation formula is shown in formula (1):

[0104]

[0105] Step S3103: Set the first rectangular cropping area Ar1, and initialize the coordinates of the upper left end point of the first rectangular cropping area Ar1 to (x d left ,y d -Tev), initialize the coordinates of the lower right end point of the first rectangular cropping area Ar1 to (x d right ,y d +Tev); Binarize the image I b Cropping according to the first rectangular cropping area Ar1 obtains the horizontal line segment binary image I lh (d) ;

[0106] Step S3104: Binarize the horizontal line segment image I lh (d) Perform horizontal projection and obtain the horizontal projection vector HP (d) , let hp (d) h Represents the horizontal projection vector HP (d) The hth element in, where h=1,2,…,hi lh (d) ,hi lh (d) I is the horizontal line segment binary image lh (d) The height, horizontal projection vector HP (d) The hth element hp (d) h Represents the horizontal line segment binary image I lh (d) The number of foreground points in the hth row, where the foreground points are pixels with a pixel value of 255;

[0107] Step S3105, calculate the horizontal projection vector HP (d) The maximum projection value hp (d) max , the calculation formula is shown in formula (2):

[0108]

[0109] Step S3106, let hcr min Indicates the minimum change rate of the current horizontal projection, initializes the minimum change rate of the current horizontal projection hcr min HP (d) max ×Tt1;

[0110] Step S3107, set the upper trough flag tf up and the lower side valley mark tf down , initialize the upper valley flag tfup The value is 0, initializing the lower valley flag tf down The value of is 0; set the horizontal projection trough span hts, and initialize the horizontal projection trough span hts to 0;

[0111] Step S3108, setting the value of the second variable e to 1;

[0112] Step S3109, if hp (d) max -hp (d) e <hcr min , then the value of the horizontal projection trough span hts is set to 0, otherwise, the value of the horizontal projection trough span hts is increased by 1;

[0113] Step S3110: if hts≥Ts1, set the upper valley mark tf up The value of is set to 1, and jump to step S3112;

[0114] Step S3111, increase the value of the second variable e by 1, if e≤Tev, jump to step S3109;

[0115] Step S3112, setting the value of the horizontal projection trough span hts to 0, and setting the value of the second variable e to Tev+1;

[0116] Step S3113, if hp (d) max -hp (d) e <hcr min , then the value of the horizontal projection trough span hts is set to 0, otherwise, the value of the horizontal projection trough span hts is increased by 1;

[0117] Step S3114: if hts≥Ts1, set the lower valley mark tf down The value of is set to 1, and jump to step S3116;

[0118] Step S3115, increase the value of the second variable e by 1, if e≤hi lh (d) , then jump to step S3113;

[0119] Step S3116, if tf up =1, tf down = 1, then the dth horizontal line segment lh in the first horizontal line segment set Lh1 is d Add the second horizontal line segment set Lh2;

[0120] Step S3117, increase the value of the first variable d by 1, if d≤nf, jump to step S3102.

[0121] Furthermore, in step S3, the interfering vertical line segments in the first vertical line segment set Lv1 are removed to obtain the second vertical line segment set Lv2. The specific steps are as follows:

[0122] Step S3201, set the horizontal expansion threshold Teh = 5, set the second trough span threshold Ts2 = 3, set the second fault tolerance threshold Tt2 = 0.8, and set lv g represents the g-th vertical line segment of the first vertical line segment set Lv1, g=1, 2, ..., ng, ng is the number of vertical line segments in the first vertical line segment set Lv1; sets a third variable t and a fourth variable v, and the initial value of the third variable t is set to 1;

[0123] Step S3202, obtaining the tth vertical line segment lv in the first vertical line segment set Lv1 t The x coordinate of the upper endpoint x t up , get the tth vertical line segment lv in the first vertical line segment set Lv1 t The y coordinate of the upper endpoint t up , get the tth vertical line segment lv in the first vertical line segment set Lv1 t The x coordinate of the lower endpoint x t down , get the tth vertical line segment lv in the first vertical line segment set Lv1 t The y coordinate of the lower endpoint t down , calculate the tth vertical line segment lv in the first vertical line segment set Lv1 t The average x coordinate x t , the calculation formula is shown in formula (3):

[0124]

[0125] Step S3203, set the second rectangular cropping area Ar2, and initialize the coordinates of the upper left end point of the second rectangular cropping area Ar2 to (x t -Teh,y t up ), initialize the lower right end point coordinate of the second rectangular cropping area Ar2 to (x t -Teh,y t down );The binary image I b Cropping according to the second rectangular cropping area Ar2 obtains the vertical line segment binary image I lv (t) ;

[0126] Step S3204: binarize the vertical line segment image I lv (t) Perform vertical projection to obtain the vertical projection vector VP (t) , let vp (t) w Represents the vertical projection vector VP (t) The wth element in, where w=1,2,…,wi lv (t) , wi lv (t) I is the vertical line segment binary image lv (t) The width of the vertical projection vector VP (t) The wth element vp in (t) w Represents the vertical line segment binary image I lv (t) The number of foreground points in the wth column, where the foreground points are pixels with a pixel value of 255;

[0127] Step S3205, calculate the vertical projection vector VP (t) The maximum projection value vp in (t) max , the calculation formula is shown in formula (4):

[0128]

[0129] Step S3206, let vcr min Indicates the minimum change rate of the current vertical projection, initializes the minimum change rate vcr of the current vertical projection min For vp (t) max ×Tt2;

[0130] Step S3207, set the left trough flag tf left and the right trough mark tf right , initialize the left trough flag tf left The value is 0, initializing the right trough flag tf right The value of is 0; set the vertical projection trough span vts, and initialize the value of the vertical projection trough span vts to 0;

[0131] Step S3208, setting the value of the fourth variable v to 1;

[0132] Step S3209, if vp (t) max -vp (t) v <vcr min, then the value of the vertical projection trough span vts is set to 0, otherwise, the value of the vertical projection trough span vts is increased by 1;

[0133] Step S3210: If vts ≥ Ts2, set the left valley mark tf left The value of is set to 1, and jump to step S3212;

[0134] Step S3211, increase the value of the fourth variable v by 1, if v≤Teh, jump to step S3209;

[0135] Step S3212, setting the value of the vertical projection trough span vts to 0, and setting the value of the fourth variable v to Teh+1;

[0136] Step S3213, if vp (t) max -vp (t) v <vcr min , then the value of the vertical projection trough span vts is set to 0, otherwise, the value of the vertical projection trough span vts is increased by 1;

[0137] Step S3214: if vts ≥ Ts2, set the right valley mark tf right The value of is set to 1, and jump to step S3216;

[0138] Step S3215, increase the value of the fourth variable v by 1, if v≤wi lv (t) , then jump to step S3213;

[0139] Step S3216, if tf left =1, tf right = 1, then the tth vertical line segment lv in the first vertical line segment set Lv1 t Add the second vertical line segment set Lv2;

[0140] Step S3217, increase the value of the third variable t by 1. If t≤ng, jump to step S3202.

[0141] Furthermore, in step S3, adjacent horizontal line segments in the second horizontal line segment set Lh2 are spliced ​​to obtain a third horizontal line segment set Lh3, and the specific steps are as follows:

[0142] Step S3301, sorting all horizontal line segments in the second horizontal line segment set Lh2 in ascending order according to the y coordinates of the left endpoints of the horizontal line segments;

[0143] Step S3302, set the first distance threshold Td1 = 5, set the second distance threshold Td2 = 5, let lhi ' represents the i-th horizontal line segment of the second horizontal line segment set Lh2, i = 1, 2, ..., ni, ni is the number of horizontal line segments in the second horizontal line segment set Lh2; define a horizontal line segment splicing mark set Fh containing n splicing mark variables, the i-th splicing mark variable fh in the horizontal line segment splicing mark set Fh i represents the splicing mark of the i-th horizontal line segment in the second horizontal line segment set, and the splicing mark fh of the i-th horizontal line segment in the second horizontal line segment set i The initial value is set to 0; the fifth variable k and the sixth variable j are set; the initial value of the fifth variable k is set to 0;

[0144] Step S3303: increase the value of the fifth variable k by 1. If k>ni-1, jump to step S3311;

[0145] Step S3304, if fh k =1, jump to step S3303, otherwise, set the value of the sixth variable j to the fifth variable k;

[0146] Step S3305, increase the value of the sixth variable j by 1, if j>ni, jump to step S3303;

[0147] Step S3306, if fh j =1, jump to step S3305;

[0148] Step S3307, if x k right ' <x j left ', where x k right ' represents the x coordinate of the right endpoint of the kth horizontal line segment of the second horizontal line segment set Lh2, x j left ' represents the x coordinate of the left endpoint of the jth horizontal line segment of the second horizontal line segment set Lh2, then the kth horizontal line segment lh of the second horizontal line segment set Lh2 is determined k 'The jth horizontal line segment lh in the second horizontal line segment set j 'Left side; if x j right ' <x k left ', where x j right ' represents the x coordinate of the right endpoint of the jth horizontal line segment of the second horizontal line segment set Lh2, x k left ' represents the x coordinate of the left endpoint of the kth horizontal line segment of the second horizontal line segment set Lh2, then the jth horizontal line segment lh in the second horizontal line segment set is determined j' is to the left of the k-th horizontal line segment lh in the second set of horizontal line segments Lh2 k '

[0149] Step S3308, if the k-th horizontal line segment lh in the second set of horizontal line segments Lh2 k ' is to the left of the j-th horizontal line segment lh in the second set of horizontal line segments, |x j ' - x k right '| < Td1, and |y j left ' - y k right '| < Td1, then connect the left endpoint of the k-th horizontal line segment lh in the second set of horizontal line segments Lh2 j left ' to the right endpoint of the j-th horizontal line segment lh in the second set of horizontal line segments to obtain a horizontal splicing line segment lc k '; Otherwise, if the j-th horizontal line segment lh in the second set of horizontal line segments j ' is to the left of the k-th horizontal line segment lh in the second set of horizontal line segments Lh2 k,j ', |x j ' - x k '| < Td1, and |y j right ' - y k left '| < Td1, then connect the left endpoint of the j-th horizontal line segment lh in the second set of horizontal line segments j right ' to the right endpoint of the k-th horizontal line segment lh in the second set of horizontal line segments Lh2 to obtain a horizontal splicing line segment lc k left '; Otherwise, jump to step S3305; j ' is to the left of the k-th horizontal line segment lh in the second set of horizontal line segments Lh2 k ' to obtain a horizontal splicing line segment lc k,j ; Otherwise, jump to step S3305;

[0150] Step S3309, calculate the vertical distance dh from the left endpoint of the k-th horizontal line segment lh in the second set of horizontal line segments Lh2 k ' to the horizontal splicing line segment lc k,j , the vertical distance dh from the right endpoint of the k-th horizontal line segment lh in the second set of horizontal line segments Lh2 k,1 ' to the horizontal splicing line segment lc k ', the vertical distance dh from the left endpoint of the j-th horizontal line segment lh in the second set of horizontal line segments k,j ' to the horizontal splicing line segment lc k,2 and the vertical distance dh from the left endpoint of the j-th horizontal line segment lh in the second set of horizontal line segments j ' to the horizontal splicing line segment lc k,j and the vertical distance dh from the left endpoint of the j-th horizontal line segment lh in the second set of horizontal line segments j,3 ' to the horizontal splicing line segment lc jThe vertical distance dh from the right endpoint of ’ to the horizontal splicing line segment lc k,j ; j,4 ;

[0151] Step S3310, if dh k,1 <Td2, dh k,2 <Td2, dh j,3 <Td2, dh j,4 <Td2, then set the splicing flag fh of the k-th horizontal line segment in the second set of horizontal line segments k and the splicing flag fh of the j-th horizontal line segment in the second set of horizontal line segments j to 1, and add the horizontal splicing line segment lc k,j to the third set of horizontal line segments Lh3; jump to step S3303;

[0152] Step S3311, traverse each splicing flag in the set Fh of horizontal line segment splicing flags. If the i-th variable fh in the set Fh of horizontal line segment splicing flags i is 0, then add the i-th horizontal line segment lh i ’ in the second set of horizontal line segments Lh2 to the third set of horizontal line segments Lh3.

[0153] Furthermore, in step S3, splice adjacent vertical line segments in the second set of vertical line segments Lv2 to obtain the third set of vertical line segments Lv3. The specific steps are as follows:

[0154] Step S3401, sort each vertical line segment in the second set of vertical line segments Lv2 in ascending order according to the x coordinate of the upper endpoint of the vertical line segment;

[0155] Step S3402, let lv j ’ represent the j-th vertical line segment in the second set of vertical line segments Lv2, j = 1, 2,..., nj, where nj is the number of vertical line segments in the second set of vertical line segments Lv2; define a set Fv of vertical line segment splicing flags containing o splicing flag variables. The j-th splicing flag variable fv j in the set Fv of vertical line segment splicing flags represents the splicing flag of the j-th vertical line segment in the second set of vertical line segments. The splicing flag fv j of the j-th vertical line segment in the second set of vertical line segments is initially set to 0; set the seventh variable u and the eighth variable s; the initial value of the seventh variable u is set to 0;

[0156] Step S3403, increase the value of the seventh variable u by 1. If u > nj - 1, jump to step S3411;

[0157] Step S3404, if fv uIf it is equal to 1, jump to step S3403; otherwise, set the value of the eighth variable s to the seventh variable u;

[0158] Step S3405, increment the value of the eighth variable s by 1. If s > nj, jump to step S3403;

[0159] Step S3406, if fv j is equal to 1, jump to step S3405;

[0160] Step S3407, if y s down ’ < y u up ’, where y s down ’ represents the y - coordinate of the lower endpoint of the s - th vertical line segment in the second vertical line segment set Lv2, and y u up ’ represents the y - coordinate of the upper endpoint of the u - th vertical line segment in the second vertical line segment set Lv2, then determine that the s - th vertical line segment lv s ’ in the second vertical line segment set Lv2 is above the u - th vertical line segment lv u ’; if y u down ’ < y s up ’, where y u down ’ represents the y - coordinate of the lower endpoint of the u - th vertical line segment in the second vertical line segment set Lv2, and y s up ’ represents the y - coordinate of the upper endpoint of the s - th vertical line segment in the second vertical line segment set Lv2, then determine that the u - th vertical line segment lv u ’ in the second vertical line segment set Lv2 is above the s - th vertical line segment lv s ’;

[0161] Step S3408, if the u - th vertical line segment lv u ’ in the second vertical line segment set Lv2 is above the s - th vertical line segment lv s ’, |x u down ’ - x s up ’| < Td1, and |y u down ’ - y s up ’| < Td1, then the u - th vertical line segment lv uThe upper endpoint of ’ is connected to the sth vertical line segment lv in the second set of vertical line segments Lv2 s to obtain the vertical splicing line segment lc u,s ; otherwise, if the sth vertical line segment lv in the second set of vertical line segments Lv2 s ’ is located above the uth vertical line segment lv in the second set of vertical line segments Lv2 u ’ and |x s down ’ - x u up ’| < Td1 and |y s down ’ - y u up ’| < Td1, then connect the upper endpoint of the sth vertical line segment lv in the second set of vertical line segments Lv2 s ’ to the lower endpoint of the uth vertical line segment lv in the second set of vertical line segments Lv2 u ’ to obtain the vertical splicing line segment lc u,s ; otherwise, jump to step S3405;

[0162] Step S3409, calculate the vertical distance dv from the upper endpoint of the uth vertical line segment lv in the second set of vertical line segments Lv2 u ’ to the vertical splicing line segment lc u,s , the vertical distance dv from the lower endpoint of the uth vertical line segment lv in the second set of vertical line segments Lv2 u,1 ’ to the vertical splicing line segment lc u ’, the vertical distance dv from the upper endpoint of the sth vertical line segment lv in the second set of vertical line segments Lv2 u,s ’ to the vertical splicing line segment lc u,2 and the vertical distance dv from the lower endpoint of the sth vertical line segment lv in the second set of vertical line segments Lv2 s ’ to the vertical splicing line segment lc u,s ; s,3 and the vertical distance dv from the lower endpoint of the sth vertical line segment lv in the second set of vertical line segments Lv2 s ’ to the vertical splicing line segment lc u,s ; s,4 ;

[0163] Step S3410, if dv u,1 < Td2, dv u,2 < Td2, dv s,3 < Td2, dv s,4 < Td2, then set the splicing marks fv of the uth vertical line segment in the second set of vertical line segments u and the splicing marks fv of the sth vertical line segment in the second set of vertical line segments s to 1, and add the vertical splicing line segment lc u,s to the third set of vertical line segments Lv3; jump to step S3403;

[0164] Step S3411, traverse each splicing mark in the vertical line segment splicing mark set Fv, if the j-th variable fv in the vertical line segment splicing mark set Fv j is 0, then the jth vertical line segment lv in the second vertical line segment set Lv2 j 'Add the third vertical line segment set Lv3.

[0165] The beneficial effects of the present invention are as follows: the present invention provides a method for detecting dotted lines in document images, which effectively utilizes the dotted line features in the document images to ensure the accurate acquisition of dotted line segments, is suitable for dotted line feature extraction and detection of various document images containing dotted line elements, and can achieve high-precision dotted line detection effects.

[0166] The above description is a preferred embodiment of the present invention and is not intended to limit the present invention. Any equivalent or modification that does not deviate from the spirit disclosed in the present invention should be included in the scope of protection of the present invention.

Claims

1. A document image dotted line detection method, characterized in that: The main steps include: Step S1: document image preprocessing; Read the document image I, grayscale and binarize the document image I, and obtain a binarized image I b ; Step S2; Dashed line feature extraction; For the binary image I b Perform lateral feature enhancement and denoising to obtain the horizontal dashed line segment feature map I h , for the binary image I b Perform longitudinal feature enhancement and denoising to obtain the vertical dashed line segment feature map I v ; Step S3; Line segment detection; horizontal dashed line segment feature map I h Perform horizontal line detection. If a horizontal line segment is detected, store the detected horizontal line segment in the first horizontal line segment set Lh1. v Perform vertical line detection, and if a vertical line segment is detected, store the detected vertical line segment into the first vertical line segment set Lv1; remove the interfering horizontal line segments in the first horizontal line segment set Lh1 to obtain the second horizontal line segment set Lh2, and remove the interfering vertical line segments in the first vertical line segment set Lv1 to obtain the second vertical line segment set Lv2; splice the adjacent horizontal line segments in the second horizontal line segment set Lh2 to obtain the third horizontal line segment set Lh3, and splice the adjacent vertical line segments in the second vertical line segment set Lv2 to obtain the third vertical line segment set Lv3; merge the third horizontal line segment set Lh3 and the third vertical line segment set Lv3 to obtain the dotted line segment set Ld of the document image I.

2. A document image dotted line detection method according to claim 1, characterized in that: In step S2, the binary image I b Perform lateral feature enhancement and denoising to obtain the horizontal dashed line segment feature map I h , the specific steps are as follows: Step S211, set the horizontal expansion threshold Tdh, set the vertical expansion threshold Tdv, set the horizontal morphological opening operation threshold Toh, set the vertical morphological opening operation threshold Tov, let wi b Represents the binary image I b The width of hi b Represents the binary image I b The height of the lateral feature enhancement structure element Ka is generated with a height of 1 and a width of the lateral expansion threshold Tdh and a rectangular shape, and a height of 1 and a width of Toh×wi b And the lateral denoising structure element K with rectangular shape b ; Step S212, using the lateral features to enhance the structural element K a For the binary image I b Perform dilation operation to obtain the horizontal feature enhanced image I c , using the lateral denoising structure element K b Enhance image I for horizontal features c Perform an open operation to obtain the horizontal dashed line segment feature map I h .

3. A document image dotted line detection method according to claim 2, characterized in that: In step S2, the binary image I b Perform longitudinal feature enhancement and denoising to obtain the vertical dashed line segment feature map I v , the specific steps are as follows: Step S221, generating a vertical feature enhancement structure element K with a height equal to the vertical expansion threshold Tdv, a width of 1 and a rectangular shape c , generate a height of Tov×hi b , a longitudinal denoising structural element K with a width of 1 and a rectangular shape d ; Step S222, using the vertical feature to enhance the structural element K c For the binary image I b Perform dilation operation to obtain the longitudinal feature enhanced image I d , using the longitudinal denoising structure element K d Enhance image I for vertical features d Perform an open operation to obtain the vertical dashed line segment feature map I v .

4. A document image dotted line detection method according to claim 3, characterized in that: In step S3, the interfering horizontal line segments in the first horizontal line segment set Lh1 are removed to obtain the second horizontal line segment set Lh2. The specific steps are as follows: Step S3101, set the vertical expansion threshold Tev, set the first trough span threshold Ts1, set the first fault tolerance threshold Tt1, set lh f represents the fth horizontal line segment of the first horizontal line segment set Lh1, f=1, 2, ..., nf, nf is the number of horizontal line segments in the first horizontal line segment set Lh1; sets a first variable d and a second variable e, and the initial value of the first variable d is set to 1; Step S3102, obtaining the dth horizontal line segment lh in the first horizontal line segment set Lh1 d The x coordinate of the left endpoint x d left , get the dth horizontal line segment lh in the first horizontal line segment set Lh1 d The y coordinate of the left endpoint d left , get the dth horizontal line segment lh in the first horizontal line segment set Lh1 d The x coordinate of the right endpoint d right , get the dth horizontal line segment lh in the first horizontal line segment set Lh1 d The y coordinate of the right endpoint d right , calculate the dth horizontal line segment lh in the first horizontal line segment set Lh1 d The average y coordinate y d , the calculation formula is shown in formula (1): Step S3103: Set the first rectangular cropping area Ar1, and initialize the coordinates of the upper left end point of the first rectangular cropping area Ar1 to (x d left ,y d -Tev), initialize the coordinates of the lower right end point of the first rectangular cropping area Ar1 to (x d right ,y d +Tev); Binarize the image I b Cropping according to the first rectangular cropping area Ar1 obtains the horizontal line segment binary image I lh (d) ; Step S3104: Binarize the horizontal line segment image I lh (d) Perform horizontal projection and obtain the horizontal projection vector HP (d) , let hp (d) h Represents the horizontal projection vector HP (d) The hth element in, where h=1,2,…,hi lh (d) ,hi lh (d) I is the horizontal line segment binary image lh (d) The height, horizontal projection vector HP (d) The hth element hp (d) h Represents the horizontal line segment binary image I lh (d) The number of foreground points in the hth row, where the foreground points are pixels with a pixel value of 255; Step S3105, calculate the horizontal projection vector HP (d) The maximum projection value hp (d) max , the calculation formula is shown in formula (2): Step S3106, let hcr min Indicates the minimum change rate of the current horizontal projection, initializes the minimum change rate of the current horizontal projection hcr min HP (d) max ×Tt1; Step S3107, set the upper trough flag tf up and the lower side valley mark tf down , initialize the upper valley flag tf up The value is 0, initializing the lower valley flag tf down The value of is 0; set the horizontal projection trough span hts, and initialize the horizontal projection trough span hts to 0; Step S3108, setting the value of the second variable e to 1; Step S3109, if hp (d) max -hp (d) e <hcr min , then the value of the horizontal projection trough span hts is set to 0, otherwise, the value of the horizontal projection trough span hts is increased by 1; Step S3110: if hts≥Ts1, set the upper valley mark tf up The value of is set to 1, and jump to step S3112; Step S3111, increase the value of the second variable e by 1, if e≤Tev, jump to step S3109; Step S3112, setting the value of the horizontal projection trough span hts to 0, and setting the value of the second variable e to Tev+1; Step S3113, if hp (d) max -hp (d) e <hcr min , then the value of the horizontal projection trough span hts is set to 0, otherwise, the value of the horizontal projection trough span hts is increased by 1; Step S3114: if hts≥Ts1, set the lower valley mark tf down The value of is set to 1, and jump to step S3116; Step S3115, increase the value of the second variable e by 1, if e≤hi lh (d) , then jump to step S3113; Step S3116, if tf up =1, tf down = 1, then the dth horizontal line segment lh in the first horizontal line segment set Lh1 is d Add the second horizontal line segment set Lh2; Step S3117, increase the value of the first variable d by 1, if d≤nf, jump to step S3102.

5. A document image dotted line detection method according to claim 4, characterized in that: In step S3, the interfering vertical line segments in the first vertical line segment set Lv1 are removed to obtain the second vertical line segment set Lv2. The specific steps are as follows: Step S3201, set the horizontal expansion threshold Teh, set the second trough span threshold Ts2, set the second fault tolerance threshold Tt2, set lv g represents the g-th vertical line segment of the first vertical line segment set Lv1, g=1, 2, ..., ng, ng is the number of vertical line segments in the first vertical line segment set Lv1; sets a third variable t and a fourth variable v, and the initial value of the third variable t is set to 1; Step S3202, obtaining the tth vertical line segment lv in the first vertical line segment set Lv1 t The x coordinate of the upper endpoint x t up , get the tth vertical line segment lv in the first vertical line segment set Lv1 t The y coordinate of the upper endpoint y t up , get the tth vertical line segment lv in the first vertical line segment set Lv1 t The x coordinate of the lower endpoint x t down , get the tth vertical line segment lv in the first vertical line segment set Lv1 t The y coordinate of the lower endpoint t down , calculate the tth vertical line segment lv in the first vertical line segment set Lv1 t The average x coordinate x t , the calculation formula is shown in formula (3): Step S3203, set the second rectangular cropping area Ar2, and initialize the coordinates of the upper left end point of the second rectangular cropping area Ar2 to (x t -Teh,y t up ), initialize the lower right end point coordinate of the second rectangular cropping area Ar2 to (x t -Teh,y t down );The binary image I b Cropping according to the second rectangular cropping area Ar2 obtains the vertical line segment binary image I lv (t) ; Step S3204: binarize the vertical line segment image I lv (t) Perform vertical projection to obtain the vertical projection vector VP (t) , let vp (t) w Represents the vertical projection vector VP (t) The wth element in, where w=1,2,…,wi lv (t) , wi lv (t) I is the vertical line segment binary image lv (t) The width of the vertical projection vector VP (t) The wth element vp in (t) w Represents the vertical line segment binary image I lv (t) The number of foreground points in the wth column, where the foreground points are pixels with a pixel value of 255; Step S3205, calculate the vertical projection vector VP (t) The maximum projection value vp in (t) max , the calculation formula is shown in formula (4): Step S3206, let vcr min Indicates the minimum change rate of the current vertical projection, initializes the minimum change rate vcr of the current vertical projection min For vp (t) max ×Tt2; Step S3207, set the left trough flag tf left and the right trough mark tf right , initialize the left trough flag tf left The value is 0, initializing the right trough flag tf right The value of is 0; set the vertical projection trough span vts, and initialize the value of the vertical projection trough span vts to 0; Step S3208, setting the value of the fourth variable v to 1; Step S3209, if vp (t) max -vp (t) v <vcr min , then the value of the vertical projection trough span vts is set to 0, otherwise, the value of the vertical projection trough span vts is increased by 1; Step S3210: If vts ≥ Ts2, set the left valley mark tf left The value of is set to 1, and jump to step S3212; Step S3211, increase the value of the fourth variable v by 1, if v≤Teh, jump to step S3209; Step S3212, setting the value of the vertical projection trough span vts to 0, and setting the value of the fourth variable v to Teh+1; Step S3213, if vp (t) max -vp (t) v <vcr min , then the value of the vertical projection trough span vts is set to 0, otherwise, the value of the vertical projection trough span vts is increased by 1; Step S3214: if vts ≥ Ts2, set the right valley mark tf right The value of is set to 1, and jump to step S3216; Step S3215, increase the value of the fourth variable v by 1, if v≤wi lv (t) , then jump to step S3213; Step S3216, if tf left =1, tf right = 1, then the tth vertical line segment lv in the first vertical line segment set Lv1 t Add the second vertical line segment set Lv2; Step S3217, increase the value of the third variable t by 1. If t≤ng, jump to step S3202.

6. A document image dotted line detection method according to claim 5, characterized in that: In step S3, adjacent horizontal line segments in the second horizontal line segment set Lh2 are spliced ​​to obtain a third horizontal line segment set Lh3. The specific steps are as follows: Step S3301, sorting all horizontal line segments in the second horizontal line segment set Lh2 in ascending order according to the y coordinates of the left endpoints of the horizontal line segments; Step S3302, set the first distance threshold Td1, set the second distance threshold Td2, let lh i ' represents the i-th horizontal line segment of the second horizontal line segment set Lh2, i = 1, 2, ..., ni, ni is the number of horizontal line segments in the second horizontal line segment set Lh2; define a horizontal line segment splicing mark set Fh containing n splicing mark variables, the i-th splicing mark variable fh in the horizontal line segment splicing mark set Fh i represents the splicing mark of the i-th horizontal line segment in the second horizontal line segment set, and the splicing mark fh of the i-th horizontal line segment in the second horizontal line segment set i The initial value is set to 0; Set a fifth variable k and a sixth variable j; the initial value of the fifth variable k is set to 0; Step S3303: increase the value of the fifth variable k by 1. If k>ni-1, jump to step S3311; Step S3304, if fh k =1, jump to step S3303, otherwise, set the value of the sixth variable j to the fifth variable k; Step S3305, increase the value of the sixth variable j by 1, if j>ni, jump to step S3303; Step S3306, if fh j =1, jump to step S3305; Step S3307, if x k right ' <x j left ', where x k right ' represents the x coordinate of the right endpoint of the kth horizontal line segment of the second horizontal line segment set Lh2, x j left ' represents the x coordinate of the left endpoint of the jth horizontal line segment of the second horizontal line segment set Lh2, then the kth horizontal line segment lh of the second horizontal line segment set Lh2 is determined k 'The jth horizontal line segment lh in the second horizontal line segment set j 'Left side; if x j right ' <x k left ', where x j right ' represents the x coordinate of the right endpoint of the jth horizontal line segment of the second horizontal line segment set Lh2, x k left ' represents the x coordinate of the left endpoint of the kth horizontal line segment of the second horizontal line segment set Lh2, then the jth horizontal line segment lh in the second horizontal line segment set is determined j 'The kth horizontal line segment lh in the second horizontal line segment set Lh2 k 'left; Step S3308, if the k-th horizontal line segment lh k ’ in the second set of horizontal line segments Lh2 is to the left of the j-th horizontal line segment lh j ’ in the second set of horizontal line segments, |x k right ’ - x j left ’| < Td1, and |y k right ’ - y j left ’| < Td1, then connect the left endpoint of the k-th horizontal line segment lh k ’ in the second set of horizontal line segments Lh2 to the right endpoint of the j-th horizontal line segment lh j ’ in the second set of horizontal line segments to obtain a horizontal splicing line segment lc k,j ; otherwise, if the j-th horizontal line segment lh j ’ in the second set of horizontal line segments is to the left of the k-th horizontal line segment lh k ’ in the second set of horizontal line segments Lh2, |x j right ’ - x k left ’| < Td1, and |y j right ’ - y k left ’| < Td1, then connect the left endpoint of the j-th horizontal line segment lh j ’ in the second set of horizontal line segments to the right endpoint of the k-th horizontal line segment lh k ’ in the second set of horizontal line segments Lh2 to obtain a horizontal splicing line segment lc k,j ; otherwise, jump to step S3305; Step S3309, calculating the kth horizontal line segment lh of the second horizontal line segment set Lh2 k 'The left end point to the horizontal connection segment lc k,j The vertical distance dh k,1 , the kth horizontal line segment lh of the second horizontal line segment set Lh2 k 'The right end point to the horizontal connection segment lc k,j The vertical distance dh k,2 , the jth horizontal line segment lh in the second horizontal line segment set j 'The left end point to the horizontal connection segment lc k,j The vertical distance dh j,3 and the jth horizontal line segment lh in the second horizontal line segment set j 'The right end point to the horizontal connection segment lc k,j The vertical distance dh j,4 ; Step S3310, if dh k,1 <Td2, dh k,2 <Td2, dh j,3 <Td2, dh j,4 <Td2, then set the splicing flag fh of the k-th horizontal line segment in the second set of horizontal line segments k and the splicing flag fh of the j-th horizontal line segment in the second set of horizontal line segments j to 1, and add the horizontal splicing line segment lc k,j to the third set of horizontal line segments Lh3; jump to step S3303; Step S3311, traverse each splicing mark in the horizontal line segment splicing mark set Fh, if the i-th variable fh in the horizontal line segment splicing mark set Fh i is 0, then the i-th horizontal line segment lh in the second horizontal line segment set Lh2 i 'Add the third horizontal line segment set Lh3.

7. A document image dotted line detection method according to claim 6, characterized in that: In step S3, adjacent vertical line segments in the second vertical line segment set Lv2 are concatenated to obtain a third vertical line segment set Lv3. The specific steps are as follows: Step S3401, sorting each vertical line segment in the second vertical line segment set Lv2 in ascending order according to the x coordinate of the upper endpoint of the vertical line segment; Step S3402, let lv j ' represents the jth vertical line segment of the second vertical line segment set Lv2, j = 1, 2, ..., nj, nj is the number of vertical line segments in the second vertical line segment set Lv2; define a vertical line segment splicing mark set Fv containing o splicing mark variables, the jth splicing mark variable fv in the vertical line segment splicing mark set Fv j represents the splicing mark of the j-th vertical line segment in the second vertical line segment set, and the splicing mark fv of the j-th vertical line segment in the second vertical line segment set j The initial value is set to 0; Set the seventh variable u and the eighth variable s; the initial value of the seventh variable u is set to 0; Step S3403, increase the value of the seventh variable u by 1, if u>nj-1, jump to step S3411; Step S3404, if fv u =1, jump to step S3403, otherwise, set the value of the eighth variable s to the seventh variable u; Step S3405, increase the value of the eighth variable s by 1, if s>nj, jump to step S3403; Step S3406, if fv j =1, jump to step S3405; Step S3407, if y s down ' <y u up ', where y s down ' represents the y coordinate of the lower endpoint of the sth vertical line segment in the second vertical line segment set Lv2, y u up ' represents the y coordinate of the upper endpoint of the uth vertical line segment in the second vertical line segment set Lv2, then the sth vertical line segment lv in the second vertical line segment set Lv2 is determined s 'The uth vertical line segment lv in the second vertical line segment set Lv2 u 'Above; if y u down ' <y s up ', where y u down ' represents the y coordinate of the lower endpoint of the uth vertical line segment in the second vertical line segment set Lv2, y s up ' represents the y coordinate of the upper endpoint of the sth vertical line segment in the second vertical line segment set Lv2, then the uth vertical line segment lv in the second vertical line segment set Lv2 is determined u 'The sth vertical line segment lv in the second vertical line segment set Lv2 s 'Above; Step S3408, if the $u$-th vertical line segment $lv$ in the second set of vertical line segments $Lv2$ u ’ is above the $s$-th vertical line segment $lv$ in the second set of vertical line segments $Lv2$ s ’ and $|x$ u down ’ - $x$ s up ’| < $Td1$, and $|y$ u down ’ - $y$ s up ’| < $Td1$, then connect the upper endpoint of the $u$-th vertical line segment $lv$ in the second set of vertical line segments $Lv2$ u ’ to the lower endpoint of the $s$-th vertical line segment $lv$ in the second set of vertical line segments $Lv2$ s ’ to obtain the vertical splicing line segment $lc$ u,s ; otherwise, if the $s$-th vertical line segment $lv$ in the second set of vertical line segments $Lv2$ s ’ is above the $u$-th vertical line segment $lv$ in the second set of vertical line segments $Lv2$ u ’ and $|x$ s down ’ - $x$ u up ’| < $Td1$ and $|y$ s down ’ - $y$ u up ’| < $Td1$, then connect the upper endpoint of the $s$-th vertical line segment $lv$ in the second set of vertical line segments $Lv2$ s ’ to the lower endpoint of the $u$-th vertical line segment $lv$ in the second set of vertical line segments $Lv2$ u ’ to obtain the vertical splicing line segment $lc$ u,s ; otherwise, jump to step S3405; Step S3409, calculate the uth vertical line segment lv in the second vertical line segment set Lv2 u 'The upper end point to the vertical splicing line segment lc u,s The vertical distance dv u,1 , the uth vertical line segment lv in the second vertical line segment set Lv2 u 'The lower end point to the vertical splicing line segment lc u,s The vertical distance dv u,2 , the sth vertical line segment lv in the second vertical line segment set Lv2 s 'The upper end point to the vertical splicing line segment lc u,s The vertical distance dv s,3 and the sth vertical line segment lv in the second vertical line segment set Lv2 s 'The lower end point to the vertical splicing line segment lc u,s The vertical distance dv s,4 ; Step S3410, if dv u,1 <Td2, dv u,2 <Td2, dv s,3 <Td2, dv s,4 <Td2, then set the splicing flag fv of the u-th vertical line segment in the second set of vertical line segments u and the splicing flag fv of the s-th vertical line segment in the second set of vertical line segments s to 1, and add the vertical splicing line segment lc u,s to the third set of vertical line segments Lv3; jump to step S3403; Step S3411, traverse each splicing mark in the vertical line segment splicing mark set Fv, if the j-th variable fv in the vertical line segment splicing mark set Fv j is 0, then the jth vertical line segment lv in the second vertical line segment set Lv2 j 'Add the third vertical line segment set Lv3.

Citation Information

Patent Citations

  • Lightweight image line segment extraction and description method based on deep learning

    CN115690444A

  • Straight line segment detection method and system based on prediction correction mechanism

    CN117994222A

  • Frame line detection method based on connected domain analysis and morphological operation

    CN110033471A

  • Form recognition method and device in image, electronic equipment and storage medium

    CN111814722A

  • Table interference line removal algorithm

    CN112016557A