The algorithm consists of two parts: one is scale and pointer (or liquid level) fine thinning, the other is identification and reading of scale.
3.1 Pretreatment and thinning
Since it is impossible to adopt complicated light disposition in the light system (high manufacturing cost), the optical field must be uneven. To reduce the effect of this case, a simple method is to make Bi-level of original picture.
Suppose image is
511 grey value M=8bit, i.e. 0~255. The Bi-level image is f2 (x, y), then
| (1) |
Here A is a constant, an arbitrary constant from 1 to 255. Assuming that A=100 in our system. T is threshold. There is many statistical methods to choose T. While any way need to know about distributed characteristic of f(x, y), which is impossible. Now we choose T according to the formula below:
| T=[fmax (x, y) +fmin(x, y)]/2
| (2)
|
Where fmax (x, y) and fmin (x, y) are maximum and minimum grey value of input image.
To calculate distance between the two adjacent graduation that the pointer position or, the Bi-level picture f2 (x, y) must be thinning. Thinning algorithm is:
| (3) |
Where Xm =(Xi +Xf )/2, Ym=(Yi+Yf)/2
Xi and Yi are initial position of line width
Xf and Yf are final position of line width.
Note that line width designation refers to that all the continuous pixels are A grey value.
Taking hair hygrometer for example, its Bi-level and thinning process image is shown as fig.2. Where fig.2(b) express Bi-level picture, fig.2(a) is thinning picture.
| (a)
| (b)
|
|
Fig 2: preprocess and thinning image of hair hygrometer
| |
3.2 Reading algorithm of scale
According to type of scale on the meter dial: circle, half-circle and line, we first seek for centerline of scale distribution position in order to look for scale line along with the center line. Then length of integer scale is two times of 0.1 scale; while length of 0.5 scale is 2/3 of the length of integer scale, discriminate the position of scale, at last according to position of pointer to recognize and read data.
Next we discuss description of scale centerline (circle or half circle meter dial).
First step, determine the direction of pointer and origin of pointer.
Fig 3: scales and center line
|
Second step, seek and identify scale like integer scale, 0.1 scale, and 0.5 scale near the pointer.
Third step, draw a circle (or arc) and the radius equals the distance from 0.1 time scale circle (or arc) to pointer the centerline of scale.
When the distribution of scale is easy to draw. Here we don't discuss it any more.
Scales of partial arc and centerline are shown as fig.3 Dot-and-dash lines in fig.3 express rays relation of the scales.
Data reading process consist of two steps. First step is identification of marked figures which is nearest from the pointer from the pointer. Second step is according to the position where pointer is on the center to calculate arc length of the marked figures which is integer times scale.
Identification of marked figure is realized by means of matching and rotating method. Since arrangement of figures on meter dial and rays from origin point are in parallel, sample figures(0,1,2,3,4,5,6,7,8,9,) must be rotated a certain angle a, meanwhile enlarging or scaling down a certain times b. Then it will match with figures on meter dial. Matching degree of single figure reach 90%, that means matching successfully. The process on general is as follows:
First, suppose i=0, j=0, j =0, a=0, Da=0, b=0, Db=0.
Second, choose sample figure corresponding to i and rotate it with a small angle a=a+Da, j2 =j1
Third, calculate its matching degree with figure on the dial, j1 is matching degree. If j1<j2 then j2=j2; if a<10°then return to second, or j2=j1, a=0.
Fourth, enlarge sample figures corresponding with i, b=b+Db then matching with figures on the dial to calculate the matching degree, j1 . If j1<j2 ,a<10°return to second.
Fifth, i=i+1, return to second.
Sixth, identify i, end.
Note that the type of sample figures 0~9 must be corresponding with that of figures on the dial. If not, it is necessary to remind a reserve when calculates the matching degree.