Building Detection
Building Detection
1. BACKGROUND
2. IDEA 2.1 STARTING POINT 2.2 IMPROVEMENTS 2.2.1 IMAGE PREPROCESSING 2.2.2 CONTOURS CHARACTERIZATION 3. IMPLEMENTATION 3.1 THE OPENCV LIBRARY 3.1.1 THE STRUCTURES 3.1.2 IMAGE PROCESSING AND ANALYSIS 3.1.3 STRUCTURAL ANALYSIS 3.2 IMPLEMENTATION OF IMAGE PREPROCESSING 3.3 IMPLEMENTATION OF THE BUILDING DETECTION 3.3.1 CONTOURS DETECTION 3.3.2 POLYGONAL APPROXIMATION 3.3.3 SCORE CALCULATION 4. FUTURE STEPS
2 2 2 2 2 3 3 3 3 3 3 5 5 5 6 6
5. CONCLUSION
1. Background
The technical objective of the project is to set up a methodology for map updating from very high resolution optical images on urban areas. This problem is of particular interest in the view of emerging applications such as GPS-guided navigation, traffic and pollution modeling, urban planning, etc. The fast urban growing observed in most of the major cities in China also requires rapid map updating. The data are (i) very high resolution optical images and (ii) digital maps from Geographical Information System (GIS). The result of the process will be an updated digital map, that is, a map that translates the content of the image. Therefore, it is necessary to have strong algorithms which detect the buildings on a satellite image to allow map updating.
2. Idea
2.1 Starting point
The idea I had was based on a demo program given with the OpenCV library, square.c. This program allows to detect squares on an image. The program was quite simple, it used a sequence of filters to obtains binary pictures, then from these pictures it returns the contours which : - are convex - have four sides - have four right angles - Have an area bigger than a given value The demo program can be found on OpenCV website : http://www.sourceforge.net/projects/opencvlibrary
2.2 Improvements
As long as a building is more than just a simple shape, improvements had to be made to the square.c program to detect buildings. I worked on two aspects : the image preprocessing and contours characterization.
- Convexity - Area - Angles - Intensity ( colors when working on 24-bit images) - Accuracy of polygon approximation (which mean straight lines) - Number of sides - Gradients on image When a contours, or its approximated polygon, has one of these characteristics, points are added to the score. This score is then used for two things : - To distinguish the buildings from noise - When two polygons intersect, to choose the one that will best fit the building shape (i.e. that has the best score).
3. Implementation
3.1 The OpenCV library
The Open Computer Vision Library is a collection of OpenSource algorithms and sample code for various computer vision problems. I mainly used three kinds of resources :
The function imageProcess filter the pixel intensity between filter_down and filter_up, and remove the noise. cvThreshold( src, temp, filter_up, 255, CV_THRESH_TOZERO_INV ); cvThreshold( temp, dst, filter_down, 255, CV_THRESH_BINARY ); These two lines will provide a binary picture in which the pixels whose intensity is between filter_down and filter_up appear in white, while the other pixels appears in black. This image will contain blocks of white pixels (building for example) and noise (Fig. 1).
Fig. 1 The noise removal process will remove pixels whose intensity is very different from the average intensity calculated on a block of 3x3 pixels or 5x5 pixels. The cvAdaptiveThreshold function is used to do so. The result after noise removal is on Fig. 2.
Fig. 2
Some parameters also take into account the source image or one of its transformation : the ratio between the area of the contour and the area of the polygon, the ration between the perimeter of the contour and the perimeter of the polygon, the matching between the Canny transform and the polygon. #define SCORE_INTENSITY 50 #define SCORE_BORDERS_MATCHING 12 #define SCORE_PERIMETER 35 The last parameter is a handicap given to the low resolution scan which tends to return too much noise. #define SCORE_HANDICAP 10 When the score has been calculated, only polygons whose score is over a given value will be added to the sequence of good polygons. 3.3.4 Polygons fusion When adding a new polygon to the list, it is necessary to check if there isnt a similar polygon in the list. The operator & allow to calculate the ratio of the area of the polygons intersection by the polygons union. This ratio is 1 for to identical polygons, and 0 for polygons which have no common intersection. This allows to keep the sequence up-to-date with the best polygon possible ( the polygon which has the best score). If the new polygons match with another polygon from the list, then the best one is kept. There is only one case where the best polygon should not be kept : its when the new polygon is recovering more than one polygon. Then, the new polygon should be kept even if it hasnt the best score.
4. Future steps
I see two directions for the improvement of the program. First, it should be possible to work on color images. It would allow to remove noise, most of the time caused by vegetation. Then, the building should have a color signature, thus by doing statistics on the buildings color it may be possible to increase the score respecting to the color of the building. Then, all the coefficient have been determined in an empiric way. The fact is that the algorithm is very sensitive to a change of these coefficients. A statistical study of the result for identified building should help to find them with a better accuracy, by looking for coefficients which maximize the score for buildings.
5. Conclusion
Its impossible actually to find 100 % of the building on the satellite map, so it is necessary to return found building with their probability.