Subpixel Detection

 

      When we need to work with certain accuracy, a subpixel detection of the interest points perhaps could be very useful for our purpose. This is the case of camera calibration, where we need (or should need), a big accuracy for an accurate calibration.

 

      For these tasks OpenCV has already got some functions implemented. Thus, I don`t want in this section focused my view in this language. My goal in this section is show you how a laser line can be detected in an image with a subpixel accuracy.

 

Introduction

     If we have a laser single line along an image (which can be set by a ROI), we can be certain of that a pixel will present the maxim value for intensity (as long as the image is not burned). In these cases, we can get better outcomes than if we use image processing functions like erosion or threshold.

 

      Each column is analyzed looking for the pixel with the maximum intensity. When this pixel is found the X previous and X next pixels are taken for the next step. X is the number of pixels to take. If X is a large value, the analysis process of the image will be large but, if X is too short, perhaps the subpixel detection is not such accurate. The choice of X depends on the goal of the processing, but I believe that a value between 5 and 10 could give good outcomes.

 

     Once the pixel with maximum intensity has been detected, and a range of the closest pixels has been taken is the moment of fitting these points in a curve. There are a lot of curves and fitting methods for this, but I suggest a couple of them. The first one is the method which uses the Bezier curves. This method gives an accuracy approach of the position where the intensity level is maxim, but it takes too long to compute them. The second one I suggest is the method which uses the Gauss curves.

 

Pixel detection using morphological properties

     In order to see the power of these methods I am going to process an image using the morphological operators, such as erode or dilate, with the goal of detecting the laser line in the image.

 

      When an Image is acquired (picture 1.a) , this is converted into a binary image, using a threeshold function and a threeshold level which will determinate the pixels that will be set to 0 or 1. The result of this conversion can be seen in the picture 1.b (right on the top). The next step in the image processing is erode and dilate the line in order to join the points belonging to the line and delete noise (figure 1.c). This line will be the laser line detected in the image processed and is shown with the original image in the last figure.

 

       It can be seen from the following picture that, although in the previous figure it seems that every points are detected, in practise is not entirely true. When morphological operators are applied, some pixels are filtered in these steps and, consequently, are not taken into consideration for late processes. Thus, the outcomes aren´t composed by the total number of pixels which should be.

 

 

Fitting curves vs. morphological operators

     Another way to detect the points which belong to a single line in an image is using the methods described in the introduction. If the image is analyzed by columns, and the maximum level is extracted for each column, we have enough points for fitting the closest points in a curve, obtaining the maximum value with a subpixel accuracy.

 

.......continue (coming soon)....

 

Pages to the People

Jose Dolz

 Spain