CMSC 190 SPECIAL PROBLEM, INSTITUTE OF COMPUTER SCIENCE 1 Elevation Proﬁle Visualization and Matching on the Philippine Islands Lawrence Namuco and Jaderick Pabico Abstract – This study proposes an approach for ren- from SRTM data. Lastly, a proﬁle matcher would be created dering topographic visualizations and for matching input to match the generated proﬁles from input images and from images of land forms of the Philippine Islands to Shuttle the SRTM database. From this, one can know the location Radar Topography Mission (SRTM) data. The approach of the land mass described in the image. The application’s utilizes the use of triangle strips for fast rendering of main task is to model any speciﬁc area in the Philippines visualizations of the different locations in the Philippines accurately based from the available SRTM data. When this and the use of formulated features for matching of proﬁles is accomplished, the application could basically generate a from input images of land masses and from the SRTM database of elevation maps of all known areas recorded in database. the SRTM data of the Philippines. The creation of this application can provide a ground for a I. I NTRODUCTION lot topographic applications. The elevation proﬁles that could be generated from the application can be used in classifying In the year 2000, NASA launched the Shuttle Radar To- unidentiﬁed land forms present on the surface of the country. pography Mission (SRTM) which collected the ﬁrst high high- The elevation proﬁles can serve as a basis for the feasibility resolution digital elevation data of the whole world. Nowadays, of infrastructure construction on certain areas. The elevation various versions of SRTM data have come out and are now proﬁles can also be used for routing purposes for hobbyists widely available in the Internet. With the possession of this such as hikers, tri-athletes, and road trippers. The proﬁle- kind of data, one can study and analyse different topographic matching feature can be used on location detection, speciﬁcally patterns present in a certain area. Also, the emergence of for search and rescue missions. SRTM data has brought several geographical applications into existences that were deemed impossible to create in the past. II. O BJECTIVES Different functionalities and features were offered by these applications that contributed to the improvement of distinct 1) To create an application that can create a 3D panoramic topographic databases and formulation of unique real-world visualization of any given location in the Philippines simulations. One application of SRTM data that has not been based on SRTM data; fully explored yet is it use on elevation proﬁling in the 2) To correctly extract features from input images of high Philippines. elevation land masses using object segmentation and The Philippines, being an archipelago, has varying degrees edge detection; of land elevation. As a result of this, many kinds of land 3) To accurately match generated proﬁle data from input forms such as mountain ranges, hills, and valleys are present images to proﬁle data from the SRTM database; in the country. It is a tough task for anyone to keep track of every existing land form in a speciﬁc area especially for III. R EVIEW OF R ELATED L ITERATURE a country as big and as diverse in terms of land forms Several studies have been made regarding the generation of such as the Philippines. Elevation proﬁling helps a lot on realistic graphical illustrations based on SRTM data. Basically, this case. Elevation proﬁling is the process wherein available digital elevation models (DEM) such as SRTM data are basic digital elevation information is extrapolated and transformed ingredients of any geo information system. SRTM data was into distinct elevation models that can be further interpreted, produced from an 11-day space ﬂight mission governed by analyzed and utilized for other scientiﬁc and experimental the National Geospatial-Intelligence Agency (GIA) and the purposes. National Aeronautics and Space Administration (NASA). The One of the main goals of this study is to create an ap- lack of available worldwide DEMs and the great need for plication in wherein users can view 3D panoramic elevation updated global topographic data that can be applied and used models of the different parts of the Philippines given a range for conducting modern studies on the earth sciences were the of longitude and latitude values. Another goal is to create main trigger for the mission (Farr et al., 2001) . a proﬁle-generating feature in that will allow the generation The creation of an application program which generates of elevation proﬁle data extracted from an input image of a realistic visualizations of land masses and bodies of water is land form and elevation proﬁle data that will be generated practically important because they can be used for allowing a basis for different civilian and military ﬁeld activities and Presented to the Faculty of the Institute of Computer Science, University of the Philippines Los Ba˜ os in partial fulﬁllment of the requirements for the n aviation systems. In a study by Hermocilla and Pabico (2010) Degree of Bachelor of Science in Computer Science , a software tool called FlowViz was designed to model, CMSC 190 SPECIAL PROBLEM, INSTITUTE OF COMPUTER SCIENCE 2 simulate, and visualize surface water ﬂow using SRTM data were used in the study. Among the seven edge detectors, speciﬁcally for the Philippines. The inspiration in creating Canny performed best followed by Rothwell although the other the software was largely based from country’s experience edge detectors also had good results. against recent typhoons which caused great physical damage The discussion of these previous studies clearly implies that to infrastructures and many casualties among humans. They applications involving the use of SRTM data in modeling aimed to create a tool for generating information that can be topographic representations is relatively not new. However, used for planning against ﬂoods and were successful in doing only a few studies involving these applications are centered it. speciﬁcally for the Philippines. The importance of topographic visualization applications is further emphasized in the study by Valeriano et al. (2006) IV. M ATERIALS AND M ETHODS  about modelling small watersheds in Brazil with SRTM The application was coded in C++. It is composed of 3 data. The original SRTM data was processed to make smoother major parts namely: DEMs. The reﬁned DEMs still contained the original drainage features which were used for the drainage modeling. It is 1) Visualizer reﬂected on this study that the use of DEMs such as SRTM 2) Proﬁle Generator (Contour Extraction, Feature Extrac- data is a good approach in characterization of landscape tion) attributes. 3) Proﬁle Matcher Identifying unique land masses is also one of the major applications of SRTM data. Dragur and Blaschke (2008) , in their study regarding terrain segmentation and classiﬁcation, devised a way to accurately sort SRTM 3 data into speciﬁc land forms. Many topographic variables such as elevations, slope gradients, slope aspects, and curvatures were extracted from the SRTM data they used which served as the basis in the process of identiﬁcation. It is clearly reﬂected upon this that SRTM data serves as a reliable tool in characterizing unique land forms in the ﬁeld of geomorphology. Besides Fig. 1. Esri File Format its application on geomorphology, the use of SRTM data can also be applied on volcanology, hydrology, forest ecology, and The input data that was used for the program was SRTM glaciology (Zandbergen, 2008) . 4.1 data from the CGIAR (Consultative Group on International There are many ways to construct graphical models given Agricultural) website. SRTM 4.1 data is formatted with a raster a set of data points. One way is via ray tracing. According to GIS ﬁle format which was developed by Esri (see Fig. 1). Cook and Carpenter (1984)  on their study on distributed The ﬁrst two columns indicate how many columns and rows ray tracing, ray tracing is one the reﬁned methods in graphics the raster has while the third and fourth columns indicate rendering. In a book by van der Ploeg (2007) , ray tracing the starting latitude and longitude values of the raster. The was deﬁned as a graphics rendering technique for generating 5th column indicates the gap between each cell of the raster. realistic images wherein a path of light is followed simulating Every value in the raster represents a single cell in an elevation natural lighting effects. Ray tracing is a global illumination representation. One degree of latitude and longitude value was rendering method, meaning light coming from all angles and represented by 1200 columns and 1200 rows of height values. surfaces are all taken into account during the image generation The Philippines’ whole SRTM data is comprised of a total process. This results into the addition of more advanced of eight ﬁles each consisting of data matrix of 6001 x 6001 effects like reﬂections, refractions, and shadows in a generated height values. picture. In a study by Aluning and Hermocilla (2010) , three algorithms were implemented in generating and visualizing A. Visualizer terrains. The algorithms that they used were the Midpoint The visualizer’s task is to a generate 3D panoramic visual- Displacement algorithm, Fault Formation algorithm, and the ization of any given location in the Philippines based on SRTM Perlin Noise algorithm. Based on the conclusion of their study, data. The ﬁrst part of the visualizer was designed to get three each algorithm had its strengths and weaknesses. input values from the user, a longitude value, a latitude value, The application of image processing methods on topo- and a scope value. The longitude and the latitude values are graphic maps is also not a new concept. To extract features the coordinates of the location the user want to project while from topographic maps, different image processing methods the scope value is the range of the projection starting from the such as edge detection and object segmentation is required. In coordinates speciﬁed by the user. Once an input of a latitude, a a study by D.P. Argialas and O.D. Mavrantza (2004)  on the longitude, and a scope value is given, the height values within comparison of edge detection techniques for the extraction of the speciﬁed scope starting from the coordinates will be saved geologic features on DEMs, several edge detection techniques in a text ﬁle which then will be converted to a TrueVision (tga) were discussed. Different edge detectors such as Canny, Roth- 24 bit uncompressed RGB image, a common image format for well, Black, Bezdek, Iverson-Zucker, EDISON, and SUSAN height maps (see Fig. 3). The image will then be fed into the CMSC 190 SPECIAL PROBLEM, INSTITUTE OF COMPUTER SCIENCE 3 from vertices to draw the visualization. A triangle strip is a series of connected triangles sharing vertices which allows fast rendering (see Fig. 4). On the other hand, a display list is a group of OpenGL commands that have been stored for later use. All vertex and pixel data are evaluated and copied into the display list memory once a display list is created. One advantage of display list is that it is one of the fastest methods to draw static data because it can be use repeatedly to draw frames. These are the simpliﬁed steps for rendering the visualiza- tion: 1) Set initial point of the visualization Fig. 2. Visualizer Flow 2) Compute for normals 3) Create the display list 4) Create n-1 strips; n = length of visualization 5) Call the display list B. Proﬁle Generator Fig. 3. A height map of Mt. Mayon visualizer via a tga library which contains functions for loading the image properly. The tga image that will be produced from the initial process Fig. 5. Generator Flow will be loaded. The height of each pixel from the image will be measured based on each pixel’s intensity for height scaling and The proﬁle generator’s task is to generate proﬁles from the later on for the computation of normals. The computation of SRTM database and from the input images that will be fed into normals will be needed to simulate light for the visualization. the proﬁle matcher. For the proﬁle data for both the SRTM A normal is a vector which contains information about the database and from the input images, two features will be used: lighting of certain surface. Normals in OpenGL is deﬁned per face of per vertex. The deﬁnition used in this study is per 1) Ratio of heights starting from the outermost left to the vertex normal computation because it offers more smoothness. center and heights starting from the outermost right to the center lef t = heightsf romthelef t right = heightsf romtheright RATIO = left / right 2) Summation of all heights divided by the width of the image The features used for the computation of proﬁles of the SRTM database is identical with the features used for the images. These are: 1) Ratio of heights starting from the outermost left and the outermost right of the point of reference Fig. 4. Triangle Strips 2) Summation of all heights divided by the length of the segment considered in the computation Normals at vertices will be computed as the normalised sum The ﬁrst feature for both the input images and the SRTM of all the normals for each face of the vertex. The face-per- database was chosen to identify the weight of the heights vertex were set to four for this study. Display lists will be from both sides starting from the center for the contour and created based from the triangle strips that would be generated starting from the points of origin for the SRTM Database. On CMSC 190 SPECIAL PROBLEM, INSTITUTE OF COMPUTER SCIENCE 4 the other hand, the second feature for both the input images and the SRTM database was chosen to determine the volume of the land mass described by the contour. Every longitude and latitude point for every 6th row of the ﬁles in the SRTM database was extracted a proﬁle. For each ﬁle in the SRTM database, there were a total of 500500 proﬁles generated. From these proﬁles, proﬁles of input images will be compared for matching. Open Source Computer Vision (OpenCV), a library of programming functions for image processing, was used for processing the input images. The application was designed to accept input images of land mass. The foreground (land mass) must be separated from the background to be able to extract Fig. 6. Matcher Flow a contour from it. To separate the background from the fore- ground, object segmentation was needed to be implemented. TABLE I The cvWatershed function of OpenCV was used for this. The FPS R ATES OF V ISUALIZATIONS cvWatershed function from OpenCV was based on one of the variants of watershed segmentation, a non-parametric marker- Visualization Min FPS Max FPS Avg FPS based segmentation algorithm. Basically, the user would need Mt. Makiling (480) 13 17 14.8 Mt. Mayon (480) 12 17 14.7 to mark the input image of which is the foreground and the Sierra Madre (480) 13 18 15.7 background. After marking, The foreground will be extracted Mt. Makiling (240) 51 64 61.4 while the background will be removed. Mayon (240) 48 56 53.2 These are the simpliﬁed steps for the Watershed Segmenta- Sierra Madre (240) 51 63 59.4 Mt. Makiling (120) 169 196 186.6 tion algorithm: Mt. Mayon (120) 179 244 199.6 1) Find the markers and the segmentation criterion for Sierra Madre (120) 125 160 149.7 region splitting which is most often the contrast or gradient 2) Perform watershed with the two elements (ﬂooding of V. R ESULTS AND D ISCUSSION the surface from its minima and preventing the merging A. Visualizer of waters coming from different sources) For the demonstration of the visualizer, three visualizations After foreground separation, the contour of the foreground were chosen to be rendered within three different scopes: must be extracted. The cvCanny function of the OpenCV was Sierra Madre (16.22, 121.85) (see Fig. 7), Mayon Volcano used to extract the contour of the foreground. The cvCanny (13.25, 123.68) (see Fig. 8), and Mt. Makiling (14.16, 121,24) function from OpenCV implements the famous Canny Edge (see Fig. 9). Each location was rendered within scopes of Detection (CED) algorithm, one of the best edge detection 120, 240, and 480. Their frame rates were recorded using algorithms. The CED algorithm is known to be the most Fraps, a free-ware benchmarking program to determine the optimal edge detection algorithm among all existing. performance of the visualizer. The minimum and maximum These are the simpliﬁed steps for the Canny Edge Detection FPS rate and the averages of FPS rates per scope of each algorithm: visualization were also recorded. 1) Reduce noise in the image by the help of a Gaussian Table 1 compares the frames-per-second rates (FPS) of mask before locating any edges different visualizations in different scopes. The application was 2) Compute the edge strength by taking the gradient of the run on a Core i5 560M 2.56 GHz, 2GB RAM computer with image Nvidia 310M graphics. Out of the three visualizations, Sierra 3) Find the edge direction and relate it to a direction that Madre obtained the lowest FPS rate. On the other hand, Mayon can be traced in the given image got the highest FPS rate. Los Banos’s FPS rate sat between the 4) Trace the edges two others. Table 1 shows that FPS rates tend to dip as scopes After the contour of the foreground has been traced, the get wider. Visualizations with a a lot high elevation points such features will be extracted from it based from the heights as Sierra Madre tend to run slower than visualizations with (northernmost points) of the contour. mostly ﬂat surfaces like the visualization of Los Banos. All of the visualizations were rendered correctly and accurately. C. Proﬁle Matcher Correct lighting was observed and no unusual geo-shapes were observed. The proﬁle matcher’s task is to compare a proﬁle generated from an input image to proﬁles in the database and ﬁnd a match. A comparison threshold was set to apply ﬁltering of B. Proﬁle Generator coordinates. If a match is found, the corresponding latitude For the proﬁle generator, eight images of different high land and longitude values will be appended to the list of coordinates masses were collected for the generating contours (see Fig. which passed through the comparison threshold. 10). Images were cropped accordingly so that the lowest points CMSC 190 SPECIAL PROBLEM, INSTITUTE OF COMPUTER SCIENCE 5 Fig. 7. Sierra Madre Visualization Fig. 9. Mt. Makiling Visualization Fig. 8. Mt. Mayon Visualization in the images were the land masses’ bases. All of the images’ contours were extracted correctly. The proﬁle data of each Fig. 10. From L-R, top to bottom: Mayon, Isarog, Canlaon, Apo, Taal, contour were recorded in Table II. Kitanglad, Matutum, Makiling C. Proﬁle Matcher coordinates out of the eight images. The other two images For the proﬁle matcher, the contours produced by the proﬁle obtained at least a half degree difference against their original generator were used. Each proﬁle was compared to all of the latitude coordinates but were close enough to qualify for their computed proﬁles in the SRTM database. original longitude coordinates. Correct contours were extracted Table III presents the closest coordinates retrieved by the from all eight images. application basing from the proﬁle from the SRTM database and the original coordinates of the land forms in the input VI. C ONCLUSION AND F UTURE W ORK images. The distances between the result coordinates and the The Shuttle Radar Topography Mission (SRTM) data has original coordinates were also recorded. As shown in it, all a lot of practical uses. Two of those uses were achieved in proﬁles of the contours resulted to near matches for at least this study. Firstly, a visualizer for the Philippine Islands was the latitude coordinate or the longitude coordinate. Six images developed to provide a 3D model of any given location in the were accurately matched by the proﬁle matcher to their correct Philippines. The use of triangle strips proved to be a fast and efﬁcient technique for generating topographic visualizations. TABLE II Secondly, a proﬁle generator and matcher were created to P ROFILE DATA generate proﬁles from input images and from the SRTM database for proﬁle matching. The Watershed Segmentation Input Ratio Volume Algorithm and The Canny Edge Detection algorithm proved Mayon 1.03 23.29 to be a good combination of algorithms for extracting the Isarog 0. 37 13.07 Canlaon 0.98 37.57 contours from the input images. Also, the features formulated Apo 1.04 24.28 for the generation of the proﬁles proved to be good features Taal .50 19.81 based on the results of the proﬁle matching tests done in this Kitanglad 0.98 52.77 Matutum 0.90 25.4 study which produced nearly accurate results. Makiling 0.85 30.07 Following the observations described in this study, a number of enhancements can be done to improve the application TABLE III developed in this study. For the ﬁrst part, the addition of M ATCHING OF C OORDINATES features like texture, foliage, and additional lighting could take this application to the next level. Also, with the availability of Input Result Original Distance (m) Mayon (13.27, 123.69) (13.25, 123.68) 24.60 different rendering techniques, a different one could be used Isarog (13.79, 123.61) (13.67, 123.37) 295.16 to enhance the quality of the visualizations. For the second Canlaon (10.46, 123.15) (10.4, 123.12) 73.79 part, adding more good features to work on would increase Apo (6.91, 125.25) (6.98, 125.27) 264.46 Taal (13.41, 120.82) (13.87, 120.92) 517.81 the success rate of matching and will also increase the ﬁltering Kitanglad (8.11, 124.80) (8.10, 124.92) 132.46 rate. Lastly, given the availability of one country’s SRTM data, Matutum (6.35, 125.08) (6.58, 125.08) 253 the approaches used in this study can be applied to other Makiling (14.83, 121.35) (14.14, 121.19) 779.14 countries as well. CMSC 190 SPECIAL PROBLEM, INSTITUTE OF COMPUTER SCIENCE 6 R EFERENCES  D.P. Argialas and O.D. Mavrantza. Comparison of edge detection and hough transform techniques for the extraction of geologic features. Technical report, Laboratory of Remote Sensing, School of Rural and Surveying Engineering, National Technical University of Athens, 2004.  Pabico J. and Hermocilla J. Identifying catchment areas near selected mountains in the philippines using ﬂowviz. Technical report, Institute of Computer Science, University of the Philippines Los Banos, 2010.  Dragur L. and Blaschke T. Terrain segmentation and classiﬁcation using srtm data. Technical report, Centre for Geoinformatics, Salzburg University, 2008.  Valeriano M., Kuplich M., Storino M., Amaral B., Mendes J., and Lima D. Modeling small watersheds in brazilian amazonia with shuttle radar topography mission-90m data. Technical report, Computers and Geosciences 32, 2006.  Zandbergen P. Applications of shuttle radar topography mission elevation data. Technical report, Department of Geography, University of New Mexico, 2008.  Cook R., Porter T., and Carpenter L. Distributed ray tracing. Computer Graphics, 1984.  Aluning R.C. and Hermocilla J. Terra: A 3d terrain generator and visualizer. Technical report, Institute of Computer Science, University of the Philippines Los Banos, 2010.  Farr T., Rosen P., Caro E, Crippen R., Duren R., Hensley S., Kobrick H., Paller M., Rodriguez E., Roth L., Seal D., Shaffer S., Shimada J., and Umland J. The shuttle radar topography mission. Technical report, Jet Propulsion Laboratory, California Institute of Technology, 2001.  A.J. Van der Ploeg. Interactive Ray Tracing. , 2007.