Method for detecting original point of rough sketch by scanner

By obtaining and processing the pixel grayscale values ​​of the drawing image in the scanner, the problem of abnormal origin detection caused by dust is solved, and a more accurate origin positioning and scanning effect is achieved.

CN119211429APending Publication Date: 2024-12-27NINGBO DELI KEBEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411204236.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-30
Publication Date
2024-12-27

AI Technical Summary

Technical Problem

When existing scanners detect the origin of the drawing, the origin is abnormal due to dust or other factors, which affects the scanning accuracy.

Method used

By obtaining the grayscale values ​​of each column and row of pixel points in the drawing image, the number of pixel points that meet specific conditions is judged and calculated, and the horizontal and vertical coordinates of the origin are determined, avoiding the influence of dust and improving the accuracy of origin detection.

Benefits of technology

It effectively avoids origin detection errors caused by dust or pixel loss, and improves the scanner's scanning accuracy of drawings.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119211429A_ABST
    Figure CN119211429A_ABST
Patent Text Reader

Abstract

The invention relates to a method for detecting an original point of a rough sketch by a scanner, which comprises the following steps of: scanning the rough sketch by the scanner to obtain a rough sketch image; intercepting an area where an original point is located in the rough sketch image to obtain a to-be-detected image; respectively obtaining the gray value of each column of pixel points and the gray value of each row of pixel points in the to-be-detected image, and judging the gray value of each column of pixel points to obtain the abscissa of each column meeting the condition and the number of continuous pixel points with the gray value of each column smaller than a gray value threshold value; in addition, the gray value of each row of pixel points is judged, each row of ordinates meeting the condition and the number of continuous pixel points with the gray value smaller than the gray value threshold value in each row are obtained, and finally the original point abscissa and the original point ordinate are obtained through calculation. The method has the advantages that the original point can be found, the found original point position is accurate, the situation that the original point cannot be found or the found original point is inaccurate or unqualified due to the fact that dust or pixel missing exists in a rough sketch can be effectively avoided, and then the scanning accuracy of a scanner is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of scanning technology, and in particular to a method for detecting the origin of a drawing by a scanner. Background Art

[0002] A scanner is a device used to convert paper documents, photos or other graphic materials into digital format for computer processing. In the process of detecting the origin of the drawing, the scanner captures the information on the drawing through an optical sensor and converts it into digital signals, which can be recognized and processed by computer software. The original data of the drawing can be accurately obtained through the scanner, including the location of the origin and the details of the image, which is very important for subsequent image processing and analysis.

[0003] Existing scanners use the first point of the drawing as the origin and perform image processing tests in different areas. Due to dust or other factors in the drawing, the origin is abnormal, and the software cannot find the origin, which affects the scanner's scanning of the drawing. Summary of the invention

[0004] The technical problem to be solved by the present invention is to provide a method for detecting the origin of a drawing by a scanner, which can avoid abnormal detection of the origin of the drawing due to dust or other factors, in view of the above-mentioned prior art.

[0005] The technical solution adopted by the present invention to solve the above technical problem is: a method for detecting the origin of a drawing by a scanner, characterized by comprising the following steps:

[0006] Step 1, scanning the drawing with a scanner to obtain a drawing image;

[0007] Step 2, intercept the area where the origin is located in the drawing image to obtain the image to be detected;

[0008] Step 3: Obtain the grayscale value of each column and each row of pixels in the image to be detected, and make the following judgments on each column and each row of pixels in the image to be detected:

[0009] Condition one:

[0010] Determine whether there are N consecutive pixels in the same column of the image to be detected whose grayscale values ​​are all less than the grayscale value threshold M, where N is a positive integer greater than or equal to 2. If so, obtain the number of all columns that meet condition 1, and mark the horizontal coordinate of the p-th column that meets condition 1 as Xp, and the number of consecutive pixels in the p-th column that meets condition 1 whose grayscale value is less than the grayscale value threshold M as a p , p∈{1, ....P}, P is the total number of columns in the image to be detected that meet condition 1;

[0011] Condition 2.

[0012] Determine whether there are N pixels in the same row of the image to be detected whose grayscale values ​​are all less than the grayscale value threshold M. If so, obtain the number of all rows that meet condition 2, and mark the qth row that meets condition 2 as Yq, and the number of consecutive pixels in the qth row that meets condition 2 whose grayscale values ​​are less than the grayscale value threshold M as b q , q∈{1,....Q}, Q is the total number of rows in the image to be detected that meet condition 2;

[0013] Step 4. Obtain the horizontal coordinate X0 of the origin based on the horizontal coordinate of each column that meets condition 1 and the number of consecutive pixels in each column whose grayscale value is less than the grayscale value threshold M; and obtain the vertical coordinate Y0 of the origin based on the vertical coordinate of each row that meets condition 2 and the number of consecutive pixels in each row whose grayscale value is less than the grayscale value threshold M.

[0014] Preferably, the method for obtaining the horizontal coordinate X0 of the origin in step 4 is:

[0015] Step 4-1, set the initial value of i to 1;

[0016] Step 4-2, follow a P 、a P-1 , ...a1 in order to find the same as a i Values ​​of equal magnitude, determine whether there is a value equal to a i If the values ​​are equal, the first value found is recorded as a n , n∈{1, 2, 3...P} and n≠i, and proceed to step 4-3; if not, proceed to step 4-6;

[0017] Step 4-3, determine a i+1 and a n-1 Are the values ​​of are equal? ​​If yes, go to step 4-4; if not, go to step 4-6;

[0018] Step 4-4, determine a i+2 and a n-2 Are the values ​​of are equal? ​​If yes, go to step 4-5; if not, go to step 4-6;

[0019] Step 4-5: Determine whether there are K pairs of consecutive values ​​that are equal, that is: a i with a n Equal, a i+1 with a n-1 Equal, ....a i+K-1 with a n-K+1 are equal, K is a preset positive integer, if yes, then X0=(Xi+Xn) / 2; if not, go to step 4-6;

[0020] Step 4-6: Determine whether the value of i is If it is a floor function, then end; if not, then update the value of i by adding 1 and proceed to step 4-2.

[0021] Preferably, if there is only a segment of N consecutive pixels in all columns whose grayscale values ​​are less than the grayscale value threshold M, the number of consecutive pixels in all columns whose grayscale values ​​are less than the grayscale value threshold M is formed into a first array A in the order of the number of columns, then A=[a1, a2...a P ], the step 4-2 corresponds to selecting a1, a2...a in the first array A in order from front to back. P As the first value to be compared, select a from the first array A in order from back to front. P 、a P-1 , ...a1 is compared with the first value to be compared.

[0022] In order to avoid the influence of dust or pixel loss, if there are R segments of N consecutive pixels in the rth column that meet condition 1, and the grayscale values ​​are all less than the grayscale value threshold M, r∈{1,....P}, R≥2, the number of pixels in the rth column that meet condition 1 and whose grayscale values ​​are less than the grayscale value threshold M is recorded as a r1 、a r2 ...a rR , where a r1 、a r2 ...a rR are the number of pixels in the 1st, 2nd, ... Rth segments distributed from top to bottom in the rth column that meet condition 1, then the first array A = [a1, a2...a r1 、a r2 ...a rR ...a P ].

[0023] Furthermore, the specific method of obtaining the origin ordinate Y0 in step 4 is:

[0024] Step 4-1a, set the initial value of j to 1;

[0025] Step 4-2a, follow b Q , b Q-1 , ...b1 in order to find the same as b j Values ​​of equal magnitude, determine whether there is a value equal to b j If the values ​​are equal, the first value found is recorded as b m , m∈{1, 2, 3...Q} and m≠j, and proceed to step 4-3a; if not, proceed to step 4-6a;

[0026] Step 4-3a, judgment bj+1 and b m-1 Are the values ​​of are equal? ​​If yes, proceed to step 4-4a; if not, proceed to step 4-6a;

[0027] Step 4-4a, judgment b j+2 and b m-2 Are the values ​​of are equal? ​​If yes, proceed to step 4-5a; if not, proceed to step 4-6a;

[0028] Step 4-5a: Determine whether there are K pairs of consecutive values ​​that are equal, that is: b j With b m Equal, b j+1 With b m-1 Equal, ....b j+K-1 With b m-K+1 are equal, K is a preset positive integer, if so, then Y0=(Yj+Ym) / 2; if not, proceed to step 4-6a;

[0029] Step 4-6a: Determine whether the value of j is If yes, then end; if no, then update the j value by adding 1 and proceed to step 4-2a.

[0030] Furthermore, if there is only a segment of N consecutive pixels in all rows whose grayscale values ​​are less than the grayscale value threshold M, the number of consecutive pixels in all rows whose grayscale values ​​are less than the grayscale value threshold M is formed into a second array B in the order of the number of rows, then B = [b1, b2...b Q ], the step 4-2a corresponds to selecting b1, b2...b in the second array B in order from front to back. Q As the second value to be compared, select b from the second array B in order from back to front. Q 、b Q-1 , ...b1 is compared with the second value to be compared.

[0031] Furthermore, if the grayscale values ​​of N consecutive pixels in the sth row that meet condition 2 are all less than the grayscale threshold M, s∈{1,....Q}, T≥2, the number of pixels in the sth row that meet condition 2 whose grayscale values ​​are less than the grayscale threshold M is recorded as b s1 、b s2 ...b sT , where b s1 、b s2 ...b sT are the number of pixels in the 1st, 2nd, ..., Tth segments distributed from left to right in the sth row that meet condition 2, then the second array B = [b1, b2 ... bs1, b s2 ...b sT...b Q ].

[0032] Compared with the prior art, the advantages of the present invention are: by obtaining the grayscale values ​​of each column and each row of pixels in the image to be detected, and by processing the grayscale values ​​of each column and each row of pixels, the origin can be found, and the position of the origin found is accurate, which can effectively avoid the inability to find the origin due to dust or missing pixels in the drawing, or the origin found is inaccurate or unqualified, thereby improving the scanning accuracy of the scanner. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] Figure 1 Schematic diagram of an image to be detected in an embodiment of the present invention. DETAILED DESCRIPTION

[0034] The present invention is further described in detail below with reference to the accompanying drawings.

[0035] The method for detecting the origin of a drawing by a scanner in this embodiment comprises the following steps:

[0036] Step 1, scanning the drawing with a scanner to obtain a drawing image;

[0037] Step 2, intercept the area where the origin is located in the drawing image to obtain the image to be detected;

[0038] In this embodiment, a square frame can be used to include the origin when intercepting, and the periphery of the square frame is as close as possible to the periphery of the origin, which can improve the detection efficiency and reduce errors;

[0039] Step 3: Obtain the grayscale value of each column and each row of pixels in the image to be detected, and make the following judgments on each column and each row of pixels in the image to be detected:

[0040] Condition one:

[0041] Determine whether there are N consecutive pixels in the same column of the image to be detected whose grayscale values ​​are all less than the grayscale value threshold M, where N is a positive integer greater than or equal to 2. If so, obtain the number of all columns that meet condition 1, and mark the horizontal coordinate of the p-th column that meets condition 1 as Xp, and the number of consecutive pixels in the p-th column that meets condition 1 whose grayscale value is less than the grayscale value threshold M as a p , p∈{1, ....P}, P is the total number of columns that meet condition 1 in the image to be detected;

[0042] Condition 2.

[0043] Determine whether there are N pixels in the same row of the image to be detected whose grayscale values ​​are all less than the grayscale value threshold M. If so, obtain the number of all rows that meet condition 2, and mark the qth row that meets condition 2 as Yq, and the number of consecutive pixels in the qth row that meets condition 2 whose grayscale values ​​are less than the grayscale value threshold M as b q , q∈{1,....Q}, Q is the total number of rows in the image to be detected that meet condition 2;

[0044] In this embodiment, the horizontal extension direction of the image to be detected is the X-axis, and the vertical extension direction of the image to be detected is the Y-axis to establish a coordinate system; the X-axis is the row, and the Y-axis is the column;

[0045] In this embodiment, the image to be detected is a color image, so the RGB value of each pixel of the image to be detected is first read, and the gray value of each pixel is calculated according to the formula (Gray=0.299×R+0.587×G+0.114×B, where Gray is the gray value, and R, G and B are the RGB values ​​of each pixel respectively);

[0046] In this embodiment, the values ​​of N and M are obtained based on empirical values ​​or experimental confirmation;

[0047] Step 4, according to the horizontal coordinates of each column that meet condition 1 and the number of consecutive pixels in each column whose grayscale value is less than the grayscale value threshold M, obtain the horizontal coordinate X0 of the origin; and according to the vertical coordinates of each row that meet condition 2 and the number of consecutive pixels in each row whose grayscale value is less than the grayscale value threshold M, obtain the vertical coordinate Y0 of the origin;

[0048] The method of obtaining the horizontal coordinate X0 of the origin is:

[0049] Step 4-1, set the initial value of i to 1;

[0050] Step 4-2, follow a P 、a P-1 , ...a1 in order to find the same as a i Values ​​of equal magnitude, determine whether there is a value equal to a i If the values ​​are equal, the first value found is recorded as a n , n∈{1, 2, 3...P} and n≠i, and proceed to step 4-3; if not, proceed to step 4-6;

[0051] In this embodiment, if there is only a segment of N consecutive pixels in all columns whose grayscale values ​​are less than the grayscale value threshold M, the number of consecutive pixels in all columns whose grayscale values ​​are less than the grayscale value threshold M is formed into a first array A in the order of the number of columns, then A = [a1, a2...a P ], the step 4-2 corresponds to selecting a1, a2...a in the first array A in order from front to back.P As the first value to be compared, select a from the first array A in order from back to front. P 、a P-1 , ...a1 is compared with the first value to be compared;

[0052] If the grayscale values ​​of N consecutive pixels in the rth column that meet condition 1 are all less than the grayscale threshold M, r∈{1,....P}, R≥2, the number of pixels in the rth column that meet condition 1 whose grayscale values ​​are less than the grayscale threshold M is recorded as a r1 、a r2 ...a rR , where a r1 、a r2 ...a rR are the number of pixels in the 1st, 2nd, ... Rth segments distributed from top to bottom in the rth column that meet condition 1, then the first array A = [a1, a2...a r1 、a r2 ...a rR ...a P ];

[0053] Step 4-3, determine a i+1 and a n-1 Are the values ​​of are equal? ​​If yes, go to step 4-4; if not, go to step 4-6;

[0054] Step 4-4, determine a i+2 and a n-2 Are the values ​​of are equal? ​​If yes, go to step 4-5; if not, go to step 4-6;

[0055] Step 4-5: Determine whether there are K pairs of consecutive values ​​that are equal, that is: a i with a n Equal, a i+1 with a n-1 Equal, ....a i+K-1 with a n-K+1 are equal, K is a preset positive integer, if yes, then X0=(Xi+Xn) / 2; if not, go to step 4-6;

[0056] The value of K in this embodiment is obtained based on experience or experimental confirmation;

[0057] Step 4-6: Determine whether the value of i is is a floor function. If yes, then end; if no, then update the value of i by adding 1, and go to step 4-2;

[0058] The end in this embodiment corresponds to the origin not being found, and the user needs to be reminded to check;

[0059] The method for obtaining the origin ordinate Y0 is the same as the method for obtaining the origin abscissa X0. The specific method for obtaining the origin ordinate Y0 is:

[0060] Step 4-1a, set the initial value of j to 1;

[0061] Step 4-2a, follow b Q , b Q-1 , ...b1 in order to find the same as b j Values ​​of equal magnitude, determine whether there is a value equal to b j If the values ​​are equal, the first value found is recorded as b m , m∈{1, 2, 3...Q} and m≠j, and proceed to step 4-3a; if not, proceed to step 4-6a;

[0062] In this embodiment, if there is only a segment of N consecutive pixels in all rows whose grayscale values ​​are less than the grayscale value threshold M, the number of consecutive pixels in all rows whose grayscale values ​​are less than the grayscale value threshold M is formed into a second array B in the order of the number of rows, then B = [b1, b2...b Q ], the step 4-2a corresponds to selecting b1, b2...b in the second array B in order from front to back. Q As the second value to be compared, select b from the second array B in order from back to front. Q , b Q-1 , ...b1 is compared with the second value to be compared;

[0063] If the grayscale values ​​of N consecutive pixels in the sth row that meet condition 2 are all less than the grayscale threshold M, s∈{1,....Q}, T≥2, the number of pixels in the sth row that meet condition 2 whose grayscale values ​​are less than the grayscale threshold M is recorded as b s1 , b s2 ...b sT , where b s1 , b s2 ...b sT are the number of pixels in the 1st, 2nd, ..., Tth segments distributed from left to right in the sth row that satisfy condition 2, then the second array B = [b1, b2, ..., b s1 , b s2 ...b sT ...b Q ];

[0064] Step 4-3a, judgment b j+1 and b m-1Are the values ​​of are equal? ​​If yes, proceed to step 4-4a; if not, proceed to step 4-6a;

[0065] Step 4-4a, judgment b j+2 and b m-2 Are the values ​​of are equal? ​​If yes, proceed to step 4-5a; if not, proceed to step 4-6a;

[0066] Step 4-5a: Determine whether there are K pairs of consecutive values ​​that are equal, that is: b j With b m Equal, b j+1 With b m-1 Equal, ....b j+K-1 With b m-K+1 are equal, K is a preset positive integer, if so, then Y0=(Yj+Ym) / 2; if not, proceed to step 4-6a;

[0067] Step 4-6a: Determine whether the value of j is If yes, then end; if no, then update the j value by adding 1 and proceed to step 4-2a.

[0068] To facilitate understanding of the method of the present invention, in this embodiment, dust is taken as an example in a certain place in the drawing. According to the method of the present invention, a first array A=[2, 6, 2, 5, 10, 12, 14, 16, 18, 18, 16, 14, 10, 6, 2] is obtained, wherein the first array A includes the number of pixels in the 1st column, the 2nd column, the 1st section of the 3rd column, the 2nd section of the 3rd column, the 4th column, the 5th column, the 6th column, ..... the 14th column that meet condition 1 in order. For the convenience of recording, as Figure 1 As shown, Figure 1 The horizontal coordinate of each column and the number of pixels in the corresponding column that meet condition 1 are recorded as X1-2, X2-6, X3-2, X3-5, X4-10, X5-12, X6-14, X7-16, X8-18, X9-18, X10-16, X11-14, X12-10, X13-6, and X14-2 respectively;

[0069] When obtaining the horizontal coordinate X0 of the origin, the specific process is:

[0070] 1. Start from X14 and look for a value that is equal to the number of pixels in X1, such as Figure 1 As shown, the number of pixels of X14 and X1 is 2;

[0071] 2. Continue to compare the number of pixels of X13 and X2. The number of pixels of X13 and X2 is 6, which is also equal.

[0072] 3. Continue to compare the number of pixels of X12 and X3. The number of pixels of X3 is 2 and 5, which is not equal to the number of pixels of X12, which is 10.

[0073] 4. Search from X14 forward to find the value with the same number of pixels as X2, and find that the number of pixels of X13 is equal to that of X2;

[0074] 5. Then the comparison continues to compare the pixel counts of X12 and X3. The pixel counts of X3 are 2 and 5, which are not equal to the pixel count of X12, which is 10.

[0075] 6. Search from X14 forward for a value that is equal to the number of pixels in X3, and so on;

[0076] 7. Finally, we find that the number of pixels of X11 and X6 is equal, the number of pixels of X10 and X7 is equal, and the number of pixels of X9 and X8 is equal, that is, there are K = 3 pairs of consecutive values ​​that are equal, then calculate the horizontal coordinate of the origin X0 = (X6 + X11) / 2;

[0077] The same method can be used to calculate the origin's ordinate Y0.

[0078] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the technical principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A method for detecting the origin of a drawing by a scanner, characterized in that The steps include: Step 1, scanning the drawing with a scanner to obtain a drawing image; Step 2, intercept the area where the origin is located in the drawing image to obtain the image to be detected; Step 3: Obtain the grayscale value of each column and each row of pixels in the image to be detected, and make the following judgments on each column and each row of pixels in the image to be detected: Condition one: Determine whether there are N consecutive pixels in the same column of the image to be detected whose grayscale values ​​are all less than the grayscale value threshold M, where N is a positive integer greater than or equal to 2. If so, obtain the number of all columns that meet condition 1, and mark the horizontal coordinate of the p-th column that meets condition 1 as Xp, and the number of consecutive pixels in the p-th column that meets condition 1 whose grayscale value is less than the grayscale value threshold M as a p , p∈{1, ....P}, P is the total number of columns in the image to be detected that meet condition 1; Condition 2. Determine whether there are N pixels in the same row of the image to be detected whose grayscale values ​​are all less than the grayscale value threshold M. If so, obtain the number of all rows that meet condition 2, and mark the qth row that meets condition 2 as Yq, and the number of consecutive pixels in the qth row that meets condition 2 whose grayscale values ​​are less than the grayscale value threshold M as b q , q∈{1,....Q}, Q is the total number of rows in the image to be detected that meet condition 2; Step 4. Obtain the horizontal coordinate X0 of the origin based on the horizontal coordinate of each column that meets condition 1 and the number of consecutive pixels in each column whose grayscale value is less than the grayscale value threshold M; and obtain the vertical coordinate Y0 of the origin based on the vertical coordinate of each row that meets condition 2 and the number of consecutive pixels in each row whose grayscale value is less than the grayscale value threshold M.

2. The method according to claim 1, characterized in that: The method for obtaining the horizontal coordinate X0 of the origin in step 4 is: Step 4-1, set the initial value of i to 1; Step 4-2, follow a P 、a P-1 , ...a1 in order to find the same i Values ​​of equal magnitude, determine whether there is a value equal to a i If the values ​​are equal, the first value found is recorded as a n , n∈{1, 2, 3…P) and n≠i, and proceed to step 4-3; if not, proceed to step 4-6; Step 4-3, determine a i+1 and a n-1 Are the values ​​of are equal? ​​If yes, go to step 4-4; if not, go to step 4-6; Step 4_4, determine a i+2 and a n-2 Are the values ​​of are equal? ​​If yes, go to step 4-5; if not, go to step 4-6; Step 4-5: Determine whether there are K pairs of consecutive values ​​that are equal, that is: a i with a n Equal, a i+1 with a n-1 Equal, ....a i+K-1 with a n-K+1 are equal, K is a preset positive integer, if yes, then X0=(Xi+Xn) / 2; if not, go to step 4-6; Step 4-6: Determine whether the value of i is If it is a floor function, then end; if not, then update the value of i by adding 1 and proceed to step 4-2.

3. The method according to claim 2, characterized in that: If there is only a segment of N consecutive pixels in all columns whose grayscale values ​​are less than the grayscale threshold M, then the number of consecutive pixels in all columns whose grayscale values ​​are less than the grayscale threshold M is formed into a first array A in the order of the number of columns, then A=[a1, a2…a P ], the step 4-2 corresponds to selecting a1, a2...a in the first array A in order from front to back. P As the first value to be compared, select a from the first array A in order from back to front. P 、a P-1 , …a1 is compared with the first value to be compared.

4. The method according to claim 3, characterized in that: If the grayscale values ​​of N consecutive pixels in the rth column that meet condition 1 are all less than the grayscale threshold M, r∈{1,…P}, R≥2, the number of pixels in the rth column that meet condition 1 whose grayscale values ​​are less than the grayscale threshold M is recorded as a r1 、a r2 ...a rR , where a r1 、a r2 ...a rR are the number of pixels in the 1st, 2nd, ... Rth segments distributed from top to bottom in the rth column that meet condition 1, then the first array A = [a1, a2 ... a r1 、a r2 …a rR …a P ].

5. The method according to any one of claims 1 to 4, characterized in that: The specific method of obtaining the origin ordinate Y0 in step 4 is: Step 4-1a, set the initial value of j to 1; Step 4-2a, follow b Q , b Q-1 , ...b1 in order to find the same j Values ​​of equal magnitude, determine whether there is a value equal to b j If the values ​​are equal, the first value found is recorded as b m , m∈{1, 2, 3…Q} and m≠j, and proceed to step 4-3a; if not, proceed to step 4-6a; Step 4-3a, judgment b j+1 and b m-1 Are the values ​​of are equal? ​​If yes, proceed to step 4-4a; if not, proceed to step 4-6a; Step 4-4a, judgment b j+2 and b m-2 Are the values ​​of are equal? ​​If yes, proceed to step 4-5a; if not, proceed to step 4-6a; Step 4-5a: Determine whether there are K pairs of consecutive values ​​that are equal, that is: b j With b m Equal, b j+1 With b m-1 Equal, ....b j+K-1 With b m-K+1 are equal, K is a preset positive integer, if so, then Y0=(Yj+Ym) / 2; if not, proceed to step 4-6a; Step 4-6a: Determine whether the value of j is If yes, then end; if no, then update the j value by adding 1 and proceed to step 4-2a.

6. The method according to claim 5, characterized in that: If there is only a segment of N consecutive pixels in all rows whose grayscale values ​​are less than the grayscale value threshold M, then the number of consecutive pixels in all rows whose grayscale values ​​are less than the grayscale value threshold M is formed into a second array B in the order of the number of rows, then B = [b1, b2…b Q ], the step 4-2a corresponds to selecting b1, b2...b in the second array B in order from front to back. Q As the second value to be compared, select b from the second array B in order from back to front. Q , b Q-1 , …b1 is compared with the second value to be compared.

7. The method according to claim 6, characterized in that: If the grayscale values ​​of N consecutive pixels in the sth row that meet condition 2 are all less than the grayscale threshold M, s∈{1,....Q}, T≥2, the number of pixels in the sth row that meet condition 2 whose grayscale values ​​are less than the grayscale threshold M is recorded as b s1 , b s2 …b sT , where b s1 , b s2 …b sT are the number of pixels in the 1st, 2nd, ..., Tth segments distributed from left to right in the sth row that meet condition 2, then the second array B = [b1, b2 ... b s1 , b s2 …b sT …b Q ].