CN108592948B - Automatic measurement method for bubble offset of pipe level - Google Patents

Automatic measurement method for bubble offset of pipe level Download PDF

Info

Publication number
CN108592948B
CN108592948B CN201810417199.6A CN201810417199A CN108592948B CN 108592948 B CN108592948 B CN 108592948B CN 201810417199 A CN201810417199 A CN 201810417199A CN 108592948 B CN108592948 B CN 108592948B
Authority
CN
China
Prior art keywords
bubble
image
offset
area
center
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201810417199.6A
Other languages
Chinese (zh)
Other versions
CN108592948A (en
Inventor
刘磊
陈爱军
丁佳为
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Jiliang University
Original Assignee
China Jiliang University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China Jiliang University filed Critical China Jiliang University
Priority to CN201810417199.6A priority Critical patent/CN108592948B/en
Publication of CN108592948A publication Critical patent/CN108592948A/en
Application granted granted Critical
Publication of CN108592948B publication Critical patent/CN108592948B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G01MEASURING; TESTING
    • G01CMEASURING DISTANCES, LEVELS OR BEARINGS; SURVEYING; NAVIGATION; GYROSCOPIC INSTRUMENTS; PHOTOGRAMMETRY OR VIDEOGRAMMETRY
    • G01C25/00Manufacturing, calibrating, cleaning, or repairing instruments or devices referred to in the other groups of this subclass
    • GPHYSICS
    • G01MEASURING; TESTING
    • G01CMEASURING DISTANCES, LEVELS OR BEARINGS; SURVEYING; NAVIGATION; GYROSCOPIC INSTRUMENTS; PHOTOGRAMMETRY OR VIDEOGRAMMETRY
    • G01C9/00Measuring inclination, e.g. by clinometers, by levels
    • G01C9/18Measuring inclination, e.g. by clinometers, by levels by using liquids
    • G01C9/24Measuring inclination, e.g. by clinometers, by levels by using liquids in closed containers partially filled with liquid so as to leave a gas bubble
    • G01C9/34Measuring inclination, e.g. by clinometers, by levels by using liquids in closed containers partially filled with liquid so as to leave a gas bubble of the tubular type, i.e. for indicating the level in one direction only
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02EREDUCTION OF GREENHOUSE GAS [GHG] EMISSIONS, RELATED TO ENERGY GENERATION, TRANSMISSION OR DISTRIBUTION
    • Y02E30/00Energy generation of nuclear origin
    • Y02E30/30Nuclear fission reactors

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Radar, Positioning & Navigation (AREA)
  • Remote Sensing (AREA)
  • Manufacturing & Machinery (AREA)
  • Image Analysis (AREA)
  • Length Measuring Devices By Optical Means (AREA)

Abstract

本发明公开了一种管水准器气泡偏移量自动测量方法,具体实施内容为:本发明方法采用自动确定感兴趣区域的方式对原始管水准器灰度图像进行操作获取感兴趣区域图像,在感兴趣图像中判断气泡偏移位置,若气泡进入计算偏移量固定区域且气泡月牙形区域中心离固定区域中心较远时,粗略计算气泡偏移量;若气泡月牙形区域中心离固定区域中心较近时,精确计算气泡的偏移量,最终根据图像标定结果实现对管水准器内气泡偏移量的测量。本发明方法采用机器视觉的方式能有效解决采用人眼识别时费时费力,误差大的问题,采用气泡中心与两条黑线包围的矩形中心的水平距离值表示实际偏移量的方法,算法具有创新性且鲁棒性佳,同时简单实用,精度高。

Figure 201810417199

The invention discloses a method for automatically measuring the bubble offset of a tube level. The specific implementation content is as follows: the method of the invention adopts the method of automatically determining the region of interest to operate the gray image of the original tube level to obtain the image of the region of interest. Determine the offset position of the bubble in the image of interest. If the bubble enters the fixed area of the calculated offset and the center of the bubble crescent is far from the center of the fixed area, roughly calculate the bubble offset; if the center of the bubble crescent is far from the center of the fixed area When it is close, the offset of the bubble is accurately calculated, and finally the measurement of the offset of the bubble in the vial is realized according to the image calibration result. The method of the present invention uses machine vision to effectively solve the time-consuming and labor-intensive problems of human-eye recognition and large errors. The method uses the horizontal distance value between the center of the bubble and the center of the rectangle surrounded by two black lines to represent the actual offset. The algorithm has Innovative and robust, yet simple and practical with high precision.

Figure 201810417199

Description

一种管水准器气泡偏移量自动测量方法A method for automatic measurement of bubble offset in tube vial

技术领域technical field

本发明涉及机器视觉测量技术领域,涉及一种管水准器气泡偏移量自动测量方法。The invention relates to the technical field of machine vision measurement, and relates to a method for automatically measuring the bubble offset of a tube level.

背景技术Background technique

在众多工业制造生产活动中,人们常常需要对被测物体表面进行平面度的检测,因此通常会借助一些带有管水准器的计量器具(例如: 水平仪等)来完成此类精密测量,目前使用最为广泛的方法是通过测量管水准器中的气泡偏移量来判断被测物体表面是否水平。当今市面上有很多用来检测被测物体表面平面度的带有管水准器的计量器具, 许多厂家为了保证自己生产的带有管水准器的计量器具测量准确性, 都会在产品出厂前对管水准器内的气泡进行检测和校准。一般校准的方式,就是将带有管水准器的计量器具置于标准水平检测台上,根据管水准器内气泡偏离中心的程度来判断出厂的计量器具是否合格。不同精度的计量器具在检测时允许的误差范围也不相同。目前国内的对于管水准器内气泡偏移量常用的检测方法:In many industrial manufacturing activities, people often need to check the flatness of the surface of the measured object. Therefore, some measuring instruments with tube levels (for example: spirit levels, etc.) are usually used to complete this type of precision measurement. The most widely used method is to judge whether the surface of the measured object is level by measuring the bubble offset in the tube level. There are many measuring instruments with tube levels on the market today, which are used to test the flatness of the surface of the measured object. Bubbles in the level are detected and calibrated. The general calibration method is to place the measuring instrument with a tube level on a standard level detection platform, and judge whether the factory-made measuring instrument is qualified according to the degree of deviation of the air bubbles in the tube level from the center. Measuring instruments with different precisions have different allowable error ranges during detection. At present, the commonly used detection methods for the bubble offset in the tube vial in China are as follows:

(1)通过人眼识别管水准器内气泡的偏移量,借此来判断计量器具合格与否,对产品进行校正也还只是人工调整管水准器的方式,显然这种方式不仅误差大,还大量消耗人力物力,产品精度很难得到提高。(1) The displacement of the air bubbles in the vial is recognized by human eyes to judge whether the measuring instrument is qualified or not. Calibration of the product is only a way of manually adjusting the vial. Obviously, this method not only has large errors, but also Also consume a large amount of manpower and material resources, product precision is difficult to be improved.

(2)基于Canny边缘检测和加权最小二乘的方法进行气泡偏移量的测量,虽然该方法对于质量较差的图像有很强的鲁棒性,但通过该方法找到的计算气泡偏移量的固定边界区域不够精确,导致最后计算出的气泡偏移量存在明显误差。(2) Measure the bubble offset based on Canny edge detection and weighted least squares. Although this method has strong robustness for poor quality images, the calculated bubble offset found by this method The fixed bounding area of is not precise enough, resulting in significant errors in the final calculated bubble offset.

(3)利用局部灰度梯度平均值曲线以及亚像素精度定位的方法进行气泡偏移量的测量,虽然该方法对于气泡轮廓边缘端点的提取精确度很高,但由于在实际测量矫正管水准器气泡的过程中,会受到电机振动的影响,气泡调整时,其轮廓形状会随之发生微小变化,因此,在持续调整的过程中若只提取气泡左右端点进行偏移量测量,则会严重影响到整个测量过程的测量精度。(3) Use the method of local gray gradient average curve and sub-pixel precision positioning to measure the bubble offset. Although this method has a high accuracy for extracting the edge point of the bubble outline, it is difficult to measure the corrected tube level in the actual measurement. During the process of air bubbles, it will be affected by the vibration of the motor. When the air bubbles are adjusted, their contour shape will change slightly. Therefore, if only the left and right endpoints of the air bubbles are extracted for offset measurement during the continuous adjustment process, it will seriously affect to the measurement accuracy of the entire measurement process.

发明内容Contents of the invention

本发明针对现有技术的不足,提供了一种管水准器气泡偏移量自动测量方法,该方法采用自动确定感兴趣区域的方式,在气泡中心刚进入计算气泡偏移量的固定区域中心时,采用粗略测量方法;在气泡中心接近计算气泡偏移量的固定区域中心时,采用精确测量方法;提高了测量精度,同时可用于机器替代人类对带有管水准器的计量器具进行矫正,解决了人眼识别、人工敲击费时费力,误差大的问题。Aiming at the deficiencies of the prior art, the present invention provides a method for automatically measuring the bubble offset of a vial, which adopts the method of automatically determining the region of interest, and when the center of the bubble just enters the center of the fixed area for calculating the bubble offset , using a rough measurement method; when the center of the bubble is close to the center of the fixed area where the bubble offset is calculated, an accurate measurement method is used; the measurement accuracy is improved, and at the same time, it can be used for machines to replace human beings to correct measuring instruments with tube levels and solve the problem It solves the problems of human eye recognition, manual tapping, time-consuming and labor-intensive, and large errors.

本发明所采用的技术方案是,一种管水准器气泡偏移量自动测量方法,具体按照以下步骤实施:The technical solution adopted in the present invention is a method for automatically measuring the bubble offset of a tube level, which is specifically implemented according to the following steps:

步骤1:读取管水准器气泡原始灰度图像;Step 1: Read the original grayscale image of the bubble in the vial;

步骤2:对原始灰度图像进行二值化与中值滤波处理;Step 2: Perform binarization and median filtering on the original grayscale image;

步骤3:对中值滤波后的二值图像进行轮廓检测,计算各轮廓所包围区域的面积与各轮廓最小外接矩形面积之比以及各轮廓最小外接矩形长边长度;Step 3: Perform contour detection on the binary image after median filtering, and calculate the ratio of the area of the area surrounded by each contour to the area of the smallest circumscribing rectangle of each contour and the length of the long side of the smallest circumscribing rectangle of each contour;

步骤4:通过对各轮廓所包围区域的面积与各轮廓最小外接矩形面积之比以及各轮廓最小外接矩形长边长度的限制,来判断图像中是否存在计算气泡偏移量的固定区域;Step 4: Determine whether there is a fixed area in the image for calculating the bubble offset by the ratio of the area enclosed by each contour to the area of the smallest circumscribing rectangle of each contour and the length of the long side of the smallest circumscribing rectangle of each contour;

步骤5:若存在计算气泡偏移量的固定区域,则对计算气泡偏移量的固定区域进行外扩得到感兴趣区域;Step 5: If there is a fixed area for calculating the bubble offset, then expand the fixed area for calculating the bubble offset to obtain the region of interest;

步骤6:求取计算气泡偏移量的固定区域的最小外接矩形的倾角,以及固定区域轮廓所包围区域的面积与此固定区域轮廓的最小外接矩形面积的比值,根据此倾角和比值来判断气泡的偏移位置;Step 6: Obtain the inclination angle of the smallest circumscribed rectangle of the fixed area for calculating the bubble offset, and the ratio of the area enclosed by the outline of the fixed area to the area of the smallest circumscribed rectangle of the outline of the fixed area, and judge the bubble according to the inclination and ratio offset position;

步骤7:若气泡进入计算气泡偏移量的固定区域范围内,则计算气泡反光产生的月牙形区域最小外接矩形中心与固定区域最小外接矩形中心的水平物理距离,粗略测量气泡的偏移量;Step 7: If the bubble enters the fixed area where the bubble offset is calculated, calculate the horizontal physical distance between the center of the smallest circumscribed rectangle of the crescent-shaped area generated by the reflection of the bubble and the center of the smallest circumscribed rectangle of the fixed area, and roughly measure the offset of the bubble;

步骤8:若月牙形区域最小外接矩形中心与计算气泡偏移量的固定区域最小外接矩形中心的水平物理距离非常小时,则计算包围气泡周长最大轮廓的外接矩形中心与固定区域最小外接矩形中心的水平物理距离,精确测量气泡的偏移量。Step 8: If the horizontal physical distance between the center of the smallest bounding rectangle of the crescent-shaped area and the center of the smallest bounding rectangle of the fixed area where the offset of the bubble is calculated is very small, then calculate the center of the bounding rectangle surrounding the largest contour of the perimeter of the bubble and the center of the smallest bounding rectangle of the fixed area The horizontal physical distance of , accurately measure the offset of the bubble.

本发明的有益效果是,通过图像处理技术根据管水准器中气泡的不同位置,计算气泡月牙形区域中心或气泡整体区域中心偏离管水准器固定区域中心的距离,实现管水准器气泡偏移量的测量。本发明方法,能有效解决采用人眼识别时,费时费力,误差大的问题,采用气泡中心与两条黑线包围的矩形中心的水平距离值的方法代替气泡轮廓左右边缘点与两条黑线轮廓中心水平距离值的方法,计算实际的偏移量,前者算法鲁棒性更佳,同时简单实用,精度高。The beneficial effect of the present invention is that, according to the different positions of the bubbles in the vial, the image processing technology is used to calculate the distance between the center of the crescent-shaped area of the bubble or the center of the overall area of the bubble deviating from the center of the fixed area of the vial, so as to realize the bubble offset of the vial Measurement. The method of the present invention can effectively solve the problems of time-consuming, laborious and large errors when using human eyes to identify, and the method of using the horizontal distance value between the center of the bubble and the center of the rectangle surrounded by two black lines replaces the left and right edge points of the bubble outline and the two black lines The method of the horizontal distance value of the contour center calculates the actual offset. The former algorithm is more robust, simple and practical, and has high precision.

附图说明Description of drawings

图1是本发明方法的步骤流程图;Fig. 1 is a flow chart of the steps of the inventive method;

图2是本发明方法获取的初始图像;Fig. 2 is the initial image that the inventive method obtains;

图3是本发明方法获取的二值化中值滤波图像;Fig. 3 is the binarized median filter image that the inventive method obtains;

图4是本发明方法获取的轮廓检测图像;Fig. 4 is the contour detection image that the inventive method obtains;

图5是本发明方法获取的固定区域实际包围轮廓图像;Fig. 5 is the actual surrounding contour image of the fixed area obtained by the method of the present invention;

图6是本发明方法获取的固定区域外接矩形图像;Fig. 6 is the circumscribed rectangular image of the fixed region obtained by the method of the present invention;

图7是本发明方法获取的感兴趣区域图像;Fig. 7 is the region of interest image obtained by the method of the present invention;

图8是本发明方法获取的消去短0行程后的感兴趣区域二值图像;Fig. 8 is the region-of-interest binary image obtained by the method of the present invention after eliminating short 0 strokes;

图9是本发明方法获取的标有气泡月牙形区域最小外接矩形图像;Fig. 9 is the minimum circumscribed rectangle image marked with a bubble crescent-shaped region obtained by the method of the present invention;

图10是本发明方法获取的气泡二值化取反图像;Fig. 10 is the inverse image of the bubble binarization obtained by the method of the present invention;

图11是本发明方法获取的标有气泡轮廓周长最大的外接矩形图像。Fig. 11 is an image of a circumscribed rectangle marked with the largest perimeter of the bubble contour acquired by the method of the present invention.

具体实施方式Detailed ways

以下结合附图对本发明作进一步说明。The present invention will be further described below in conjunction with accompanying drawing.

如图1所示,本发明方法的步骤是:As shown in Figure 1, the step of the inventive method is:

步骤1:读取管水准器气泡原始灰度图像Step 1: Read the original grayscale image of the tube vial bubble

读取待进行气泡偏移量测量的管水准器气泡原始灰度图像,得到的结果如图2所示Read the original grayscale image of the bubble in the vial to be measured for the bubble offset, and the result is shown in Figure 2

步骤2:对原始灰度图像进行二值化与中值滤波处理Step 2: Binarize and median filter the original grayscale image

对原始灰度图像src采用OTSU法进行二值化分割处理得到二值化图像BI;对BI采用5X5窗口进行中值滤波去除噪声,得到滤波后的图像Ifilt,如图3所示。The original grayscale image src is binarized and segmented by the OTSU method to obtain the binarized image BI; the 5X5 window is used to remove the noise by the median filter for BI, and the filtered image I filt is obtained, as shown in Fig. 3 .

步骤3:对中值滤波后的二值图像进行轮廓检测,计算各轮廓所包围区域的面积与各轮廓最小外接矩形面积之比以及各轮廓最小外接矩形长边长度Step 3: Perform contour detection on the binary image after median filtering, and calculate the ratio of the area enclosed by each contour to the area of the smallest circumscribing rectangle of each contour and the length of the long side of the smallest circumscribing rectangle of each contour

对滤波后的图像Ifilt进行轮廓检测,得到的轮廓检测图像如图4 所示。计算中值滤波后图像Ifilt中每个轮廓Ci的实际包围面积Areai与其最小外接矩形面积之比Ri,以及最小外接矩形的长边长度Li,其中i=1,2,3,...,N,N为中值滤波后图像Ifilt中轮廓个数。Contour detection is performed on the filtered image I filt , and the obtained contour detection image is shown in FIG. 4 . Calculate the ratio R i of the actual enclosing area Area i of each contour C i in the median filtered image I filt to the area of the smallest circumscribing rectangle R i , and the length of the long side L i of the smallest circumscribing rectangle, where i=1,2,3, ..., N, N is the number of contours in the image I filt after median filtering.

步骤4:通过对各轮廓所包围区域的面积与各轮廓最小外接矩形面积之比以及各轮廓最小外接矩形长边长度的限制,来判断图像中是否存在计算气泡偏移量的固定区域。Step 4: Determine whether there is a fixed area in the image for calculating the bubble offset through the ratio of the area enclosed by each contour to the area of the smallest circumscribing rectangle of each contour and the length of the long side of the smallest circumscribing rectangle of each contour.

对步骤3得到的各轮廓所包围区域的面积与各轮廓最小外接矩形面积之比Ri以及各轮廓最小外接矩形长边长度Li进行限制,当比值Ri大于某个定值TR且长边长度Li在某个固定范围[L1,Lh]内时,即:Limit the ratio R i of the area enclosed by each contour obtained in step 3 to the area of the smallest circumscribed rectangle of each contour R i and the length L i of the smallest circumscribed rectangle of each contour. When the ratio R i is greater than a certain value T R and the length When the side length L i is within a fixed range [L 1 , L h ], that is:

Ri>TR且L1≤Li≤Lh (1)R i >T R and L 1 ≤L i ≤L h (1)

则判定为中值滤波后图像Ifilt中存在计算气泡偏移量的固定区域 Rect,将满足公式(1)的轮廓设为固定区域Rect的轮廓CR,继续进行后续处理;否则,判定为中值滤波后图像Ifilt中不存在计算气泡偏移量的固定区域轮廓,给出“气泡不在当前图像中”的信息提示,不再进行后续处理。Then it is determined that there is a fixed region Rect for calculating the bubble offset in the image I filt after median filtering, and the contour satisfying the formula (1) is set as the contour C R of the fixed region Rect, and the subsequent processing is continued; otherwise, it is judged as medium After value filtering, there is no fixed area outline for calculating the bubble offset in the image I filt , and the message "bubble is not in the current image" will be given, and no subsequent processing will be performed.

步骤5:若存在计算气泡偏移量的固定区域,则对计算气泡偏移量的固定区域进行外扩得到感兴趣区域Step 5: If there is a fixed area for calculating the bubble offset, then expand the fixed area for calculating the bubble offset to obtain the region of interest

若中值滤波后图像Ifilt中存在计算气泡偏移量的固定区域轮廓 CR,则先获取固定区域轮廓CR的外接矩形RMax,如图6所示。再将矩形RMax向上、向下、向左和向右外扩一定距离iOffset,得到矩形 RN。将矩形RN在中值滤波后图像Ifilt中所包含的区域图像Iroi作为感兴趣区域图像从中值滤波后图像Ifilt中提取出,感兴趣区域图像Iroi如图7所示。同时,设感兴趣区域图像Iroi的最左上角的第一个像素点在原始灰度图像src中的坐标为(TLx,TLy)。If there is a fixed region contour C R for calculating the bubble offset in the image I filt after median filtering, first obtain the circumscribed rectangle R Max of the fixed region contour C R , as shown in FIG. 6 . Then expand the rectangle R Max upwards, downwards, leftwards and rightwards by a certain distance iOffset to obtain the rectangle R N . The region image I roi contained in the median-filtered image I filt of the rectangle R N is extracted from the median-filtered image I filt as the region-of-interest image, and the region-of-interest image I roi is shown in FIG. 7 . At the same time, let the coordinates of the first pixel in the upper left corner of the region of interest image I roi in the original grayscale image src be (TL x , TL y ).

步骤6:求取计算气泡偏移量的固定区域的最小外接矩形的倾角,以及固定区域轮廓所包围区域的面积与此固定区域轮廓的最小外接矩形面积的比值,根据此倾角和比值来判断气泡的偏移位置Step 6: Calculate the inclination angle of the smallest circumscribed rectangle of the fixed area for calculating the bubble offset, and the ratio of the area enclosed by the outline of the fixed area to the area of the smallest encircled rectangle of the outline of the fixed area, and judge the bubble according to the inclination and ratio offset of

计算固定区域轮廓CR的最小外接矩形MER的倾角θ和固定区域轮廓CR实际包围的面积Area与其最小外接矩形面积的比值R,判断气泡的当前位置,如果R大于某个定值TRN,则判定气泡在计算气泡偏移量的固定区域外侧;气泡在外侧时,可根据计算气泡偏移量的固定区域的倾角。判断气泡在哪一侧;如果θ<-45°,则气泡在计算气泡偏移量的固定区域之外左侧,给出“气泡在固定区域左侧”的信息提示;否则,气泡在计算气泡偏移量的固定区域之外右侧,给出“气泡在固定区域右侧”的信息提示。Calculate the inclination angle θ of the minimum circumscribed rectangle MER of the fixed region contour C R and the ratio R of the area actually enclosed by the fixed region contour C R to the area of the minimum circumscribed rectangle, and judge the current position of the bubble. If R is greater than a certain value T RN , Then it is determined that the bubble is outside the fixed area where the bubble offset is calculated; when the bubble is outside, it can be determined according to the inclination angle of the fixed area where the bubble offset is calculated. Determine which side the bubble is on; if θ<-45°, the bubble is on the left side outside the fixed area where the bubble offset is calculated, and a message prompt "bubble is on the left side of the fixed area" is given; otherwise, the bubble is in the calculation bubble On the right side outside the fixed area of the offset, the information prompt "bubble is on the right side of the fixed area" is given.

步骤7:若气泡进入计算气泡偏移量的固定区域范围内,则计算气泡反光产生的月牙形区域最小外接矩形中心与固定区域最小外接矩形中心的水平物理距离,粗略测量气泡的偏移量Step 7: If the bubble enters the fixed area where the bubble offset is calculated, calculate the horizontal physical distance between the center of the smallest circumscribed rectangle of the crescent-shaped area generated by the reflection of the bubble and the center of the smallest circumscribed rectangle of the fixed area, and roughly measure the offset of the bubble

若气泡开始进入计算气泡偏移量的固定区域Rect,则先寻找气泡反光引起的月牙形区域RM;在感兴趣区域图像Iroi中按照从左到右、从上到下的顺序进行0行程的搜索,其中0行程为每行像素值均为0 的连续像素组成的像素段;如果某0行程的长度RL满足属于某个区间[Th1,Thh]时,即:If the bubble starts to enter the fixed area Rect where the bubble offset is calculated, first look for the crescent-shaped area R M caused by the reflection of the bubble; in the region of interest image I roi , perform 0 strokes in order from left to right and from top to bottom The search of , where the 0-stroke is a pixel segment composed of consecutive pixels whose pixel values are 0 in each row; if the length RL of a certain 0-stroke satisfies a certain interval [Th 1 ,Th h ], that is:

Th1≤RL≤Thh (2)Th 1 ≤ RL ≤ Th h (2)

则消去此短0行程,即将此行程中的所有黑像素变为白像素。所有满足公式(2)的短0行程消去后,得到图像bIroi,如图8所示。在图像bIroi中进行轮廓检测,如果轮廓的最小外接矩形的长边长度Wf满足公式(3),且这样的轮廓有且仅有1个,则判定存在月牙形区域RMThen eliminate this short 0 stroke, that is, all black pixels in this stroke will be changed into white pixels. After all the short 0-strokes satisfying the formula (2) are eliminated, the image bI roi is obtained, as shown in FIG. 8 . Contour detection is performed in the image bI roi , if the long side length W f of the smallest circumscribed rectangle of the contour satisfies the formula (3), and there is only one such contour, then it is determined that there is a crescent-shaped region R M :

W1<Wf<Wh (3)W 1 <W f <W h (3)

其中,W1和Wh为感兴趣图像中轮廓最小外接矩形长边长度的下限值和上限值。Among them, W 1 and W h are the lower limit and upper limit of the length of the long side of the smallest circumscribed rectangle of the outline in the image of interest.

如果存在月牙形区域RM的轮廓CM,则求取月牙形区域RM的最小外接矩形Mm,如图9所示,将月牙形区域的最小外接矩形Mm的中心设为Mc,Mc在感兴趣区域图像Iroi中的横坐标设为MCx,则月牙形区域最小外接矩形的中心Mc在原始灰度图像src中的横坐标Mx为:If there is a contour C M of the crescent-shaped region R M , then the minimum circumscribed rectangle M m of the crescent-shaped region R M is calculated, as shown in Figure 9, the center of the minimum circumscribed rectangle M m of the crescent-shaped region is set as M c , The abscissa of M c in the region of interest image I roi is set to MC x , then the abscissa M x of the center M c of the smallest circumscribed rectangle of the crescent-shaped area in the original grayscale image src is:

Mx=MCx+TLx (4)M x =MC x +TL x (4)

其中,TLx为感兴趣区域图像Iroi的最左上角的第一个像素点在原始灰度图像src中的横坐标。Among them, TL x is the abscissa of the first pixel in the upper left corner of the region of interest image I roi in the original grayscale image src.

设计算气泡偏移量的固定区域Rect的最小外接矩形MER的中心为MEc,MEc在原始灰度图像src中的横坐标为MEx;用计算气泡偏移量的固定区域的最小外接矩形中心横坐标MEx与月牙形区域轮廓外接矩形中心在原始灰度图像src中的横坐标Mx间的差值△X1,来表示气泡在图像中的偏移量,单位为pixel:The center of the minimum circumscribed rectangle MER of the fixed area Rect for calculating the bubble offset is ME c , and the abscissa of ME c in the original grayscale image src is ME x ; use the minimum circumscribed rectangle of the fixed area for calculating the bubble offset The difference between the central abscissa ME x and the abscissa M x of the center of the circumscribed rectangle of the crescent-shaped area in the original grayscale image src is the difference △X 1 , which represents the offset of the bubble in the image, and the unit is pixel:

△X1=MEx-Mx (5)△X 1 =ME x -M x (5)

如果△X>0,则气泡偏左;否则,气泡偏右。根据图像标定结果 Res,单位为mm/pixel,粗略计算气泡物理偏移量dR1,单位为mm:If △X>0, the bubble is to the left; otherwise, the bubble is to the right. According to the image calibration result Res, the unit is mm/pixel, roughly calculate the bubble physical offset dR 1 , the unit is mm:

dR1=|△X1|×Res (6)dR 1 =|△X 1 |×Res (6)

其中|△X1|表示△X1的绝对值;Where |△X 1 | represents the absolute value of △X 1 ;

如果△X1>0,则给出“气泡偏左XX mm”的信息提示;否则给出“气泡偏右XX mm”的信息提示,其中XX为dR1的值。If △X 1 >0, give the information prompt of "the bubble is XX mm to the left"; otherwise, give the information prompt of "the bubble is XX mm to the right", where XX is the value of dR 1 .

步骤8:若月牙形区域最小外接矩形中心与计算气泡偏移量的固定区域最小外接矩形中心的水平物理距离小于1mm,则计算包围气泡周长最大轮廓的外接矩形中心与固定区域最小外接矩形中心的水平物理距离,精确测量气泡的偏移量Step 8: If the horizontal physical distance between the center of the smallest circumscribing rectangle of the crescent-shaped area and the center of the smallest circumscribing rectangle of the fixed area where the offset of the bubble is calculated is less than 1mm, calculate the center of the circumscribing rectangle surrounding the largest contour of the perimeter of the bubble and the center of the smallest circumscribing rectangle of the fixed area The horizontal physical distance of , accurately measure the offset of the bubble

若月牙形区域最小外接矩形中心Mc与计算气泡偏移量的固定区域最小外接矩形中心MEc的水平方向距离小于某个阈值dT时,即 |dR1|<dT,则从中值滤波后图像Ifilt中截取固定区域轮廓CR的外接矩形RMax对应区域的图像并对其进行取反操作,得到取反后的图像Isub,如图10所示;对图像Isub进行轮廓检测,提取出周长最大的轮廓CB,轮廓CB即为气泡轮廓;计算气泡轮廓CB的外接矩形RB,如图11所示,气泡轮廓外接矩形RB的中心MBc的横坐标设为MBx,则气泡轮廓外接矩形中心MBc在原始灰度图像src中的横坐标Mb为:If the horizontal distance between the minimum circumscribed rectangle center M c of the crescent-shaped area and the minimum circumscribed rectangle center ME c of the fixed area for calculating the bubble offset is less than a certain threshold dT, that is, |dR 1 |<dT, then the median filtered image In I filt , intercept the image of the area corresponding to the circumscribed rectangle R Max of the contour CR of the fixed area and perform an inversion operation on it to obtain the inverse image I sub , as shown in Figure 10; perform contour detection on the image I sub , and extract Get the contour C B with the largest perimeter, and the contour C B is the bubble contour; calculate the circumscribed rectangle R B of the bubble contour C B , as shown in Figure 11, the abscissa of the center MB c of the circumscribed rectangle R B of the bubble contour is set to MB x , then the abscissa M b of the center MB c of the circumscribed rectangle of the bubble outline in the original grayscale image src is:

Mb=MBx+TLN (7)M b =MB x +TL N (7)

其中,TLN为图像Isub的最左上角的第一个像素点在原始灰度图像src 中的横坐标。Wherein, TL N is the abscissa of the first pixel in the upper left corner of the image I sub in the original grayscale image src .

用计算气泡偏移量的固定区域外接矩形中心横坐标MEx与气泡轮廓外接矩形中心在原始灰度图像src中的横坐标Mb的差值△X2来表示气泡偏移量,单位为pixel:The bubble offset is represented by the difference △X 2 between the abscissa ME x of the center of the circumscribed rectangle of the fixed area for calculating the bubble offset and the abscissa M b of the center of the circumscribed rectangle of the bubble outline in the original grayscale image src, and the unit is pixel :

△X2=MEx-Mb (8)△X 2 =ME x -M b (8)

根据图像标定结果Res,单位为mm/pixel),精确计算气泡物理偏移量dR2,单位为mm:According to the image calibration result Res, the unit is mm/pixel), accurately calculate the bubble physical offset dR 2 , the unit is mm:

dR2=|△X2|×Res (9)dR 2 =|△X 2 |×Res (9)

其中|△X2|表示△X2的绝对值。where |△X 2 | represents the absolute value of △X 2 .

如果dR2>0,则给出“气泡偏左XX mm”的信息提示;否则给出“气泡偏右XX mm”的信息提示;其中XX为dR2的绝对值;当 |dR2|<TP时,则判定气泡已处于管水准器中心,给出“合格”的信息提示,其中TP为给定的气泡偏移量最大允许误差。If dR 2 >0, give the information prompt of "the bubble is XX mm to the left"; otherwise, give the information prompt of "the bubble is XX mm to the right"; where XX is the absolute value of dR 2 ; when |dR 2 |<TP , it is determined that the bubble is in the center of the vial, and a "qualified" message is given, where TP is the maximum allowable error of the given bubble offset.

Claims (8)

1. A method for automatically measuring the bubble offset of a pipe level is characterized by comprising the following steps:
step 1, reading an original gray image of a bubble of a pipe level;
step 2: carrying out binarization and median filtering processing on the original gray level image;
and step 3: carrying out contour detection on the binary image after median filtering, and calculating the ratio of the area of the region surrounded by each contour to the minimum circumscribed rectangle area of each contour and the length of the long side of the minimum circumscribed rectangle of each contour;
and 4, step 4: judging whether a fixed region for calculating the bubble offset exists in the image or not by limiting the ratio of the area of the region surrounded by each outline to the area of the minimum circumscribed rectangle of each outline and the length of the long side of the minimum circumscribed rectangle of each outline;
and 5: if a fixed area for calculating the bubble offset exists, carrying out external expansion on the fixed area for calculating the bubble offset to obtain an interested area;
step 6: calculating the inclination angle of the minimum circumscribed rectangle of the fixed region for calculating the bubble offset, and the ratio of the area of the region surrounded by the outline of the fixed region to the area of the minimum circumscribed rectangle of the outline of the fixed region, and judging the offset position of the bubble according to the inclination angle and the ratio;
and 7: if the bubbles enter the range of the fixed area for calculating the bubble offset, calculating the horizontal physical distance between the center of the minimum external rectangle of the crescent area generated by reflecting light of the bubbles and the center of the minimum external rectangle of the fixed area, and roughly measuring the offset of the bubbles;
and 8: and if the horizontal physical distance between the center of the minimum external rectangle of the crescent area and the center of the minimum external rectangle of the fixed area for calculating the bubble offset is very small, calculating the horizontal physical distance between the center of the external rectangle surrounding the maximum outline of the bubble perimeter and the center of the minimum external rectangle of the fixed area, and accurately measuring the offset of the bubble.
2. The method for automatically measuring the bubble offset of the pipe level according to claim 1, wherein the step 2 is specifically performed according to the following procedures:
carrying out binarization segmentation processing on the original gray level image src by adopting an OTSU method to obtain a binarization image BI; median filtering is carried out on the BI by adopting a 5 multiplied by 5 window to remove noise, and a filtered image I is obtained filt
3. The method for automatically measuring the bubble offset of the pipe level according to claim 1, wherein the step 3 is specifically performed according to the following steps:
for filtered image I filt Contour detection is carried out, and a median filtered image I is calculated filt Of each contour C i Actual Area of enclosure Area of i The ratio R of the minimum circumscribed rectangular area i And length L of the long side of the minimum bounding rectangle i Wherein I =1,2, 3.. And N, N is the median filtered image I filt The number of the middle outlines.
4. The method for automatically measuring the bubble offset of the pipe level according to claim 1, wherein the step 4 is specifically performed according to the following procedures:
the ratio C of the area surrounded by each contour obtained in the step 3 to the minimum circumscribed rectangle area of each contour i And length L of long side of minimum circumscribed rectangle of each outline i Limiting when the ratio C is i Greater than a certain constant value T R And the length L of the long side i Within a certain fixed range [ L 1 ,L h ]When the internal pressure is within the range:
R i >T R and L is 1 ≤L i ≤L h (1)
It is determined as the median filtered image I filt There is a fixed region Rect in which to calculate the bubble offset, and the contour satisfying the formula is set to the contour C of the fixed region Rect R Continuing to perform subsequent processing; otherwise, judging the image I after median filtering filt The contour of a fixed area for calculating the bubble offset does not exist, and the information prompt of 'the bubble is not in the current image' is given, so that the subsequent processing is not performed any more.
5. The method for automatically measuring the bubble offset of the pipe level according to claim 1, wherein the step 5 is specifically performed according to the following steps:
if the median value is filtered image I filt In which there is a fixed area contour C for calculating the amount of bubble offset R Then, first, the contour C of the fixed region is obtained R Is a circumscribed rectangle R Max Then, the rectangle R is put Max Extending a certain distance iOffset upwards, downwards, leftwards and rightwards to obtain a rectangle R N Will be rectangular R N Image I after median filtering filt Area image I contained in roi Median filtered image I as region of interest image filt Extracting; meanwhile, setting a region of interest image I roi The coordinate of the first pixel point at the top left corner in the original gray level image src is (TL) x ,TL y )。
6. The method for automatically measuring the bubble offset of the pipe level according to claim 1, wherein the step 6 is specifically performed according to the following steps:
calculating a fixed region contour C R And the minimum circumscribed rectangle MER and the constant area profile C R The ratio R of the Area actually surrounded to the minimum circumscribed rectangle Area of the Area is used for judging the current position of the bubble, and if R is larger than a certain fixed value T RN If so, judging that the air bubble is outside the fixed area for calculating the air bubble offset; when the air bubble is on the outer side, the air bubble on which side is positioned can be judged according to the inclination angle of the fixed area for calculating the offset of the air bubble; if theta is greater than theta<45 degrees, the air bubble is on the left side outside the fixed area for calculating the air bubble offset, and an information prompt that the air bubble is on the left side of the fixed area is given; otherwise, the bubble is outside the fixed area of the calculated bubble offset and is on the right side, and an information prompt that the bubble is on the right side of the fixed area is given.
7. The method for automatically measuring the bubble offset of the pipe level according to claim 1, wherein the step 7 is specifically performed according to the following steps:
if the bubble begins to enter the fixed area Rect for calculating the bubble offset, firstly, a crescent area R caused by bubble reflection is searched M (ii) a In a region of interest image I roi The 0 stroke is searched from left to right and from top to bottom, wherein the 0 stroke is a pixel segment formed by continuous pixels of which the pixel values of each row are 0; if a certain 0 lineThe length of the range RL satisfies the requirement of belonging to a certain interval Th 1 ,Th h ]When, namely:
Th 1 ≤RL≤Th h (2)
the short 0 stroke is eliminated, namely all black pixels in the stroke are changed into white pixels; all short 0 strokes satisfying the formula (2) are eliminated to obtain an image bI roi (ii) a In the image bI roi If the length W of the long side of the minimum bounding rectangle of the contour is detected f Satisfying equation (3), and such contours have only 1, it is determined that the crescent-shaped region R exists M
W 1 <W f <W h (3)
Wherein, W f And W h The lower limit value and the upper limit value of the length of the long side of the outline minimum circumscribed rectangle in the interested image are set;
if there is a crescent shaped region R M Is (C) M Then, the crescent-shaped region R is obtained M Minimum circumscribed rectangle M of m The minimum external rectangle M of the crescent area m Is set as M c ,M c In a region of interest image I roi The abscissa of (A) is set as MC x Then the center M of the minimum circumscribed rectangle of the crescent area c Abscissa M in original grayscale image src x Comprises the following steps:
M x =MC x +TL x (4)
wherein, TL x For an image I of a region of interest roi The abscissa of the first pixel point at the top left corner in the original gray level image src;
setting the center of the minimum circumscribed rectangle MER of the fixed region Rect for calculating the bubble offset as ME c ,ME c The abscissa in the original grayscale image src is ME x (ii) a With minimum circumscribed rectangle center abscissa ME of fixed area for calculating bubble offset x An abscissa M of a center of a rectangle circumscribed to the crescent region outline in the original gray level image src x Difference value DeltaX between 1 To indicate the amount of displacement of the bubble in the image, in units of pixel:
△X 1 =ME x -M x (5)
If Δ X>0, the bubble is left; otherwise, the bubble is deflected to the right; roughly calculating the physical bubble offset dR according to the image calibration result Res in mm/pixel 1 In mm:
dR 1 =|△X 1 |×Res (6)
wherein |. DELTA.X 1 | represents Δ X 1 Absolute value of (d);
if Δ X 1 >0, giving an information prompt of 'the air bubble is deviated from the left by XX mm'; otherwise, giving an information prompt of 'the air bubble is deviated from right XX mm'; wherein XX is dR 1 The value of (c).
8. The method as claimed in claim 1, wherein the step 8 is performed according to the following steps:
if the minimum external rectangle center M of the crescent area c ME (minimum bounding rectangle center) of fixed region for calculating bubble offset c Is less than a threshold value dT, i.e. | dR 1 |<dT, then image I filtered from the median filt Middle cut fixed area outline C R Is a circumscribed rectangle R Max The image of the corresponding area is inverted to obtain an inverted image I sub (ii) a For image I sub Detecting the contour and extracting the contour C with the maximum perimeter B Contour C B Namely the bubble profile; calculating the bubble profile C B Is a circumscribed rectangle R B The outline of the bubble is circumscribed by a rectangle R B Center MB of c The abscissa of (a) is set as MB x The outline of the bubble circumscribes the center MB of the rectangle c Abscissa M in original grayscale image src b Comprises the following steps:
M b =MB x +TL N (7)
wherein, TL N Is an image I sub The first pixel point at the top left corner of the original gray image src sits transverselyMarking;
fixed region circumscribed rectangle center abscissa ME for calculating bubble offset x Abscissa M of the center of the rectangle circumscribing the bubble outline in the original grayscale image src b Difference of (A) Δ X 2 To represent the bubble offset, in pixel:
△X 2 =ME x -M b (8)
accurately calculating the physical bubble offset dR according to the image calibration result Res in mm/pixel 2 In mm:
dR 2 =|△X 2 |×Res (9)
wherein |. DELTA.X 2 | represents Δ X 2 Absolute value of (d);
if dR 2 >0, giving an information prompt of 'the air bubble is deviated from the left by XX mm'; otherwise, giving an information prompt of 'the air bubble is deviated from the right by XX mm', wherein XX is dR 2 Absolute value of (d); when | dR 2 |<And at TP, judging that the air bubble is positioned at the center of the tube level, and giving a qualified information prompt, wherein TP is the maximum allowable error of the given air bubble offset.
CN201810417199.6A 2018-04-28 2018-04-28 Automatic measurement method for bubble offset of pipe level Active CN108592948B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810417199.6A CN108592948B (en) 2018-04-28 2018-04-28 Automatic measurement method for bubble offset of pipe level

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810417199.6A CN108592948B (en) 2018-04-28 2018-04-28 Automatic measurement method for bubble offset of pipe level

Publications (2)

Publication Number Publication Date
CN108592948A CN108592948A (en) 2018-09-28
CN108592948B true CN108592948B (en) 2023-03-14

Family

ID=63620745

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810417199.6A Active CN108592948B (en) 2018-04-28 2018-04-28 Automatic measurement method for bubble offset of pipe level

Country Status (1)

Country Link
CN (1) CN108592948B (en)

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109886911B (en) * 2018-10-09 2020-12-18 中国计量大学 A detection method of level bubble scribe line defect based on image processing technology
CN109883396B (en) * 2018-10-09 2020-11-24 中国计量大学 A method for measuring the width of leveling bubble scribe line based on image processing technology
CN109900302A (en) * 2019-04-09 2019-06-18 中国计量大学 A kind of more groove level tube bubbles error vision measuring method placed in the middle
CN112254744A (en) * 2020-10-23 2021-01-22 广州计量检测技术研究院 Bubble level meter calibration method, system, device and storage medium
CN113124898B (en) * 2021-03-03 2022-12-23 上海大学 Pipe level device position precision measuring method based on image processing
CN114018289B (en) * 2021-11-08 2022-06-10 河北省科学院应用数学研究所 Level detection method and device
CN116592835B (en) * 2023-07-18 2023-10-27 聊城金恒智慧城市运营有限公司 Intelligent construction leveling instrument and measuring method

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1402853A (en) * 1999-12-02 2003-03-12 三菱电机株式会社 Image retrieval system and image retrieval method
CN102739951A (en) * 2011-04-06 2012-10-17 富士施乐株式会社 Image processing apparatus, image processing method, and program
CN103206947A (en) * 2012-01-16 2013-07-17 中国科学院声学研究所 Tilt angle measurement method based on level bubble, and apparatus thereof
CN106289325A (en) * 2016-09-23 2017-01-04 浙江大学 A kind of air-bubble level automatic checkout system
CA3036332A1 (en) * 2016-09-25 2018-03-29 Israel Aerospace Industries Ltd. Method of calibrating a computerized leveling offset meter

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1402853A (en) * 1999-12-02 2003-03-12 三菱电机株式会社 Image retrieval system and image retrieval method
CN102739951A (en) * 2011-04-06 2012-10-17 富士施乐株式会社 Image processing apparatus, image processing method, and program
CN103206947A (en) * 2012-01-16 2013-07-17 中国科学院声学研究所 Tilt angle measurement method based on level bubble, and apparatus thereof
CN106289325A (en) * 2016-09-23 2017-01-04 浙江大学 A kind of air-bubble level automatic checkout system
CA3036332A1 (en) * 2016-09-25 2018-03-29 Israel Aerospace Industries Ltd. Method of calibrating a computerized leveling offset meter

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
一种基于图像处理的水平尺气泡偏移量检测系统;单晓杭,范超;《计算机应用与软件》;20171130;第34卷(第11期);全文 *

Also Published As

Publication number Publication date
CN108592948A (en) 2018-09-28

Similar Documents

Publication Publication Date Title
CN108592948B (en) Automatic measurement method for bubble offset of pipe level
CN108534802B (en) Tube level bubble deviation measurement method based on image processing technology
CN108876860B (en) An Image Calibration Method for Measurement of Bubble Offset of Tube Level
CN108613630B (en) Measurement method of bubble offset of two-line tube vial based on image processing technology
CN109003258B (en) A high-precision sub-pixel circular part measurement method
CN117237368B (en) Bridge crack detection method and system
CN107798672B (en) Method and system for measuring width of cut tobacco or cut stem and server with system
CN101408985B (en) A method and device for extracting the center of a circular light spot sub-pixel
CN109883396B (en) A method for measuring the width of leveling bubble scribe line based on image processing technology
CN110838097A (en) Conveyor belt offset measurement method based on machine vision
CN103353985A (en) Measurement method for image Gaussian Blur
CN106197612B (en) A liquid level detection method for transparent bottles based on machine vision
CN113066076A (en) Rubber tube leakage detection method, device, equipment and storage medium
CN114627080B (en) Vehicle stamping accessory defect detection method based on computer vision
CN107796826B (en) Detection method for broken teeth of micro-duplex gears based on tooth center distance curve analysis
CN113643276A (en) Textile texture defect automatic detection method based on statistical analysis
CN111862055B (en) Bubble turning cavity defect detection method based on image processing
CN115311294A (en) Glass bottle body flaw identification and detection method based on image processing
CN112419225B (en) A SOP-type chip detection method and system based on pin segmentation
CN113554688B (en) O-shaped sealing ring size measurement method based on monocular vision
CN114581915B (en) A noise-robust multi-category dial pointer reading recognition method and device
CN118552824B (en) Line structure light center line extraction method based on multichannel feature fusion
CN111861979A (en) Positioning method, positioning equipment and computer readable storage medium
CN111815575B (en) Bearing steel ball part detection method based on machine vision
CN109886911B (en) A detection method of level bubble scribe line defect based on image processing technology

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant