4.4. TUBE LOCALIZATION 71 but also over the whole image width or locally within a single image. The first case is uncritical as long as there is a sufficient contrast between a tube and the background. The later case, i.e. local variations in background brightness, can lead to failures of the global threshold. Figure 4.15(a) shows one characteristic situation which occurs quite often with transparent tubes. The background intensity on the left is much darker compared to the right. The global threshold fails, since the much brighter background regions on the right increase the global mean. Thus, the local median of the most left segment falls below the threshold and is therefore classified as foreground. Due to this misclassification no measuring will be performed on this frame, although it would be possible. A region based threshold can overcome this problem. The idea is to compute the classification threshold not globally, but on regional image brightness. While the local median is computed for each segment, a good classification threshold must consider at least one transition between background and foreground. Following the assumptions made in Section 4.2, two tubes can not be completely in the image at one time. Furthermore, the number of connected background regions in the image can not exceed two. If there are two connected background regions, one has to lie in the left half of the image while the other falls in the right half. Thus, one can define two regions, left and right of the image center respectively, and compute the mean for each region as analogue to the global mean. Inthefollowing,themeanoftheleftandrightsideofthe(smoothed)profileare denoted as Pleft and Pright respectively. If there is only one background region (states empty, entering, leaving, entering + leaving), splitting the image at the center has no negative effect. The left and right mean is computed either over a tube and background region, or over background only. At the very special case that the image width is exactly twice a tube’s length and the tube enters (or leaves) the scene with the right (or left) boundary exactly on the image center, the regional threshold is computed only over the tube and the classification may be either foreground or background. However, in both cases this situation can be detected as a state where a measurement is not possible and is therefore a sufficient solution. The region based classification of the segments can now be expressed as: � TUBE , median(s(i)) ≤ τregion C3(s) = BG , otherwise where τregion is defined as follows: ⎧ ⎨ Pleft ,s(i) falls into left region only τregion = Pright ⎩ max(Pleft, Pright) ,s(i) falls into right region only ,s(i) falls into both regions (4.12) (4.13) In Figure 4.15(b) one can see the difference between the global and the regional classification threshold. The regional threshold of the left half is much lower compared to the global threshold. On the other hand, since the second segment belonging to the tube intersects the center, the maximum of both regional thresholds is taken into account which lies significantly above the global threshold. Finally, all segments are classified correctly. With this threshold, the classification is less sensitive to darker background regions. Thetwomethodshavebeencomparedinthefollowingexperiment: A sequence of transparent tubes (50mm length, 8mm diameter) has been captured including 467 frames that have been manually classified as measurable, i.e. a tube is
72 CHAPTER 4. LENGTH MEASUREMENT APPROACH 250 200 150 100 50 (a) Smoothed graylevel profile Regional mean Global mean peak candidates filtered peaks local median 0 0 20 40 60 80 100 120 140 160 180 200 (b) Figure 4.15: (a) The background intensity at the left is much darker than at the right. The global mean as threshold can not compensate for such local variations as can be seen in (b). In this case, the left background region is wrongly classified as foreground, since the global threshold is larger than the local median of the corresponding segment. A region based threshold that considers the left and right image side independently can overcome this problem (see text).