Assignment: Detecting Circular Objects using Template Matching

0 downloads 0 Views 528KB Size Report
Assignment: Detecting Circular Objects using Template Matching. (This is submitted as partial fulfillment for module EN3552 – Fundamentals of Machine Vision ...
Assignment: Detecting Circular Objects using Template Matching (This is submitted as partial fulfillment for module EN3552 – Fundamentals of Machine Vision & Image Processing, Department of Electronic and Telecommunication)

Zamrath M.N.M. 100618D Motivation: The rationale behind the selection of this project was to explore the opportunity to learn new areas of skills in Detecting Circular Objects. This concept can be integrated to the ‘Automotive’ industry to detect circular traffic boards and perform task intelligently. Problem Statement: The challenge of this project is to Detect Circular Objects from a range of objects. The detection of circular object can be done through several mechanisms. Some of them are already available as inbuilt function of MATLAB®. But some of them have their own disadvantages. As an example Hough transform works worst when there are large numbers of edges. Solution at a glance: The proposed solution contains mainly two parts. First is to detect the edges which are appeared on the image. Second part which works on template matching contains two sub parts which are generated concurrently as firstly creating the template and secondly detecting the circles.

pixel then the pixel will be brighter than others as shown in [2]. The next main stream was to define the threshold value to extract possible pixel points which have been highly correlated. The results are stored in ‘g’ matrix. One thing we have to be more precise is the deviation in the intensity levels when highly correlated and hence differ the threshold. For that an equation is generated as follows.

Variable ‘var’ is to change the parameters of the threshold and the diameter is of the circle we are trying to match with. Other notations are as described above. Then as to the highly correlated values on ‘g’, another walk through on the image will create possible circles around the objected circles. Results:

Method: In this project the edges are detected using a customized code where the Sobel Kernels are used in a moderated level. See [1]. The kernels are sequenced throughout the image and results are stored in matrix ‘result’.

=

+2

+(

)

Image 1: Detecting circles of same size The results are largely depended on the threshold value we defined to extract Cross Correlated results. As you can see when the brightness level, object’s size and clear stand out are differed across the image then the threshold levels are varied. Why we ignore some terms in the equation is, our aim is to detect circular objects and not to detect all the edges in the image as in [1]. The produced output is then processed using template matching. In template matching every possible circles have to be matched with the image. For that possible circles are created using ‘meshgrid’ and updated as template image. (Circles also can be created using edge detection) The created template images are then matched and calculated their dot products as in Cross correlation unlike in [3]. In this method when the template is placed at a particular position then each of the counterparts are multiplied and get the summation. The results are stored in ‘final’ matrix. When the template is highly correlated with the image at a particular

Imag e1

(17 circles) # Detecte d circles

Imag e2

(3 circles) # Detecte d circles

Imag e3

(1 traffic board)

Imag e4

(8 coins)

‘var'

Detecte d? (yes/no)

‘var'

# Detecte d coins

80

17

12

3

45

Yes

100

82

13

20

2

85

Yes

120

85

2

30

1

100

Yes(Not clear)

130

90

0

50

1

110

No

145

‘var'

‘var'

8 (2 non circle) 6 (1 non circle) 5 (1 non circle) 4 (1 non circle)

Conclusion: The extraction of the circular object on the image has extensively used the edge detection technique which is on the concept of Sobel operation. But the Sobel operation has been used in this project in a more moderated level. Even the moderated level does not significantly affect the edge detection of circular objects, the enhancement in the speed of the operation has been enormously reduced. The point we have to keep in mind here is Generally Circular object detection through Template matching is noisier than Circular Hough Transform. See [4]. An extraction on comparing these two methods has been provided in [4]. Image 2: Detecting circles of different sizes When the ‘var’ value in (1) equation is incremented, circles that can be detected by the program is reduced. In image 2, the circle which is at the middle is not disappeared as ‘var’ increases as in image 1. This is because the contrast level at which this circle is differentiated is large.

The main criticism in this program is the Threshold level we define on each image. This can be overcome by normalizing the edge detected image’s brightness and suitably defining a z value for the normal distribution. But in this project it was not expected and hence it was not examined. Therefore the Threshold level varies with picture to picture. A clear example on this project can be visualized as follows.

Image 5: Detecting a traffic sign Image 3: Detecting traffic signs In image 3, the detection of traffic sign is illustrated. In image 4 even there are only 6 out of 8 are circular (C) coins, since the non circular (NC) coins are round shape those are susceptible to be recognized as circular coins when ‘var’ is 100. But when ‘var’ is 120 the 6th coin (which is an NC) will not be detected. Since 3rd coin (which is an NC) is highly contrasted it is detected. But 7th C coin is not detected due to low contrast. To overcome this, the threshold level set at edge detection should be reduced. Another reason for this is the objects are close to each other and hence edges are not clear.

Image 6: Detected traffic sign References: [1] http://angeljohnsy.blogspot.com/2011/12/sobel-edge-detection.html [2]

http://docs.opencv.org/doc/tutorials/imgproc/histograms/template_matching/ template_matching.html

[3] http://en.wikipedia.org/wiki/Template_matching [4]http://www.intechopen.com/books/international_journal_of_advanced_ro botic_systems/bolting-cabin-assistance-system-using-a-sensor-network

Image 4: Detecting coins of different sizes