CN105740829A - Scanning line processing based automatic reading method for pointer instrument - Google Patents

Scanning line processing based automatic reading method for pointer instrument Download PDF

Info

Publication number
CN105740829A
CN105740829A CN201610074160.XA CN201610074160A CN105740829A CN 105740829 A CN105740829 A CN 105740829A CN 201610074160 A CN201610074160 A CN 201610074160A CN 105740829 A CN105740829 A CN 105740829A
Authority
CN
China
Prior art keywords
pointer
image
line
theta
scanning line
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.)
Pending
Application number
CN201610074160.XA
Other languages
Chinese (zh)
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.)
Jinan University
Original Assignee
Jinan 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 Jinan University filed Critical Jinan University
Priority to CN201610074160.XA priority Critical patent/CN105740829A/en
Publication of CN105740829A publication Critical patent/CN105740829A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V20/00Scenes; Scene-specific elements
    • G06V20/20Scenes; Scene-specific elements in augmented reality scenes

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Multimedia (AREA)
  • Theoretical Computer Science (AREA)
  • Image Processing (AREA)
  • Image Analysis (AREA)

Abstract

本发明公开了一种基于扫描线处理的指针式仪表自动读数方法,包括步骤:首先采用单尺度Retinex算法对原始图像进行光照处理,接着将图像二值化,然后基于行扫描线处理的方法提取出特征像素点,对特征像素点进行Hough变换检测指针直线,最后采用角度法计算读数;所述基于行扫描线处理的方法是指对图像中的每一行进行扫描,提取该行中的连续段,搜索连续段的长度小于等于指针线宽度的连续段,将该连续段的线段中点作为特征像素点。本发明通过采取Retinex算法可以减少非均匀光照对后续算法的影响,通过采用基于行扫描线处理的方法可以减少参与Hough变换的像素点数,从而降低计算量。

The invention discloses an automatic reading method of a pointer instrument based on scanning line processing, which includes the steps of: firstly, using a single-scale Retinex algorithm to perform illumination processing on the original image, then binarizing the image, and then extracting Feature pixel point is carried out, Hough transformation is carried out to feature pixel point to detect pointer straight line, adopt angle method to calculate reading at last; Described method based on line scanning line processing refers to scanning each line in the image, extracting the continuous segment in this line , search for a continuous segment whose length is less than or equal to the width of the pointer line, and use the midpoint of the continuous segment as a feature pixel. The present invention can reduce the impact of non-uniform illumination on subsequent algorithms by adopting the Retinex algorithm, and can reduce the number of pixels participating in the Hough transform by adopting a method based on row scanning line processing, thereby reducing the amount of calculation.

Description

一种基于扫描线处理的指针式仪表自动读数方法An automatic reading method of pointer instrument based on scanning line processing

技术领域technical field

本发明涉及图像处理研究领域,特别涉及一种基于扫描线处理的指针式仪表自动读数方法。The invention relates to the field of image processing research, in particular to an automatic reading method of a pointer meter based on scanning line processing.

背景技术Background technique

指针式仪表因结构简单、价格便宜、便于维护等优点,目前仍广泛应用于电力、交通和居民生活中。人工读数的精度和速度均容易受自身因素影响。特别是面对一些不适宜人靠近的恶劣环境下的仪表读数问题,更需要一种仪表自动读数技术来取代人工读数。由于机器视觉比人类的生理视觉更具优势,它更加准确、客观和稳定,因而图像识别技术就成为指针式仪表自动读数的重要应用手段。Due to the advantages of simple structure, low price and easy maintenance, pointer instruments are still widely used in electricity, transportation and residents' lives. The accuracy and speed of manual readings are easily affected by their own factors. Especially in the face of the problem of instrument reading in some harsh environments where people are not suitable for approaching, an automatic instrument reading technology is needed to replace manual reading. Because machine vision has more advantages than human physiological vision, it is more accurate, objective and stable, so image recognition technology has become an important application means for automatic reading of pointer instruments.

现在基于图像识别的指针式仪表自动读数算法,大多数是在理想环境下进行的,大体上分三步实现:第一步是指针提取,实现方法包括减影法、颜色空间法、阈值法、边缘提取法等;第二步是指针定位,实现方法包括利用Hough变换来检测指针等;第三步是读数计算,实现方法包括角度法和距离法等。但在实际应用中,光照不均匀或遮挡等因素对读数的精度和速度均有严重影响,直接应用上述算法无法得到理想的结果。Most of the automatic reading algorithms of pointer instruments based on image recognition are carried out in an ideal environment, and are generally implemented in three steps: the first step is pointer extraction, and the implementation methods include subtraction method, color space method, threshold method, Edge extraction method, etc.; the second step is pointer positioning, and the implementation method includes using Hough transform to detect pointers, etc.; the third step is reading calculation, and the implementation methods include angle method and distance method. However, in practical applications, factors such as uneven illumination or occlusion have a serious impact on the accuracy and speed of readings, and the ideal results cannot be obtained by directly applying the above algorithm.

针对光照不均匀情况,不少文献也提出过解决算法,例如李学聪,汪仁煌等2012年在《电测与仪器》杂志上提出的指针式仪表图像的六步预处理方法;汪志敏,汪仁煌2014年在《工业控制计算机》杂志上发表的《指针式仪表图像预处理及分割研究》,提到采用同态滤波技术来处理光照不均匀现象。上述方法虽然能解决一定光照变化问题,但是运算量都很大,不适合用在实时性要求较高的场合。Aiming at uneven illumination, many literatures have also proposed a solution algorithm, such as Li Xuecong, Wang Renhuang and others proposed a six-step preprocessing method for pointer instrument images in the journal "Electrical Measurement and Instrument" in 2012; Wang Zhimin, Wang Renhuang in 2014 in "Research on Image Preprocessing and Segmentation of Pointer Instruments" published in the journal "Industrial Control Computer" mentioned the use of homomorphic filtering technology to deal with uneven illumination. Although the above methods can solve the problem of certain illumination changes, they have a large amount of computation and are not suitable for occasions with high real-time requirements.

另外,针对Hough变换本身的计算量比较大的问题,也有不少文献提出解决算法。例如陶冰洁,韩佳乐等2011年在《光电工程》杂志上发表的《一种实用的指针式仪表读数识别方法》,该方法提出采用双阈值Hough变换,仅把位置在指针角度范围内的像素点进行变换;李静,张宁等2015年公开的《Hough变换的改进及其在指针式水表识别过程中的应用》,该方法提出对水表中像素灰度值在一定范围内的像素点进行变换;段汝娇等提出了一种基于改进Hough变换的直线快速检测算法,该算法是先对前景像素进行聚类,然后进行感知编组细分成许多小直线段,最后采用随机Hough变换对直线段进行检测。在一定程度上,这些方法均能减少进行Hough变换的像素点数,提高了检测速度,但检测的准确性还是不够理想。In addition, for the problem that the Hough transform itself has a relatively large amount of calculation, there are also many literatures that propose a solution algorithm. For example, Tao Bingjie, Han Jiale, etc. published "A Practical Pointer Instrument Reading Recognition Method" in the "Optoelectronic Engineering" magazine in 2011. This method proposes to use a double-threshold Hough transform, and only the pixels within the angle range of the pointer are processed. Transformation; "Improvement of Hough Transformation and Its Application in Pointer Water Meter Recognition Process" published by Li Jing, Zhang Ning, etc. in 2015, this method proposes to transform the pixel points in the water meter whose gray value is within a certain range; Duan Rujiao et al. proposed a fast line detection algorithm based on the improved Hough transform. The algorithm first clusters the foreground pixels, then performs perceptual grouping and subdivides them into many small straight line segments, and finally uses random Hough transform to detect the straight line segments. To a certain extent, these methods can reduce the number of pixels for Hough transform and improve the detection speed, but the detection accuracy is still not ideal.

为此,研究一种读数精度高、读取速度快的指针式仪表自动读数算法,具有重要的应用价值。For this reason, it is of great application value to study an automatic reading algorithm of a pointer instrument with high reading precision and fast reading speed.

发明内容Contents of the invention

本发明的目的在于克服现有技术的缺点与不足,提供一种基于扫描线处理的指针式仪表自动读数方法,该算法可以在非均匀光照下仍能够实现高精度、高读数速度,且读数速度可调节。The purpose of the present invention is to overcome the shortcomings and deficiencies of the prior art, and provide an automatic reading method for pointer instruments based on scanning line processing. The algorithm can still achieve high precision and high reading speed under non-uniform illumination, and the reading speed adjustable.

本发明的目的通过以下的技术方案实现:一种基于扫描线处理的指针式仪表自动读数方法,包括步骤:首先采用单尺度Retinex算法对原始图像进行光照处理,接着将图像二值化,然后基于行扫描线处理的方法提取出特征像素点,对特征像素点进行Hough变换检测指针直线,最后采用角度法计算读数;所述基于行扫描线处理的方法是指对图像中的每一行进行扫描,提取该行中的连续段,搜索连续段的长度小于等于指针线宽度的连续段,将该连续段的线段中点作为特征像素点。通过采取Retinex算法可以减少非均匀光照对后续算法的影响,通过采用基于行扫描线处理的方法可以减少参与Hough变换的像素点数,从而降低计算量。The object of the present invention is achieved through the following technical solutions: a method for automatic reading of pointer meters based on scanning line processing, comprising the steps of: firstly adopting a single-scale Retinex algorithm to carry out illumination processing on the original image, then binarizing the image, and then based on The method of row scanning line processing extracts feature pixels, performs Hough transform on feature pixels to detect pointer straight lines, and finally adopts angle method to calculate readings; the method based on row scan line processing refers to scanning each row in the image, Extract the continuous segment in the row, search for the continuous segment whose length is less than or equal to the width of the pointer line, and use the midpoint of the continuous segment as the feature pixel. The influence of non-uniform illumination on subsequent algorithms can be reduced by adopting the Retinex algorithm, and the number of pixels participating in the Hough transform can be reduced by adopting the method based on row scanning line processing, thereby reducing the amount of calculation.

优选的,所述采用单尺度Retinex算法对原始图像进行光照处理的步骤是:Preferably, the step of using the single-scale Retinex algorithm to perform illumination processing on the original image is:

r(x,y)=logR(x,y)r(x,y)=logR(x,y)

== ll oo gg ii (( xx ,, ythe y )) LL (( xx ,, ythe y )) ;;

≈logi(x,y)-log(F(x,y)*i(x,y))≈logi(x,y)-log(F(x,y)*i(x,y))

其中,r(x,y)为单尺度Retinex算法处理后的图像,F(x,y)=λexp(-(x2+y2)/σ2),∫∫F(x,y)dxdy=1,为一高斯函数,i(x,y)为图像位置(x,y)处的灰度值,R(x,y)、L(x,y)分别为图像在点(x,y)处的反射分量与光照分量。Among them, r(x,y) is the image processed by single-scale Retinex algorithm, F(x,y)=λexp(-(x 2 +y 2 )/σ 2 ), ∫∫F(x,y)dxdy= 1, is a Gaussian function, i(x,y) is the gray value at the image position (x,y), R(x,y), L(x,y) are the image at point (x,y) The reflection component and the illumination component at .

优选的,所述图像二值化采用最大类间方差法(OTSU)。Preferably, the image binarization adopts the method of maximum between-class variance (OTSU).

优选的,在图像二值化后还进行如下操作:进行形态学处理,把断点的指针连起来,然后进行连通域分析,当连通域外接矩形的长宽小于一定阈值时,设置该连通域为背景部分,滤除仪表上的数字、符号、文字。从而在进行指针识别前尽量滤除掉不相关的数据,进一步降低后续算法计算量,提高处理速度。Preferably, the following operations are performed after image binarization: perform morphological processing, connect the pointers of the breakpoints, and then perform connected domain analysis. When the length and width of the bounding rectangle of the connected domain are less than a certain threshold, set the connected domain As the background part, the numbers, symbols and text on the instrument are filtered out. In this way, irrelevant data is filtered out as much as possible before pointer recognition, which further reduces the calculation amount of subsequent algorithms and improves the processing speed.

优选的,基于行扫描线处理的方法提取出特征像素点,具体步骤如下:Preferably, feature pixel points are extracted based on the method of row scanning line processing, and the specific steps are as follows:

(1-1)定义二值图像大小为h×w,初始化变量i=0,集合,前景像素点值为1;根据图像分辨率,计算出指针线宽度方向所占的像素个数lzhizhen(1-1) Define binary image size as h×w, initialize variable i=0, set , the value of the foreground pixel is 1; according to the image resolution, calculate the number of pixels l zhizhen occupied by the width direction of the pointer line;

(1-2)扫描图像中第i行像素,i∈[1,2,3...h],将其中连续的前景像素点看成一线段,设共有k段,将它们标记为bj,j=1,2,3...k,并将每段的像素个数记为lj,lj∈[1,2,3...w];(1-2) Scan the i-th row of pixels in the image, i∈[1,2,3...h], regard the continuous foreground pixels as a line segment, set a total of k segments, and mark them as b j , j=1,2,3...k, and record the number of pixels in each segment as l j ,l j ∈[1,2,3...w];

(1-3)将每段的像素个数lj与lzhizhen比较,若lj≤lzhizhen,则将第j段的线段中点在原二值图像中的坐标保存到集合H中;(1-3) Compare the number of pixels l j of each segment with l zhizhen , if l j ≤ l zhizhen , save the coordinates of the midpoint of the line segment j in the original binary image to the set H;

(1-4)判断i是否等于h,如果否,则令i=i+1,返回步骤(1-2),否则对集合H中的坐标进行Hough变换检测直线。(1-4) Determine whether i is equal to h, if not, set i=i+1, and return to step (1-2), otherwise, perform Hough transform on the coordinates in the set H to detect a straight line.

采用这种行扫描线处理的方法可以去除非指针部分的前景块,例如光照不均匀或存在遮挡阴影时造成的大面积前景块。仅保留符合指针线宽的线段中点作为直线检测的前景点,扫描处理既简单又快速。经上述算法处理后,进行Hough变换的前景像素点数大大减少,进而提高了直线的检测速度。The foreground block of the non-pointer part can be removed by adopting the row scanning line processing method, such as a large-area foreground block caused by uneven illumination or occlusion shadows. Only the midpoint of the line segment that conforms to the pointer line width is reserved as the foreground point for line detection, and the scanning process is simple and fast. After being processed by the above algorithm, the number of foreground pixels for Hough transform is greatly reduced, thereby improving the detection speed of straight lines.

更进一步的,所述步骤(1-4)中,设定n表示扫描线处理的行列间隔数,在扫描完第i行后,接着扫描i+n行。通过设定n可以调节直线检测速度,n越大,Hough变换所需时间越少,也即直线检测速度越快,因此可进一步提高算法的计算速度。Furthermore, in the step (1-4), n is set to represent the number of row and column intervals for scanning line processing, and after the i-th row is scanned, i+n rows are scanned next. The straight line detection speed can be adjusted by setting n. The larger n is, the less time is required for the Hough transformation, that is, the faster the straight line detection speed, so the calculation speed of the algorithm can be further improved.

优选的,采用角度法计算读数的步骤是:Preferably, the steps of using the angle method to calculate the reading are:

(2-1)设指针量程为[a,b],指针是从左边向右边摆动,最小刻度处夹角为θ1,最大刻度处为θ2,Z为仪表测量读数值,ε为当前指针与x轴负方向夹角,以指针摆动时所绕的点为坐标中心建立一xoy坐标系;(2-1) Set the range of the pointer as [a, b], the pointer swings from left to right, the angle between the smallest scale is θ 1 , the largest scale is θ 2 , Z is the reading value of the instrument, ε is the current pointer The included angle with the negative direction of the x-axis, and an xoy coordinate system is established with the point around which the pointer swings as the coordinate center;

(2-2)对刻度均匀的仪表,存在比例式:(2-2) For instruments with uniform scale, there is a proportional formula:

ϵϵ -- θθ 11 θθ 22 -- θθ 11 == ZZ -- aa bb -- aa ;;

故读数 Z = ϵ - θ 1 θ 2 - θ 1 · ( b - a ) + a . Therefore reading Z = ϵ - θ 1 θ 2 - θ 1 · ( b - a ) + a .

本发明与现有技术相比,具有如下优点和有益效果:Compared with the prior art, the present invention has the following advantages and beneficial effects:

1、本发明采用单尺度Retinex算法对指针图像进行预处理,使得自动读数算法不受变化光照影响,在光线暗淡或镜片反光的情况下,同样能得到良好的识别效果,而且识别速度快,完全满足实时性要求。1. The present invention uses a single-scale Retinex algorithm to preprocess the pointer image, so that the automatic reading algorithm is not affected by changing illumination. In the case of dim light or mirror reflection, it can also obtain good recognition effect, and the recognition speed is fast, completely Meet real-time requirements.

2、本发明利用连通域分析与扫描线处理等方法来减少Hough变换的前景点数,快速抽取进行Hough变换的特征像素点,减少参与Hough变换的像素点数,创新性地将指针图像细化、离散化与Hough变换等相结合,大大减少了指针检测时间。同时读取速度可调节,使得指针直线检测速度可比传统的算法快10倍以上,非常具有实用价值。2. The present invention uses methods such as connected domain analysis and scan line processing to reduce the number of foreground points in Hough transform, quickly extract feature pixels for Hough transform, reduce the number of pixels participating in Hough transform, and innovatively refine and discrete the pointer image Combined with Hough transform, etc., the pointer detection time is greatly reduced. At the same time, the reading speed can be adjusted, so that the detection speed of the pointer line can be more than 10 times faster than the traditional algorithm, which is very practical.

附图说明Description of drawings

图1为本发明方法的流程图。Fig. 1 is the flowchart of the method of the present invention.

图2(a)为光照处理前的指针图像。Figure 2(a) is the pointer image before lighting processing.

图2(b)为采用单尺度Retinex算法进行预处理后的效果图像。Figure 2(b) is the effect image after preprocessing with the single-scale Retinex algorithm.

图3为直线条结构示意图。Figure 3 is a schematic diagram of the structure of a straight line.

图4为根据直线条结构得到的几何关系示意图。Fig. 4 is a schematic diagram of the geometric relationship obtained according to the straight line structure.

图5为本实施例对一行像素的像素灰度值进行扫描处理的原理图。FIG. 5 is a schematic diagram of scanning processing of pixel gray values of a row of pixels in this embodiment.

图6(a)为一指针二值图像。Figure 6(a) is a binary image of a pointer.

图6(b)为对图6(a)所示二值图像进行所有行扫描处理后的结构图。FIG. 6( b ) is a structure diagram after performing all row scanning processing on the binary image shown in FIG. 6( a ).

图7(a)为一直线检测示例图。Figure 7(a) is an example diagram of a straight line detection.

图7(b)—(d)分别为针对图7(a),当n=1,5,10时,二值图像经扫描处理后对应参数空间中小格计数变量值的分布图。Figures 7(b)-(d) are respectively for Figure 7(a), when n=1, 5, 10, the binary image is scanned and processed, corresponding to the distribution diagram of the small grid count variable value in the parameter space.

图8为本实施例根据仪表建立的坐标系示意图。Fig. 8 is a schematic diagram of the coordinate system established according to the instrument in this embodiment.

图9为采用不同预处理方法所得效果图。Figure 9 is the effect diagram obtained by using different pretreatment methods.

图10为一指针检测速度测试图像。Fig. 10 is a pointer detection speed test image.

具体实施方式detailed description

下面结合实施例及附图对本发明作进一步详细的描述,但本发明的实施方式不限于此。The present invention will be further described in detail below in conjunction with the embodiments and the accompanying drawings, but the embodiments of the present invention are not limited thereto.

实施例1Example 1

参见图1,本实施例一种基于扫描线处理的指针式仪表自动读数方法,主要可分为两大部分,第一个部分是指针图像预处理,第二个部分是指针检测与读数,下面结合附图对每一部分涉及的方法进行具体说明。Referring to Fig. 1, a method for automatic reading of pointer instruments based on scanning line processing in this embodiment can be mainly divided into two parts, the first part is pointer image preprocessing, and the second part is pointer detection and reading, as follows The methods involved in each part are described in detail with reference to the accompanying drawings.

1、指针图像预处理1. Pointer image preprocessing

在图像采集过程中,由于环境光照不均匀(比如受到外物的遮挡)或仪器自身玻璃镜片造成的局部反光等现象,采集到的图像亮度也将会不均衡,会严重影响到后面对图像的准确分割。本实施例采用单尺度Retinex算法对原始图像进行光照处理,接着将图像二值化,然后进行形态学处理,把断点的指针连起来,最后进行连通域分析,滤除仪表上的数字、符号、文字。During the image acquisition process, due to uneven ambient light (such as being blocked by foreign objects) or local reflections caused by the glass lens of the instrument itself, the brightness of the collected image will also be uneven, which will seriously affect the subsequent images. accurate segmentation. This embodiment uses the single-scale Retinex algorithm to perform illumination processing on the original image, then binarizes the image, then performs morphological processing, connects the pointers of breakpoints, and finally performs connected domain analysis to filter out numbers and symbols on the instrument ,Word.

1.1采用单尺度Retinex算法进行光照处理1.1 Using single-scale Retinex algorithm for lighting processing

假设仪表图像中点(x,y)处的像素灰度值为i(x,y),根据郎伯光照模型,有Assuming that the gray value of the pixel at point (x, y) in the meter image is i(x, y), according to the Lambertian illumination model, there is

i(x,y)=R(x,y)·L(x,y)(1)i(x,y)=R(x,y) L(x,y)(1)

其中R(x,y)和L(x,y)分别是图像在点(x,y)处的反射分量和光照分量。由于光照分量L(x,y)属于图像低频成分,并且变化缓慢,通常认为是平滑的,即where R(x,y) and L(x,y) are the reflection component and illumination component of the image at point (x,y), respectively. Since the illumination component L(x,y) belongs to the low-frequency component of the image and changes slowly, it is generally considered smooth, that is

L(x+Δx,y)≈L(x,y)(2)L(x+Δx,y)≈L(x,y)(2)

L(x,y+Δy)≈L(x,y)(3)L(x,y+Δy)≈L(x,y)(3)

由Retinex理论可知,入射光与反射物体是构成人眼成像的两大主要因素,而光照部分属于低频部分,反射部分为高频部分,两者乘积即为人眼成像感知的图像亮度,如公式(1)所示。可用低频滤波技术对图像进行滤波估计低频分量L(x,y),即L(x,y)≈F(x,y)*i(x,y)。故单尺度Retinex算法可用下面式子表示:According to the Retinex theory, the incident light and the reflected object are the two main factors that constitute the imaging of the human eye, while the illumination part belongs to the low frequency part, and the reflection part belongs to the high frequency part. The product of the two is the image brightness perceived by the human eye imaging, such as the formula ( 1) as shown. The low-frequency component L(x,y) can be estimated by filtering the image with low-frequency filtering technology, that is, L(x,y)≈F(x,y)*i(x,y). Therefore, the single-scale Retinex algorithm can be expressed by the following formula:

r(x,y)=logR(x,y)r(x,y)=logR(x,y)

== ll oo gg ii (( xx ,, ythe y )) LL (( xx ,, ythe y )) -- -- -- (( 44 ))

≈logi(x,y)-log(F(x,y)*i(x,y))≈logi(x,y)-log(F(x,y)*i(x,y))

其中F(x,y)=λexp(-(x2+y2)/σ2),∫∫F(x,y)dxdy=1。F(x,y)为环境函数,这里选用高斯函数作为环境函数,i(x,y)为图像位置(x,y)的灰度值,R(x,y)、L(x,y)分别为反射分量与光照分量;r(x,y)为单尺度Retinex算法处理后的图像。由上式可知处理后的图像为反射分量的对数形式,与光照分量无关,因此,得到的图像具有光照表述不变特征。针对图2(a)的原始图像,采用单尺度Retinex算法进行预处理后的效果如图2(b)所示。Where F(x,y)=λexp(−(x 2 +y 2 )/σ 2 ), ∫∫F(x,y)dxdy=1. F(x,y) is the environmental function, here we choose Gaussian function as the environmental function, i(x,y) is the gray value of the image position (x,y), R(x,y), L(x,y) are the reflection component and the illumination component respectively; r(x, y) is the image processed by the single-scale Retinex algorithm. It can be seen from the above formula that the processed image is the logarithmic form of the reflection component, which has nothing to do with the illumination component, so the obtained image has the characteristics of illumination expression invariance. For the original image in Figure 2(a), the effect after preprocessing with the single-scale Retinex algorithm is shown in Figure 2(b).

1.2二值化处理1.2 Binarization processing

对光照处理后的图像进行二值化,目的是分割出指针图像。OTSU法是最常用的自适应二值化技术,其基本思想是在所有灰度等级中寻找一个阈值,该阈值能将图像划分为方差最大的前景与背景两部分。Binarization is performed on the image after illumination processing, and the purpose is to segment the pointer image. The OTSU method is the most commonly used adaptive binarization technology. Its basic idea is to find a threshold in all gray levels, which can divide the image into two parts, the foreground and the background with the largest variance.

假设灰度值t为前景与背景的分割阈值,前景点数占图像比例为ω0,平均灰度为μ0;背景点数占图像比例为ω1,平均灰度为μ1。则图像的总平均灰度为μ和前景和背景图象的方差g分别如(5),(6)式所示:Assuming that the gray value t is the threshold for foreground and background segmentation, the proportion of foreground points in the image is ω 0 , and the average gray level is μ 0 ; the proportion of background points in the image is ω 1 , and the average gray level is μ 1 . Then the total average gray level of the image is μ and the variance g of the foreground and background images is shown in (5) and (6) respectively:

μ=ω0·μ01·μ1(5)μ=ω 0 ·μ 01 ·μ 1 (5)

g=ω0·(μ0-μ)21·(μ1-μ)2(6)g=ω 0 ·(μ 0 -μ) 21 ·(μ 1 -μ) 2 (6)

当(6)式中的g取得最大值时,对应的分割阈值t即为OTSU法所寻找的阈值。When g in formula (6) attains the maximum value, the corresponding segmentation threshold t is the threshold value sought by the OTSU method.

1.3连通域分析1.3 Connected domain analysis

采用OTSU法对图像二值化后,先进行形态学处理,把断点的指针连起来,然后进行连通域分析,当连通域外接矩形的长宽小于一定阈值时,设置该连通域为背景部分,滤除仪表上的数字、符号、文字等。After using the OTSU method to binarize the image, first perform morphological processing, connect the pointers of the breakpoints, and then perform connected domain analysis. When the length and width of the bounding rectangle of the connected domain are less than a certain threshold, set the connected domain as the background part , to filter out numbers, symbols, text, etc. on the meter.

2、指针检测与读数2. Pointer detection and reading

本实施例基于行扫描线处理的方法提取出特征像素点,对特征像素点进行Hough变换检测指针直线,最后采用角度法计算读数。上述二值化处理已将仪表图像分割为前景部分与背景部分,前景部分为指针候选部分,而对指针的检测实质上是对前景图像的直线检测。Hough变换在仪表指针检测具有广泛应用,本文根据其检测原理,提出一种基于扫描线处理的快速检测仪表图像指针方法。In this embodiment, feature pixels are extracted based on the method of row scanning line processing, Hough transform is performed on the feature pixels to detect the pointer straight line, and finally the angle method is used to calculate the reading. The above binarization process has divided the instrument image into foreground part and background part, the foreground part is the pointer candidate part, and the detection of the pointer is essentially the straight line detection of the foreground image. Hough transform is widely used in instrument pointer detection. According to its detection principle, this paper proposes a fast detection method of instrument image pointer based on scan line processing.

2.1Hough变换检测直线原理2.1 Hough transform detection line principle

Hough变换的基本思想是点线的对偶性,即将图像空间中的问题转换到参数空间来解决。直线的参数方程:The basic idea of Hough transform is the duality of point and line, that is, the problem in the image space is converted to the parameter space to solve it. The parametric equation of the line:

ρ=x·cosθ+y·sinθ(7)ρ=x·cosθ+y·sinθ(7)

在参数空间中,x,y为常数(这里仅讨论不同时为0的情况),(7)式可变为In the parameter space, x and y are constants (here only the case of not being 0 at the same time is discussed), and the formula (7) can be changed to

ρρ == xx 22 ++ ythe y 22 ·&Center Dot; (( xx xx 22 ++ ythe y 22 ·&Center Dot; coscos θθ ++ ythe y xx 22 ++ ythe y 22 ·&Center Dot; sinsin θθ )) == xx 22 ++ ythe y 22 ·· sinsin (( sinsin φφ ·· coscos θθ ++ coscos φφ ·&Center Dot; sinsin θθ )) == xx 22 ++ ythe y 22 ·· sinsin (( φφ ++ θθ )) -- -- -- (( 88 ))

其中 in

由(7)(8)式可知,图像空间中的点(x,y)与θ-ρ空间的正弦曲线对应,θ-ρ空间的点对应图像空间中的直线。故容易得到检测直线方法:在θ-ρ空间中将按一定步长分为许多小格(w,h分别为图片的宽和高),每个小格分配一个计数变量,每次正弦曲线经过小格时,相应小格计数变量的值加1,小格计数变量的值对应着图像空间共线像素点的数目,将计数变量值大于一定阈值的小格中心坐标(θ,ρ)中的θ,ρ代入(7)式,即可得到x-y空间直线方程,该直线便是所寻找的直线。It can be known from (7) (8) that the point (x, y) in the image space corresponds to the sinusoidal curve in the θ-ρ space, and the point in the θ-ρ space corresponds to the straight line in the image space. Therefore, it is easy to obtain the detection line method: in the θ-ρ space, the According to a certain step length, it is divided into many small grids (w, h are the width and height of the picture respectively), each small grid is assigned a count variable, and each time the sinusoidal curve passes through the small grid, the value of the corresponding small grid count variable is increased by 1, The value of the small grid count variable corresponds to the number of collinear pixels in the image space, and the θ, ρ in the small grid center coordinates (θ, ρ) whose count variable value is greater than a certain threshold are substituted into (7) to obtain the xy space The equation of the line that is the line you are looking for.

2.2基于行扫描线处理的方法提取出特征像素点2.2 Extract feature pixels based on row scan line processing method

由2.1小节可知,Hough变换检测直线本身计算量就相当大,且计算量随着变换的像素点数增加而呈线性增加,所以,减少进行Hough变换的像素点数,是提高检测直线的有效方法。本发明方法通过对图像进行行扫描处理,将指针宽度范围内的线段中点作为直线检测的前景点,快速减少参与Hough变换的像素点数,从而降低计算量。From Section 2.1, it can be seen that the calculation amount of the Hough transform detection line itself is quite large, and the calculation amount increases linearly with the increase of the number of transformed pixels. Therefore, reducing the number of pixels for Hough transform is an effective method to improve the detection of straight lines. The method of the invention performs row scanning processing on the image, uses the midpoint of the line segment within the pointer width range as the foreground point of line detection, and rapidly reduces the number of pixels participating in the Hough transformation, thereby reducing the amount of calculation.

为了便于描述原理,下面对一些概念作以下定义:In order to facilitate the description of the principle, some concepts are defined as follows:

定义:将具有宽度(非单像素宽)的直线段称为直线条,直线条两侧的单像素宽边缘直线称为直线条边缘直线,到两边缘直线距离相等的点称为直线条的特征点,特征点组成的直线称为直线条的特征直线。直线条结构如图3所示。图中1表示边缘直线,2表示特征点,3表示特征直线。由图3可知,同一直线条的两边缘直线互相平行,特征直线是期望找到的直线,特征点便是选为进行Hough变换的特征点。对于特征点,可通过以下定理确定。Definition: A straight line segment with a width (not a single pixel width) is called a straight line, a single-pixel wide edge line on both sides of the straight line is called a straight line edge line, and a point with the same distance from the two edge lines is called a feature of a straight line Points, and the line formed by the feature points is called the feature line of the line bar. The straight line structure is shown in Figure 3. In the figure, 1 represents the edge line, 2 represents the feature point, and 3 represents the feature line. It can be seen from Figure 3 that the two edge lines of the same straight line are parallel to each other, the feature line is the line expected to be found, and the feature points are selected as the feature points for Hough transformation. For feature points, it can be determined by the following theorem.

定理1:假设一直线条的两边缘直线l1,l2与一水平线(或一垂直线)交于A,B两点,过A,B两点连线的线段中点O作一垂直线(或一水平线),并与直线l1,l2分别交于C,D,则点O同时也是C,D两点连线的中点,并且点O为位于直线条的特征直线上的特征点。Theorem 1: Assume that the two edge straight lines l 1 , l 2 of a straight line intersect with a horizontal line (or a vertical line) at two points A and B, and a vertical line ( or a horizontal line), and intersect with straight line l 1 , l 2 at C and D respectively, then point O is also the midpoint of the line connecting C and D, and point O is a feature point located on the feature line of the straight line .

证明:已知条件如图4所示。因为同一直线条的两边缘直线l1,l2平行,∠OCA与∠ODB为它们的内错角,故有:Proof: The known conditions are shown in Figure 4. Because the two edge lines l 1 and l 2 of the same straight line are parallel, ∠OCA and ∠ODB are their internal alternate angles, so:

∠OCA=∠ODB(9)∠OCA=∠ODB(9)

又直线AB与直线CD互相垂直,O为线段AB的中点,故有下式成立:The straight line AB and the straight line CD are perpendicular to each other, and O is the midpoint of the line segment AB, so the following formula holds:

∠AOC=∠BOD=π/2(10)∠AOC=∠BOD=π/2(10)

AO=BO(11)AO=BO(11)

到两全等直角三角形:To two congruent right triangles:

ΔAOCΔ AOC ≅≅ ΔBODΔBOD (( 1212 ))

由(12)式得:OC=OD,点O到AC距离与O到BD距离相等。根据定义,点O为线段CD中点,也是直线条的特征点,位于直线条的特征直线上。证毕From (12) formula: OC=OD, the distance from point O to AC is equal to the distance from O to BD. According to the definition, the point O is the midpoint of the line segment CD, which is also the characteristic point of the straight line, and is located on the characteristic straight line of the straight line. Certificate completed

本实施例所用仪表指针与x轴负方向夹角在45°与135°范围内,故本发明采用行扫描处理。对于一行像素的像素灰度值进行扫描处理的原理如图5所示。图5中像素灰度值为1的像素点是前景点,否则是背景点,x,y分别表示像素位置与像素灰度值。中间的前景部分宽度过大,不在指针宽度范围内,另两侧的前景像素宽度在指针宽度范围内,扫描线处理后只提取中间像素点作为Hough变换像素点。对图6(a)所示的二值图像进行所有行扫描处理后的结果如图6(b)所示。从图6中可以看出,这种扫描线处理算法可以将非指针部分的前景块去除,例如光照不均匀或存在遮挡阴影时造成的大面积前景块。另外,仅保留符合指针线宽的线段中点作为直线检测的前景点,扫描处理既简单又快速。经所提算法处理后,进行Hough变换的前景像素点数大大减少,进而提高了直线的检测速度。The included angle between the pointer of the meter used in this embodiment and the negative direction of the x-axis is within the range of 45° and 135°, so the present invention adopts row scanning processing. The principle of scanning the pixel gray value of a row of pixels is shown in FIG. 5 . In Figure 5, the pixel with a pixel gray value of 1 is the foreground point, otherwise it is the background point, and x and y represent the pixel position and pixel gray value respectively. The width of the foreground part in the middle is too large and is not within the range of the pointer width, and the width of the foreground pixels on the other two sides is within the range of the pointer width. After scanning line processing, only the middle pixels are extracted as Hough transform pixels. Figure 6(b) shows the result after all line scanning processing of the binary image shown in Figure 6(a). It can be seen from FIG. 6 that this scanline processing algorithm can remove non-pointer foreground blocks, such as large-area foreground blocks caused by uneven illumination or occlusion shadows. In addition, only the midpoint of the line segment conforming to the line width of the pointer is reserved as the foreground point for line detection, and the scanning process is simple and fast. After being processed by the proposed algorithm, the number of foreground pixels for Hough transform is greatly reduced, thereby improving the detection speed of straight lines.

2.3直线检测速度的控制2.3 Control of linear detection speed

由Hough检测直线原理知道:图像空间的直线参数是在参数空间中通过比较小格上的计数值大小求得的。可以设想一下,如果参数空间中所有小格计数变量值同时减小相同数值,这并不改变它们的大小关系,那么返回计数值最大的小格所对应的参数ρ,θ是不变的,也即映射到图像空间为同一直线。According to the principle of Hough detection of straight lines, it is known that the parameters of the straight line in the image space are obtained by comparing the count values on the small grids in the parameter space. It can be imagined that if the values of counting variables of all the small cells in the parameter space are reduced by the same value at the same time, which does not change their size relationship, then the parameters ρ, θ corresponding to the small cell with the largest count value are returned unchanged, and also That is, they are mapped to the image space as the same straight line.

事实上,只要对二值化图像进行等间隔扫描处理,相当于同时减少参数空间中小格变量值。通过调节行扫描的间隔数来进一步改变Hough变换的像素点数,进而使得直线的检测速度可控。双阈值Hough变换实质上是选择处于指针最小角度与最大角度之间的像素进行Hough变换。基于扫描线处理的双阈值Hough变换快速检测直线算法具体步骤如下所示:In fact, as long as the binarized image is scanned at equal intervals, it is equivalent to reducing the value of the small variable in the parameter space at the same time. By adjusting the number of intervals of line scanning to further change the number of pixels of Hough transform, and then make the detection speed of the straight line controllable. The double-threshold Hough transform essentially selects the pixels between the minimum angle and the maximum angle of the pointer to perform Hough transform. The specific steps of the double-threshold Hough transform fast detection line algorithm based on scan line processing are as follows:

(1)输入大小为h×w的二值图像,初始化变量i=0,集合H=φ;根据图像分辨率,计算出指针线宽度方向所占的像素个数lzhizhen(1) Input a binary image whose size is h×w, initialize variable i=0, set H=φ; calculate the number of pixels l zhizhen occupied by the pointer line width direction according to the image resolution;

(2)扫描图像第i行像素,i∈[1,2,3...h],将连续的前景像素看成一线段,假设共有k段,将它们标记为bj,j=1,2,3...k,并将每段的像素个数记为lj,lj∈[1,2,3...w];(2) Scan the pixels in the i-th row of the image, i∈[1,2,3...h], regard the continuous foreground pixels as a line segment, assuming there are k segments in total, mark them as b j , j=1,2 ,3...k, and record the number of pixels in each segment as l j ,l j ∈[1,2,3...w];

(3)将每段的像素个数lj与lzhizhen比较,若lj≤lzhizhen,则将第j段的线段中点在原二值图像中的坐标保存到集合H中;(3) Compare the number of pixels l j in each segment with l zhizhen , if l j ≤ l zhizhen , save the coordinates of the midpoint of the line segment j in the original binary image to the set H;

(4)i=i+n,如果i<h,返回步骤(2),否则进入步骤(5);(4) i=i+n, if i<h, return to step (2), otherwise enter step (5);

(5)对集合H中的坐标进行双阈值Hough变换检测直线。(5) Perform double-threshold Hough transform on the coordinates in the set H to detect straight lines.

其中n表示扫描线处理的行列间隔数,是调节直线检测速度的参数。当n=1,5,10时,二值图像图7(a)经扫描处理后对应参数空间中小格计数变量值的分布如图7(b)、(c)、(d)所示。其中,n=1,5,10时,Hough变换确定直线参数所需时间分别为7.83ms,2.55ms,1.86ms。参数空间ρ,θ的小格步长均为1,将统计范围内的小格排成一行。从图7可以看出,小格计数变量值分布形状具有极高的相似性,扫描间隔n越大,Hough变换所需时间越少,也即直线检测速度越快,小格计数变量值同时缩小,小格计数变量最大值对应同一个小格或附近小格,这与前面分析相吻合。Among them, n represents the number of row and column intervals processed by the scan line, and is a parameter for adjusting the detection speed of a straight line. When n=1, 5, 10, the distribution of the small grid count variable value in the corresponding parameter space of the binary image Fig. 7(a) after scanning is shown in Fig. 7(b), (c), and (d). Among them, when n=1, 5, 10, the time required for the Hough transformation to determine the parameters of the straight line is 7.83ms, 2.55ms, and 1.86ms respectively. The small grid step size of parameter space ρ, θ is 1, and the small grids in the statistical range are arranged in a row. It can be seen from Figure 7 that the distribution shape of the small grid count variable values has a very high similarity. The larger the scanning interval n is, the less time is required for Hough transformation, that is, the faster the detection speed of the straight line, the smaller the small grid count variable value is at the same time. , the maximum value of the small cell count variable corresponds to the same small cell or nearby small cells, which is consistent with the previous analysis.

2.4读数计算2.4 Reading Calculation

由于Hough变换检测到直线的角度范围是0到180度,本实施例所用的仪表指针在最小刻度与最大刻度处与x轴负方向夹角为45度、135度,所以本实施例只考虑指针在这个范围内偏转。假设指针量程为[a,b],指针是从左边向右边摆动,最小刻度处夹角为θ1,最大刻度处为θ2,Z为仪表测量读数值,以指针摆动时所绕的点为坐标中心建立一xoy坐标系,如图8所示。Since the angle range of the straight line detected by the Hough transform is 0 to 180 degrees, the angles between the minimum scale and the maximum scale of the instrument pointer used in this embodiment and the negative direction of the x-axis are 45 degrees and 135 degrees, so this embodiment only considers the pointer deflect within this range. Suppose the range of the pointer is [a,b], the pointer swings from left to right, the angle between the minimum scale is θ 1 , and the maximum scale is θ 2 , Z is the reading value of the meter, and the point around which the pointer swings is An xoy coordinate system is established for the coordinate center, as shown in Fig. 8 .

对刻度均匀的仪表,由图7得比例式:For an instrument with uniform scale, the proportional formula can be obtained from Figure 7:

&epsiv;&epsiv; -- &theta;&theta; 11 &theta;&theta; 22 -- &theta;&theta; 11 == ZZ -- aa bb -- aa -- -- -- (( 1313 ))

故读数 Z = &epsiv; - &theta; 1 &theta; 2 - &theta; 1 &CenterDot; ( b - a ) + a - - - ( 14 ) Therefore reading Z = &epsiv; - &theta; 1 &theta; 2 - &theta; 1 &Center Dot; ( b - a ) + a - - - ( 14 )

3、与现有技术3. Compared with existing technology

为验证本发明方法对光照鲁棒性,选取处理速度较快的经典直方图均衡化、灰度变换与本发明方法作对比;为验证指针检测速度效果,选canny算子和骨架提取方法与本发明方法作对比。In order to verify the robustness of the method of the present invention to illumination, the classic histogram equalization and grayscale transformation with faster processing speed are selected for comparison with the method of the present invention; in order to verify the effect of pointer detection speed, the canny operator and skeleton extraction method are selected to be compared with the method of the present invention Invented method for comparison.

本实验都是在Pentium(R)Dual-CoreCPUE58003.2GHz内存1.96GB,VS2010+Opencv4.8环境下进行的。This experiment is carried out in Pentium(R)Dual-CoreCPUE58003.2GHz memory 1.96GB, VS2010+Opencv4.8 environment.

实验过程中保证能检测到指针为前提,参数均经测试后选取较优的参数,骨架提取也即细化技术,选用T.Y.zhang等在论文《Afastparallelalgorithmforthinningdigitalpatterns》中提出的并行快速细化算法,灰度变换选用对数变换y=log(i+1)/b+a,i为像素灰度值,取a=10,b=0.3。其中本文取Hough变换的小格θ∈[0°,180°)的步长为1°,ρ的步长为像素单位1;Retinex中的低通滤波器的参数σ=2.5,指针图像宽度阈值为10个像素宽度。During the experiment, it is the premise that the pointer can be detected. After the parameters are tested, the better parameters are selected. The skeleton extraction is the thinning technology. The parallel fast thinning algorithm proposed by T.Y.zhang et al. in the paper "Afastparallelalgorithmforthinningdigitalpatterns" The transformation uses the logarithmic transformation y=log(i+1)/b+a, i is the gray value of the pixel, a=10, b=0.3. Among them, in this paper, the step size of the small lattice θ∈[0°,180°) of the Hough transform is 1°, and the step size of ρ is 1 pixel unit; the parameter σ=2.5 of the low-pass filter in Retinex, the pointer image width threshold is 10 pixels wide.

3.1光照鲁棒性验证3.1 Illumination robustness verification

采用3种不同光照处理方法对3种不同环境下获得的图像处理结果如图9所示。由图9可以看出,直方图均衡化处理效果最差,对数变换虽然能进行灰度动态压缩,但处理对比度较大的光照区域并不理想,处理后遮挡与非遮挡区域依然存在明显的对比度,不利于指针图像的准确提取。本发明提出的单尺度Retinex方法可以很好的处理阴影部分,实现图像增强,减少阴影部分与非阴影部分的灰度等级差,从而消去了光照影响。The image processing results obtained in three different environments using three different lighting processing methods are shown in Figure 9. It can be seen from Figure 9 that the histogram equalization processing effect is the worst. Although the logarithmic transformation can perform grayscale dynamic compression, it is not ideal to deal with the illuminated areas with high contrast. After processing, there are still obvious differences between occluded and non-occluded areas. The contrast is not conducive to the accurate extraction of the pointer image. The single-scale Retinex method proposed by the present invention can handle the shadow part well, realize image enhancement, reduce the gray scale difference between the shadow part and the non-shadow part, thereby eliminating the influence of light.

将发明算法计算结果与人工目测所得结果进行比对,可得到表1所示的部分实验数据:Comparing the calculated results of the invented algorithm with the results obtained by manual visual inspection, some experimental data shown in Table 1 can be obtained:

表1发明算法计算结果与人工目测所得结果数据Table 1 Invention Algorithm Calculation Results and Manual Visual Inspection Results Data

目测visual inspection 读数值reading value 误差error 7373 73.50073.500 0.5000.500 101101 101.277101.277 0.2770.277 108108 108.222108.222 0.2220.222 172172 171.722171.722 0.2880.288 190190 190.166190.166 0.1660.166

其中目测值中最后一位数是人为估计值,由表1可以看出,本发明对指针的定位和读数均非常准确,可见所用算法对光照具有相当好的鲁棒性。Wherein the last digit in the visual value is an artificial estimated value. It can be seen from Table 1 that the present invention is very accurate in positioning and reading of the pointer, and it can be seen that the algorithm used has quite good robustness to illumination.

3.2读数速度比较3.2 Comparison of reading speed

将仪表图像去除光照变化影响后,将其进行二值化处理,为了减少进行Hough变换的像素点,将本发明所述基于线扫描处理的算法与并行快速细化算法、Canny算法分别对二值图像处理,对读数所需时间进行比较。假设经预处理后的二值图像如图10所示,大小为640×253,测试不同算法提取Hough变换特征点开始到确认直线参数所用时间,测试结果如表2所示,其中n为扫描间隔。After the instrument image is removed from the influence of illumination changes, it is subjected to binarization processing. In order to reduce the pixels for Hough transformation, the algorithm based on the line scan processing described in the present invention, the parallel fast thinning algorithm, and the Canny algorithm are respectively used for binarization. Image processing to compare the time required for reading. Assuming that the preprocessed binary image is shown in Figure 10, with a size of 640×253, test the time taken by different algorithms to extract Hough transform feature points and confirm the parameters of the straight line. The test results are shown in Table 2, where n is the scan interval .

表2不同处理方法读数时间(单位:ms)Table 2 Reading time of different processing methods (unit: ms)

从表2可得出,本发明所述的扫描线处理时间最短,扫描间隔n越大,检测时间越短,n=10时检测速度为Canny算子的15倍、经典细化算法的11倍。这里Canny算子、经典细化算法与本发明所述算法的目的均是为了减少进行Hough变换像素点数。本发明所述算法提取Hough变换像素点,过程简单,运算量少;而细化则是对二维图像的细化,Canny算子是常用的边缘提取算法,它们本身运算量大,选取进行Hough变换像素点数也远大于所提算法且不具有可调节性。故本发明所述算法更具优越性。It can be drawn from Table 2 that the scanning line processing time of the present invention is the shortest, the larger the scanning interval n, the shorter the detection time, and when n=10, the detection speed is 15 times that of the Canny operator and 11 times that of the classic thinning algorithm . Here, the purpose of the Canny operator, the classical thinning algorithm and the algorithm of the present invention is to reduce the number of pixels for Hough transformation. The algorithm of the present invention extracts the Hough transformation pixel points, the process is simple, and the amount of calculation is small; and the refinement is the refinement of the two-dimensional image, and the Canny operator is a commonly used edge extraction algorithm, and they themselves have a large amount of calculation. The number of transformed pixels is also much larger than the proposed algorithm and is not adjustable. Therefore, the algorithm of the present invention is more superior.

综上所述,本实施例所述方法利用单尺度Retinex消除光照影响,利用连通域分析与扫描线处理等技术来减少Hough变换的前景点数,创新性地将指针图像细化、离散化与Hough变换等思想相结合,实验证明所提的算法不但具有较好的光照鲁棒性与较高的检测速度,而且具有速度可调节等优点。To sum up, the method described in this embodiment uses single-scale Retinex to eliminate the influence of illumination, uses technologies such as connected domain analysis and scan line processing to reduce the number of foreground points in Hough transform, and innovatively refines and discretizes the pointer image with Hough The experiment proves that the proposed algorithm not only has good illumination robustness and high detection speed, but also has the advantages of adjustable speed.

上述实施例为本发明较佳的实施方式,但本发明的实施方式并不受上述实施例的限制,其他的任何未背离本发明的精神实质与原理下所作的改变、修饰、替代、组合、简化,均应为等效的置换方式,都包含在本发明的保护范围之内。The above-mentioned embodiment is a preferred embodiment of the present invention, but the embodiment of the present invention is not limited by the above-mentioned embodiment, and any other changes, modifications, substitutions, combinations, Simplifications should be equivalent replacement methods, and all are included in the protection scope of the present invention.

Claims (7)

1. the pointer instrument automatic reading method processed based on scanning line, it is characterized in that, including step: initially with single scale Retinex algorithm, original image is carried out photo-irradiation treatment, then by image binaryzation, the method being then based on horizontal scanning line process extracts feature pixel, feature pixel is carried out Hough transform detection pointer straight line, finally adopts preset angle configuration to calculate reading;The described method processed based on horizontal scanning line refers to each row in image is scanned, and extracts the continuous segment in this row, and the length of search continuous segment is less than or equal to the continuous segment of cursor line width, using the line segment midpoint of this continuous segment as feature pixel.
2. pointer instrument automatic reading method according to claim 1, it is characterised in that the step that original image is carried out photo-irradiation treatment by described employing single scale Retinex algorithm is:
r ( x , y ) = log R ( x , y ) = log i ( x , y ) L ( x , y ) &ap; log i ( x , y ) - log ( F ( x , y ) * i ( x , y ) ) ;
Wherein, r (x, the image after y) processing for single scale Retinex algorithm, F (x, y)=λ exp (-(x2+y2)/σ2), (x, y) dxdy=1, be a Gaussian function to ∫ ∫ F, (x, y) for picture position (x, y) gray value at place, R (x for i, y), L (x, y) respectively image at point (x, y) reflecting component at place and illumination component.
3. pointer instrument automatic reading method according to claim 1, it is characterised in that described image binaryzation adopts maximum variance between clusters.
4. pointer instrument automatic reading method according to claim 1, it is characterized in that, also proceed as follows after image binaryzation: carry out Morphological scale-space, the pointer of breakpoint is linked up, then connected domain analysis is carried out, when the length and width of connected domain boundary rectangle are less than certain threshold value, arranging this connected domain is background parts, filters the numeral in instrument, symbol, word.
5. pointer instrument automatic reading method according to claim 1, it is characterised in that the method processed based on horizontal scanning line extracts feature pixel, specifically comprises the following steps that
(1-1) define bianry image and be sized to h × w, initializing variable i=0, setForeground pixel point value is 1;According to image resolution ratio, calculate the number of pixels l shared by cursor line widthzhizhen
(1-2) the i-th row pixel in scanogram, i ∈ [1,2,3...h], wherein will regard a line segment as by continuous print foreground pixel point, and if total k section, they will be labeled as bj, j=1,2,3...k, and the number of pixels of every section is designated as lj,lj∈[1,2,3...w];
(1-3) by the number of pixels l of every sectionjWith lzhizhenCompare, if lj≤lzhizhen, then the line segment midpoint of jth section coordinate in former bianry image is saved in set H;
(1-4) judge that whether i is equal to h, if it is not, then make i=i+1, returns step (1-2), otherwise the coordinate in set H is carried out Hough transform detection of straight lines.
6. pointer instrument automatic reading method according to claim 5, it is characterised in that in described step (1-4), sets the n ranks space-number representing that scanning line processes, after scanning through the i-th row, and then scanning i+n row.
7. pointer instrument automatic reading method according to claim 1, it is characterised in that employing preset angle configuration calculates the step of reading and is:
(2-1) setting needle deflections as [a, b], pointer is to swing from the left side to the right, and minimum scale place angle is θ1, maximum scale place is θ2, Z is instrument measurement reading value, and ε is current pointer and x-axis negative direction angle, during with the beat of pointer around point set up an xoy coordinate system for coordinate center;
(2-2) to the uniform instrument of scale, there is proportion expression:
&epsiv; - &theta; 1 &theta; 2 - &theta; 1 = Z - a b - a ;
Therefore reading Z = &epsiv; - &theta; 1 &theta; 2 - &theta; 1 &CenterDot; ( b - a ) + a .
CN201610074160.XA 2016-02-02 2016-02-02 Scanning line processing based automatic reading method for pointer instrument Pending CN105740829A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610074160.XA CN105740829A (en) 2016-02-02 2016-02-02 Scanning line processing based automatic reading method for pointer instrument

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610074160.XA CN105740829A (en) 2016-02-02 2016-02-02 Scanning line processing based automatic reading method for pointer instrument

Publications (1)

Publication Number Publication Date
CN105740829A true CN105740829A (en) 2016-07-06

Family

ID=56245715

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610074160.XA Pending CN105740829A (en) 2016-02-02 2016-02-02 Scanning line processing based automatic reading method for pointer instrument

Country Status (1)

Country Link
CN (1) CN105740829A (en)

Cited By (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106951900A (en) * 2017-04-13 2017-07-14 杭州申昊科技股份有限公司 A kind of automatic identifying method of arrester meter reading
CN107067018A (en) * 2016-12-09 2017-08-18 南京理工大学 A kind of hot line robot bolt recognition methods based on random Hough transformation and SVM
CN107133623A (en) * 2017-05-11 2017-09-05 安徽慧视金瞳科技有限公司 A kind of pointer position accurate detecting method positioned based on background subtraction and the center of circle
CN107301412A (en) * 2017-05-08 2017-10-27 浙江工业大学 A kind of readings of pointer type meters method based on image procossing
CN107978321A (en) * 2017-11-29 2018-05-01 广州酷狗计算机科技有限公司 Audio-frequency processing method and device
CN108898632A (en) * 2018-06-13 2018-11-27 浙江大华技术股份有限公司 A kind of rotation angle of gauge pointer determines method and device
CN109146806A (en) * 2018-07-29 2019-01-04 国网上海市电力公司 Gauge pointer position detection recognition methods based on shadow removing optimization in remote monitoriong of electric power
CN109558871A (en) * 2018-10-26 2019-04-02 中国科学院长春光学精密机械与物理研究所 A kind of readings of pointer type meters recognition methods and device
CN110059529A (en) * 2017-12-13 2019-07-26 台达电子工业股份有限公司 The recognition methods and its image capturing equipment of the direction of the pointer of analog measurement device
CN110132823A (en) * 2019-05-15 2019-08-16 林伟阳 A Cell Counting Method Based on Template Matching and Finding Outlines
CN110490145A (en) * 2019-08-22 2019-11-22 国网四川省电力公司信息通信公司 A kind of readings of pointer type meters recognition methods
CN112001379A (en) * 2020-05-19 2020-11-27 西安工程大学 Correction algorithm of automobile instrument fixed viewpoint reading instrument based on machine vision
CN114549835A (en) * 2022-02-15 2022-05-27 中国人民解放军海军工程大学 Pointer instrument correction identification method and device based on deep learning
CN115331014A (en) * 2022-10-17 2022-11-11 暨南大学 Machine vision-based pointer instrument reading method and system and storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103207987A (en) * 2013-02-28 2013-07-17 华北电力大学 Indicating value identification method of dial instrument
CN103528617A (en) * 2013-09-27 2014-01-22 中国人民解放军空军工程大学 Cockpit instrument automatic recognizing and detecting method and device

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103207987A (en) * 2013-02-28 2013-07-17 华北电力大学 Indicating value identification method of dial instrument
CN103528617A (en) * 2013-09-27 2014-01-22 中国人民解放军空军工程大学 Cockpit instrument automatic recognizing and detecting method and device

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
刘迪 等: "非均匀光照下指针式仪表自动判读算法设计", 《计算机应用与软件》 *
宋伟 等: "基于指针区域特征的仪表读数识别算法", 《仪器仪表学报》 *
肖志涛 等: "基于车道线宽度滤波和抽样行扫描的车道线检测", 《河北工业大学学报》 *
陈薇 等: "改进单尺度Retinex 的光照人脸识别", 《计算机工程与应用》 *

Cited By (20)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107067018A (en) * 2016-12-09 2017-08-18 南京理工大学 A kind of hot line robot bolt recognition methods based on random Hough transformation and SVM
CN106951900A (en) * 2017-04-13 2017-07-14 杭州申昊科技股份有限公司 A kind of automatic identifying method of arrester meter reading
CN107301412A (en) * 2017-05-08 2017-10-27 浙江工业大学 A kind of readings of pointer type meters method based on image procossing
CN107301412B (en) * 2017-05-08 2019-12-17 浙江工业大学 A Reading Method of Pointer Meter Based on Image Processing
CN107133623A (en) * 2017-05-11 2017-09-05 安徽慧视金瞳科技有限公司 A kind of pointer position accurate detecting method positioned based on background subtraction and the center of circle
CN107133623B (en) * 2017-05-11 2020-03-24 安徽慧视金瞳科技有限公司 Pointer position accurate detection method based on background difference and circle center positioning
CN107978321A (en) * 2017-11-29 2018-05-01 广州酷狗计算机科技有限公司 Audio-frequency processing method and device
CN110059529A (en) * 2017-12-13 2019-07-26 台达电子工业股份有限公司 The recognition methods and its image capturing equipment of the direction of the pointer of analog measurement device
CN108898632A (en) * 2018-06-13 2018-11-27 浙江大华技术股份有限公司 A kind of rotation angle of gauge pointer determines method and device
CN108898632B (en) * 2018-06-13 2020-09-29 浙江大华技术股份有限公司 Method and device for determining rotation angle of instrument pointer
CN109146806A (en) * 2018-07-29 2019-01-04 国网上海市电力公司 Gauge pointer position detection recognition methods based on shadow removing optimization in remote monitoriong of electric power
CN109558871A (en) * 2018-10-26 2019-04-02 中国科学院长春光学精密机械与物理研究所 A kind of readings of pointer type meters recognition methods and device
CN109558871B (en) * 2018-10-26 2021-09-17 中国科学院长春光学精密机械与物理研究所 Pointer instrument reading identification method and device
CN110132823A (en) * 2019-05-15 2019-08-16 林伟阳 A Cell Counting Method Based on Template Matching and Finding Outlines
CN110490145A (en) * 2019-08-22 2019-11-22 国网四川省电力公司信息通信公司 A kind of readings of pointer type meters recognition methods
CN110490145B (en) * 2019-08-22 2021-09-17 国网四川省电力公司信息通信公司 Pointer instrument reading identification method
CN112001379A (en) * 2020-05-19 2020-11-27 西安工程大学 Correction algorithm of automobile instrument fixed viewpoint reading instrument based on machine vision
CN114549835A (en) * 2022-02-15 2022-05-27 中国人民解放军海军工程大学 Pointer instrument correction identification method and device based on deep learning
CN115331014A (en) * 2022-10-17 2022-11-11 暨南大学 Machine vision-based pointer instrument reading method and system and storage medium
CN115331014B (en) * 2022-10-17 2023-03-07 暨南大学 A machine vision-based pointer meter reading method, system, and storage medium

Similar Documents

Publication Publication Date Title
CN105740829A (en) Scanning line processing based automatic reading method for pointer instrument
CN109816644B (en) An automatic detection system for bearing defects based on multi-angle light source images
CN107045634B (en) Text positioning method based on maximum stable extremum region and stroke width
CN109839385B (en) Self-adaptive PCB defect visual positioning detection and classification system
CN103258201B (en) A kind of form lines extracting method of amalgamation of global and local message
CN106446894B (en) A method of based on outline identification ball-type target object location
CN104680130A (en) Chinese character recognition method for identification cards
CN108764229A (en) A kind of water gauge automatic distinguishing method for image based on computer vision technique
CN105067638A (en) Tire fetal-membrane surface character defect detection method based on machine vision
CN101334263A (en) Method for locating the center of a circular target
CN112233116B (en) Concave-convex mark visual detection method based on neighborhood decision and gray level co-occurrence matrix description
CN101984916A (en) Blood vessel diameter measuring method based on digital image processing technology
CN103761743A (en) Solid wood floor surface defect detecting method based on image fusion and division
Ma Defect detection and recognition of bare PCB based on computer vision
CN109540925B (en) Complex ceramic tile surface defect detection method based on difference method and local variance measurement operator
Galun et al. Multiscale edge detection and fiber enhancement using differences of oriented means
CN111476246A (en) Robust and efficient intelligent reading method for pointer instrument applied to complex environment
CN107545565A (en) A kind of solar energy half tone detection method
CN112734729A (en) Water gauge water level line image detection method and device suitable for night light supplement condition and storage medium
Wankhede et al. A low cost surface strain measurement system using image processing for sheet metal forming applications
CN112241964B (en) Light strip center extraction method for line structured light non-contact measurement
CN104408721B (en) Stamper image extracting method based on background density estimation
CN116128849A (en) Method, device, equipment and storage medium for detecting underwater cracks of concrete dam
CN104657983B (en) A kind of fabric ball top Density Detection method filtered based on Gabor
CN115170520A (en) Metal mesh defect detection method based on structure contrast information lamination

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20160706