Image processing method for tubular level bubble angle value measurement

By using image processing technology to perform binarization, reticle search, tilt correction and endpoint search on the tubular level bubble, the automatic measurement of the axial movement distance of the tubular level bubble is realized, solving the problems of measurement errors and low efficiency in the existing technology. problem, improving measurement accuracy and efficiency.

CN119359810AActive Publication Date: 2025-01-24CHINA JILIANG UNIV
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202411463434.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-21
Publication Date
2025-01-24
Estimated Expiration
2044-10-21

AI Technical Summary

Technical Problem

In the prior art, there are fewer automatic measurement methods for the moving distance of tubular level bubbles in the axial direction, and most of them rely on manual measurement, which has problems of measurement error and low efficiency.

Method used

Image processing technology is used to calculate the distance the bubble moves along the axial direction by performing binarization processing, reticle search, tilt correction and endpoint search on the original image of the tubular level bubble to achieve automated measurement.

Benefits of technology

The measurement accuracy and efficiency of the bubble along the axis movement along the axial direction is improved, the errors caused by artificial intervention are avoided, and the non -contact automatic measurement is achieved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119359810A_ABST
    Figure CN119359810A_ABST
Patent Text Reader

Abstract

The invention discloses an image processing method for tubular level bubble angle value measurement. The method comprises the following steps: firstly, carrying out binarization processing on an acquired level bubble image; secondly, carrying out first-time scribed line search, and carrying out tilt correction on the image according to a direction angle of a scribed line; carrying out second-time scribed line search again, determining a bubble left end point search area, and obtaining a bubble left end point; calculating the physical distance from the left end point of the bubble to the main axis of the left scribed line; and finally, calculating the absolute value of the physical distance difference between the left end point of the bubble in the two images before and after bubble movement in the level bubble and the main axis of the left scribed line to obtain the axial movement distance of the bubble. According to the invention, the automatic measurement of the bubble axial movement distance necessary in the tubular level bubble angle value measurement process is better realized, the problems of time and labor waste, large measurement error and the like caused by manual intervention are completely eliminated, and the accuracy of the measurement result and the measurement efficiency can be effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of image processing, and in particular to an image processing method for calculating the amount of movement of a tubular vial along an axis. Background Art

[0002] A spirit level is a measuring instrument that uses the principle of liquid level to directly display angular displacement with a spirit level bubble, and measures the deviation of the measured surface relative to the horizontal position, plumb position, and tilt position. The measurement accuracy of its angle value directly affects the measurement effect of the spirit level. According to the national standard GB / T1146-2009, the definition of the angle value of a tubular spirit level bubble is "the inclination angle of the spirit level bubble when the bubble moves 2mm along the axis." If you want to obtain this inclination angle, you need to accurately obtain the distance the bubble moves along the axial direction.

[0003] At present, there are few methods for automatically measuring the axial movement distance of the bubble in the level bubble at home and abroad. Most of them are still carried out by manual methods, and a few use image processing technology, but there are still disadvantages. For example, Shan Xiaohang measured the bubble offset in "A Level Ruler Bubble Offset Detection System Based on Image Processing", using the edge recognition method, but the disadvantage is that the influence of the inclination of the level bubble on the measurement result is not considered. Therefore, it is necessary to propose a novel image processing method for measuring the axial movement of the bubble of the tubular level bubble to improve the measurement accuracy and efficiency of the axial movement distance of the bubble. Summary of the invention

[0004] In view of the deficiencies in the background technology, the purpose of the present invention is to provide an image processing method for measuring the axial movement distance of a tubular vial bubble, which can achieve tilt correction of the vial while avoiding human intervention, thereby improving measurement accuracy and efficiency.

[0005] In order to achieve the above object, the present invention adopts the following technical scheme:

[0006] An image processing method for measuring the angle value of a tubular level bubble is implemented in the following steps:

[0007] Step S1: Binarize the original image of the tubular level bubble to obtain a binary image bw;

[0008] Step S2: performing a first scale line search in the binary image bw to obtain two scale lines of the tubular vial;

[0009] Step S3: performing tilt correction on the binary image bw according to the direction angles of the two scribed lines to obtain a tilt-corrected binary image rtBw;

[0010] Step S4: performing a second engraved line search in the binary image rtBw to obtain two centroids and two minimum circumscribed regular rectangles of the left engraved line and the right engraved line respectively;

[0011] Step S5: determining the bubble left endpoint search area according to the two minimum circumscribed regular rectangles of the left and right engraved lines, and searching to obtain the bubble left endpoint;

[0012] Step S6: Calculate the image distance from the left end point of the bubble to the main axis of the left engraved line, and then use the pixel equivalent to further calculate the physical distance from the left end point of the bubble to the main axis of the left engraved line;

[0013] Step S7: Collect the image of the vial bubble when the bubble is at the initial position and the image of the vial bubble when the bubble is moved, and calculate the distance the bubble moves along the axial direction.

[0014] The steps of obtaining the two engraved lines of the tubular vial in step S2 specifically include the following steps:

[0015] Step S21: searching for a zero run in the binary image bw by using the run length encoding concept, and retaining a zero run whose length meets the set condition; the zero run is a pixel set in which the grayscale values ​​of consecutive pixels in a row of pixels in the binary image bw are all 0;

[0016] Step S22: construct a 0-stroke image with the same size as the binary image bw and a black background, and set the grayscale values ​​of all pixels of the 0-stroke that meet the conditions to 255;

[0017] Step S23: perform contour search in the 0-stroke image, calculate the area and direction angle of the area corresponding to each contour, and determine the contour whose direction angle meets the set conditions as the candidate scribed line contour; the specific process of calculating the direction angle of the area corresponding to the contour is: suppose contour C i The pixel in the corresponding area is p 1 (x 1 ,y 1 ),p 2 (x 2 ,y 2 ),…,p m (x m ,y m ), m is the number of pixels, then the contour C i The centroid coordinates (x c ,y c ) can be calculated by the following two formulas:

[0018] x c =(x 1 +x 2 +…+x m ) / m

[0019] yc =(y 1 +y 2 +…+y m ) / m

[0020] Then a, b and c are calculated using the following three formulas:

[0021] a=(x 1 x 1 +x 2 x 2 +…+x m x m ) / mx c x c

[0022] b=2[(x 1 y 1 +x 2 y 2 +…+x m y m ) / mx c y c ]

[0023] c=(y 1 y 1 +y 2 y 2 +…+y m y m ) / my c y c

[0024] Finally, the contour C is calculated by a, b and c i The direction angle θ of the corresponding area is: θ = arctan[b / (ac)] / 2, and its range is (-90°, 90°];

[0025] Step S24: arranging the candidate scribe line contours in descending order according to the areas of the regions corresponding to the candidate scribe line contours;

[0026] Step S25: The two contours arranged in the front are used as the marking contours to obtain two marking lines of the tubular vial.

[0027] In step S3, the specific steps of performing tilt correction on the binary image bw are:

[0028] Step S31: Calculate the left engraved line direction angle θ L and the right engraved line direction angle θ R The mean value θ mean =(θ L +θ R ) / 2;

[0029] Step S32: Calculate the correction angle α:

[0030]

[0031] Step S33: construct the correction matrix M:

[0032] Where (x img ,y img ) is the center coordinate of the binary image bw;

[0033] Step S34: Use the correction matrix M to transform the pixel coordinates in the binary image bw:

[0034] Where (x, y) is the pixel coordinate in the binary image bw; (x', y') is the pixel coordinate in the corrected image rtBw0, and the corresponding pixel values ​​remain unchanged before and after the coordinate transformation;

[0035] Step S35: Use the mean interpolation method to normalize the pixels in the corrected image rtBw0 to integer coordinates, taking (x img ,y img ) is the center and the area with the same size as the binary image bw, and the final corrected image rtBw is obtained, where (x img ,y img ) is the center of the binary image bw.

[0036] The specific method for searching for the left endpoint of the bubble in step S5 is: within the bubble left endpoint search area in the tilt-corrected binary image rtBw, the first pixel with a pixel value of 0 is searched in order from bottom to top and from left to right, and the location of the pixel is the left endpoint of the bubble.

[0037] In step S6, the main axis of the left scale line is a straight line passing through the centroid of the left scale line and in a vertical state; the calculation method of the pixel equivalent is: using the physical spacing between the left and right scale lines, divided by the absolute value of the difference between the horizontal coordinates of the centroids of the left and right scale lines obtained in step S4, to obtain the pixel equivalent, the unit is mm / px.

[0038] The specific method of step S7 for calculating the distance the bubble moves along the axial direction is as follows: by collecting the image of the level bubble when the bubble is at the initial position and the image of the level bubble after the bubble moves, the two collected level bubble images are processed respectively using steps 1 to 6 to obtain the physical distance from the left end points of the two bubbles to the main axis of the left scale line, and the absolute value of their difference is the distance the bubble moves along the axial direction.

[0039] Compared with the background technology, the gain effect of the present invention is:

[0040] 1. The present invention utilizes image processing technology to realize non-contact automatic measurement of the axial distance from the left end point of the tubular level bubble to the scale line. Compared with manual measurement, it can effectively avoid large measurement errors caused by human factors.

[0041] 2. The present invention performs a tilt correction on the level bubble image according to the direction angle of the scale line. Compared with directly measuring the level bubble image, this method can eliminate the measurement error caused by the tilt of the level bubble, solve the drawbacks of other image processing methods, and make the result more accurate.

[0042] 3. The present invention obtains the endpoint of the level bubble by first obtaining the centroid and circumscribed rectangle of the left and right scale lines. Compared with searching the entire image, this method can more accurately determine the axial distance from the left endpoint of the bubble to the main axis of the left scale line, laying the foundation for obtaining more accurate angle values.

[0043] 4. Compared with other image processing methods, the method of the present invention completely eliminates the time-consuming, labor-intensive and poor reliability problems caused by manual intervention. By applying this method to machine vision, the machine can automatically measure the level bubble angle value instead of humans, greatly improving the measurement efficiency and reducing the labor costs of related enterprises. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] Figure 1 It is an image processing flow chart;

[0045] Figure 2 is the original image of the tubular level bubble;

[0046] Figure 3 is the binary image of tubular level bubble;

[0047] Figure 4 It is the zero-stroke result image whose length meets the set conditions;

[0048] Figure 5 is a schematic diagram of candidate scribed line detection results;

[0049] Figure 6 This is a schematic diagram of the two engraved lines obtained in the first search;

[0050] Figure 7 is the binary image after tilt correction;

[0051] Figure 8 It is the left and right engraved lines obtained by the second search;

[0052] Fig. 9 It is a schematic diagram of the search area at the left endpoint of the bubble;

[0053] Fig.10 It is the marking result of the left scale line main axis and the left end point of the bubble. DETAILED DESCRIPTION

[0054] The present invention is further described below in conjunction with the accompanying drawings and specific implementation methods (examples), but they are not intended to limit the present invention.

[0055] like Figure 1 As shown, the steps of the method of the present invention are:

[0056] Step 1: Binarize the original image of the tubular level bubble

[0057] Read the original image of the tubular vial, and the original image of the tubular vial is as follows: Figure 2 The original image of the tubular vial is binarized using a fixed segmentation threshold, and the resulting tubular vial binary image bw is as follows: Figure 3 As shown, white is the background, and the fixed segmentation threshold used is determined according to experiments. In this embodiment, the segmentation threshold is set to 150.

[0058] Step 2: Perform the first line search to obtain two lines

[0059] The idea of ​​run length encoding is used to search for 0 runs consisting of pixels with continuous grayscale values ​​of 0 in the binary image bw, and the 0 runs whose lengths are within a certain interval are retained. In this embodiment, the length interval range is [16,30], and the length unit is px. The interval is determined experimentally according to actual needs. Then, a 0-run image with the same size as the binary image bw and a black background is constructed, and the grayscale values ​​of all pixels in the 0-run that meet the length requirements are set to 255, as shown in FIG. Figure 4 shown.

[0060] Contour search is performed in the 0-stroke image, and the area and direction angle of the area corresponding to each contour are calculated. The contour whose direction angle meets the set conditions is determined as the candidate scaled line contour; the candidate scaled line contours are arranged in descending order according to the area of ​​the area corresponding to the candidate scaled line contour; the two contours arranged in the front are used as the scaled line contours, and two scaled lines of the tubular vial are obtained. The candidate scaled line detection results are shown as follows: Figure 5 shown.

[0061] The specific process of calculating the direction angle of the area corresponding to the contour is: let the contour C i The pixel in the corresponding area is p 1 (x 1 ,y 1 ),p 2 (x 2 ,y 2 ),…,p m (x m ,y m ), m is the number of pixels, then the contour C i The centroid coordinates (x c ,y c) can be calculated by formula (1) and formula (2):

[0062] x c =(x 1 +x 2 +…+x m ) / m (1)

[0063] y c =(y 1 +y 2 +…+y m ) / m (2)

[0064] Then a, b and c are calculated by equations (3), (4) and (5):

[0065] a=(x 1 x 1 +x 2 x 2 +…+x m x m ) / mx c x c (3)

[0066] b = 2[(x 1 y 1 +x 2 y 2 +…+x m y m ) / mx c y c ] (4)

[0067] c = (y 1 y 1 +y 2 y 2 +…+y m y m ) / my c y c (5)

[0068] Finally, the contour C is calculated by a, b and c i The direction angle θ of the corresponding area is:

[0069] θ = arctan[b / (ac)] / 2,

[0070] Its range is (-90°,90°].

[0071] In this embodiment, the conditions for determining the direction angle of the candidate scribed line profile are: 45°<θ≤90° and -90°<θ<-45°.

[0072] Step 3: Perform tilt correction on the binary image based on the direction angles of the two engraved lines

[0073] First, calculate the left engraved line direction angle θ by formula (6): L and the right engraved line direction angle θ R The mean value θ mean :

[0074] θ mean = (θ L + θ R ) / 2 (6)

[0075] Secondly, the correction angle α is calculated by formula (7):

[0076]

[0077] Then the correction matrix M is constructed by formula (8):

[0078]

[0079] Where (x img ,y img ) is the center coordinate of the binary image bw. The pixel coordinates in the binary image bw are transformed using the correction matrix M through equation (9):

[0080]

[0081] Where (x, y) is the pixel coordinate in the binary image bw; (x', y') is the pixel coordinate in the corrected image rtBw0, and the corresponding pixel values ​​remain unchanged before and after the coordinate transformation.

[0082] Finally, the pixels in the corrected image rtBw0 are normalized to integer coordinates using the mean interpolation method, and the coordinates are taken as (x img ,y img ) is the center and the area with the same size as the binary image bw, and the final corrected image rtBw is obtained, where (x img ,y img ) is the center of the binary image bw. The final corrected image rtBw is as follows Figure 7 shown.

[0083] Step 4: Perform a second line search to obtain the centroid and circumscribed rectangle of the left and right lines

[0084] A second line search is performed in the corrected image rtBw to obtain the two centroids of the left and right lines and the minimum circumscribed rectangles of the two lines. The centroids of the left and right lines and the circumscribed rectangles obtained by the second search are as follows: Figure 8 As shown, the centroid of the engraved line is represented by “×”.

[0085] Step 5: Determine the search area for the left endpoint of the bubble and obtain the left endpoint of the bubble

[0086] Get the upper right corner point P1 and lower right corner point P2 of the left engraved line minimum circumscribed rectangle obtained in step 4 and the upper left corner point P3 and lower left corner point P4 of the right engraved line minimum circumscribed rectangle, then construct the minimum circumscribed rectangle bRect of the four corner points P1, P2, P3 and P4, then get the upper half of the minimum circumscribed rectangle bRect, and move its upper side downward by a set distance. In this embodiment, this distance is set to 6 pixels. The obtained rectangular area is the bubble left endpoint search area bubRect. The schematic diagram of the bubble left endpoint search area is as follows: Fig. 9 shown.

[0087] In the bubble left endpoint search area bubRect in the corrected image rtBw, the first pixel with a gray value of 0 is searched from bottom to top and from left to right. The location of this pixel is the bubble left endpoint. The bubble left endpoint marking result is as follows: Fig.10 Indicated by the circle with an × mark in the middle.

[0088] Step 6: Determine the physical distance from the left endpoint of the bubble to the main axis of the left scale line

[0089] Calculate the image distance d from the left end point of the bubble to the main axis of the left scale line img (unit: mm / px), and then use the pixel equivalent v px (Unit: mm / px) The physical distance d from the left end point of the bubble to the main axis of the left scale line is calculated by formula (10): real (Unit: mm):

[0090] d real = d img ×v px (10)

[0091] The pixel equivalent v px Calculated by formula (11):

[0092] v px = d Lreal / d Limg (11)

[0093] where d Lreal is the physical distance between the left and right lines of the vial (unit: mm), d Limg is the absolute value of the difference between the abscissa of the centroid of the left scale line and the right scale line obtained in step 4 (unit: px).

[0094] The main axis of the left engraved line is a straight line passing through the centroid of the left engraved line and in a vertical state, such as Fig.10 As shown by the middle vertical line on the center left engraved line.

[0095] In this embodiment, the pixel equivalent v px = 0.028mm / px, the measured physical distance d from the left end point of the bubble to the main axis of the left scale line real =2.575mm.

[0096] Step 7: Calculate the axial movement distance of the level bubble

[0097] By collecting the image of the level bubble when the bubble is at its initial position and the image of the level bubble when the bubble is moved, the two collected level bubble images are processed respectively using steps 1 to 6 to obtain the physical distances from the left end points of the two bubbles to the main axis of the left scale line. The absolute value of their difference is the distance the bubble moves along the axial direction.

[0098] The above is only a preferred specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.

Claims

1. An image processing method for measuring the angle value of a tubular level bubble, characterized in that: The following steps are involved: Step S1: Binarize the original image of the tubular level bubble to obtain a binary image bw; Step S2: performing a first scale line search in the binary image bw to obtain two scale lines of the tubular vial; Step S3: performing tilt correction on the binary image bw according to the direction angles of the two scribed lines to obtain a tilt-corrected binary image rtBw; Step S4: performing a second engraved line search in the binary image rtBw to obtain two centroids and two minimum circumscribed regular rectangles of the left engraved line and the right engraved line respectively; Step S5: determining the bubble left endpoint search area according to the two minimum circumscribed regular rectangles of the left and right engraved lines, and searching to obtain the bubble left endpoint; Step S6: Calculate the image distance from the left end point of the bubble to the main axis of the left engraved line, and then use the pixel equivalent to further calculate the physical distance from the left end point of the bubble to the main axis of the left engraved line; Step S7: collecting the image of the vial bubble at the initial position of the bubble and the image of the vial bubble at the position after the bubble moves, and calculating the distance the bubble moves along the axial direction; In step S2, the specific steps of obtaining two engraved lines of the tubular vial include: Step S21: Searching for 0 runs in the binary image bw using the run length coding concept, and retaining 0 runs whose lengths meet the set conditions; Step S22: construct a 0-stroke image with the same size as the binary image bw and a black background, and set the grayscale values ​​of all pixels of the 0-stroke that meet the conditions to 255; Step S23: searching for contours in the 0-stroke image, calculating the area and direction angle of the region corresponding to each contour, and determining the contour whose direction angle meets the set conditions as the candidate scribed line contour; Step S24: arranging the candidate scribe line contours in descending order according to the areas of the regions corresponding to the candidate scribe line contours; Step S25: using the two contours arranged in the front as the marking contours to obtain two marking lines of the tubular vial; In step S5, the specific steps of determining the bubble left endpoint search area include: Step S51: Obtain the upper right corner point P1 and the lower right corner point P2 of the minimum circumscribed regular rectangle of the left engraved line obtained in step S4, and the upper left corner point P3 and the lower left corner point P4 of the minimum circumscribed regular rectangle of the right engraved line; Step S52: construct the minimum circumscribed regular rectangle bRect of the four corner points P1, P2, P3 and P4; Step S53: Get the upper half of the minimum circumscribed regular rectangle bRect, and move its upper side downward by a set distance. The obtained rectangular area is the bubble left endpoint search area.

2. The image processing method for measuring the angle value of a tubular level bubble according to claim 1, characterized in that: In the step S21, the zero-run is a set of pixels in which the grayscale values ​​of consecutive pixels in a row of pixels in the binary image bw are all 0.

3. The image processing method for measuring the angle of a tubular level bubble according to claim 1, characterized in that: In step S23, the specific process of calculating the direction angle of the area corresponding to the contour is as follows: Assume that the contour C i The pixels in the corresponding area are p1(x1,y1),p2(x2,y2),…,p m (x m ,y m ), m is the number of pixels, then the contour C i The centroid coordinates of the corresponding area (x c ,y c ) can be calculated by the following two formulas: x c =(x1+x2+…+x m ) / m yes c =(y1+y2+…+y m ) / m Then a, b and c are calculated using the following three formulas: a=(x1x1+x2x2+…+x m x m ) / m-x c x c b=2[(x1y1+x2y2+…+x m y m ) / m-x c y c ] c=(y1y1+y2y2+…+y m and m ) / my c and c Finally, the contour C is calculated by a, b and c i The direction angle θ of the corresponding area is: θ=arctan[b / (ac)] / 2, and its range is (-90°, 90°].

4. The image processing method for measuring the angle value of a tubular level bubble according to claim 1, characterized in that: In step S3, the specific steps of performing tilt correction on the binary image bw are: Step S31: Calculate the left engraved line direction angle θ L and the right engraved line direction angle θ R The mean value θ mean =(θ L +θ R ) / 2; Step S32: Calculate the correction angle α: Step S33: construct the correction matrix M: Where (x img ,y img ) is the center coordinate of the binary image bw; Step S34: Use the correction matrix M to transform the pixel coordinates in the binary image bw: Where (x, y) is the pixel coordinate in the binary image bw; (x', y') is the pixel coordinate in the corrected image rtBw0, and the corresponding pixel values ​​remain unchanged before and after the coordinate transformation; Step S35: Use the mean interpolation method to normalize the pixels in the corrected image rtBw0 to integer coordinates, taking (x img ,y img ) is the center and the area with the same size as the binary image bw, and the final corrected image rtBw is obtained, where (x img ,y img ) is the center of the binary image bw.

5. The image processing method for measuring the angle value of a tubular level bubble according to claim 1, characterized in that: In step S5, the specific method for searching for the left endpoint of the bubble is as follows: within the bubble left endpoint search area in the tilt-corrected binary image rtBw, the first pixel with a pixel value of 0 is searched in order from bottom to top and from left to right, and the location of the pixel is the left endpoint of the bubble.

6. The image processing method for measuring the angle value of a tubular level bubble according to claim 1, characterized in that: In step S6, the main axis of the left engraved line is a straight line passing through the centroid of the left engraved line and in a vertical state.

7. The image processing method for measuring the angle value of a tubular level bubble according to claim 1, characterized in that: In step S6, the pixel equivalent is calculated by dividing the physical spacing between the left and right engraved lines by the absolute value of the difference between the centroid abscissas of the left and right engraved lines obtained in step S4 to obtain the pixel equivalent in units of mm / px.

8. The image processing method for measuring the angle of a tubular level bubble according to claim 1, characterized in that: The specific step S7 is as follows: by collecting the image of the level bubble when the bubble is in the initial position and the image of the level bubble when the bubble is in the position after moving, the two collected level bubble images are processed respectively using steps 1 to 6 to obtain the physical distance from the left end points of the two bubbles to the main axis of the left scale line, and the absolute value of their difference is the distance the bubble moves along the axial direction.

Citation Information

Patent Citations

  • Level bubble scribed line width measuring method based on image processing technology

    CN109883396A

  • Leveling instrument limit inclination qualification detection system and method based on image processing technology

    CN113008267A

  • Tubular level position precision measuring method based on image processing

    CN113124898A

  • Measuring apparatus for analogue gauge and method thereof

    KR102089498B1