This project is created for implementing the Harris Corner Detection and RANSAC algorithms.
This project consist of 2 parts. In the following, details of the parts are described.
At this part, the Harris Corner Detection is implemented. Steps of the algorithm are given below:
- Ix and Iy are found by using [-1 0 +1] and [-1 0 +1]T filters.
- The following formula is applied to get M matrix.
- Then, the following formula is applied to get Mc value.
In here, K can be selected between the 0.04 - 0.15. - Finally, if value of Mc is greater than the threshold, it is marked as a corner pixel.
Note: Filter can be calculated according to given size. At above, algorithm is described with filter size of 3. If if you want to change filter size, you need to change only first step. For example, if you want to use filter whose size is 5, you need to get Ix and Iy by using the following filters: [-2 -1 0 +1 +2] and [-2 -1 0 +1 +2]T.
In my project, three filters are used at the same time. Their sizes are 3, 5 and 7. Then, non_maximum suppression is applied to get most dominant corners.
At below results of the algorithm is being displayed:
- The first picture is the original image.
- The second picture is the result of application of the filters.
- Red squares shows the results of the filter whose size is 3.
- Green squares shows the results of the filter whose size is 5.
- Blue squares shows the results of the filter whose size is 7.
- The third picture is the result of the non-maximum suppression.
First Image |
---|
Second Image |
---|
Third Image |
---|
RANSAC (Random Sample Consensus) is a recursive method used to estimate the parameters of a mathematical model from data in a data set. RANSAC is a powerful method that works even when there is a lot of noisy data in the data set used, which is also used for noise detection.
The method generally consists of the following steps:
- Random data is selected from the entire data set
- Calculate the parameters of the model using the selected data
- Calculates the number of data from the data set in the whole data set
- If the number of data suitable for the model is as desired, the algorithm ends
- Steps 1-4 are repeated up to the preset number of steps
- If no model is found in the number of preset steps, the algorithm ends
At this part, using the RANSAC, the best 3 lines in a set of randomly generated dots are found and shown. There are six global variables which you can change as you want their values:
- randomIntegerLimit = 2000: It is the maximum value of the randomly generated dots.
- numberOfPoints = 750: It is the number of randomly generated dots.
- margin = 25: It is used to include points that are close to line. If we have a line y = mx + n, all points will be included to line whose distance is lower than 25.
- maxNumberOfIteration = 5000: It is the maximum number of iteration of RANSAC algorithm.
- numberOfIteration = 0: It is the number of iteration to find model. It is increased at every iteration.
- minNumberOfSuitablePoints = 30: It is the minimum number of points which are suitable to model. If third model is greater than this value, algorithm ends before number of iteration reaches the ‘maxNumberOfIteration’.
At below, there is a result of this part. In the example, please note that iteration stopped at 812th iteration as written at the top of the forth plot. Because, number of suitable points of third line is 31 which is greater than ‘minNumberOfSuitablePoints’.
Copyright 2019 Burak Kuyucu
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.