I'm trying to write a little C++/OpenGL utility with which I could manage SRTM HDG files. For now, I'm just trying to read the files correctly. So I downloaded a sample tile from the main server, which is associated with this image.
To generate an image like that is exactly what I want to do initially, by code, no lib (if it doesn't became too hard). The problem is that the best I got so far are images like this (compare!).
I have tried a couple of proceedings... Basically, I'm transforming altitude in pixel color (from black/low to white/high), and putting the points per pixel with openGL as if creating an image. I've done it directly already, and now I'm averaging with the points around the point of interest. The results are very alike in both cases.
Before that, when I was visualizing the raw data (the altitude int's), I noticed a lot of strange negative values (like, -100 aside to 512 and so on), and it seems they correspond to some of the dark areas in my images (where they should not be so, if compared to the original image from NASA).
Here is my code for the draw() function (ok, it's just to get something out). Im usign netBeans IDE, on linux/Ubuntu:
void draw() { glClear( GL_COLOR_BUFFER_BIT ); int rows = 0; int cols = 0; byte = new char[2]; file.seekg (0, ios::beg); file.read(byte, 2); while(!file.eof()) {
alt = byte[1] | ( byte[0] maximo ) maximo = alt; h[cols][rows] = alt; cols++; if ( cols > 3600 ) { rows++; cols = 0; }
file.read(byte, 2); } for (rows = 1; rows < 3599; rows++) { for (cols = 1; cols < 3599; cols++) { altitude[cols][rows] = 0.1111111111*( h[cols][rows] + h[cols-1][rows-1] + h[cols][rows-1] + h[cols+1][rows-1] + h[cols-1][rows] + h[cols+1][rows] + h[cols-1][rows+1] + h[cols][rows+1] + h[cols+1][rows+1]); } } glPointSize(1.0f); glBegin(GL_POINTS); for (rows = 1; rows < 3600; rows++) { for (cols = 1; cols < 3600; cols++) { color = 0.0005555555555556f * (float)altitude[cols][rows]; glColor3f(color, color, color); glVertex3f(cols, rows, 0); } } glEnd(); cout
To generate an image like that is exactly what I want to do initially, by code, no lib (if it doesn't became too hard). The problem is that the best I got so far are images like this (compare!).
I have tried a couple of proceedings... Basically, I'm transforming altitude in pixel color (from black/low to white/high), and putting the points per pixel with openGL as if creating an image. I've done it directly already, and now I'm averaging with the points around the point of interest. The results are very alike in both cases.
Before that, when I was visualizing the raw data (the altitude int's), I noticed a lot of strange negative values (like, -100 aside to 512 and so on), and it seems they correspond to some of the dark areas in my images (where they should not be so, if compared to the original image from NASA).
Here is my code for the draw() function (ok, it's just to get something out). Im usign netBeans IDE, on linux/Ubuntu:
void draw() { glClear( GL_COLOR_BUFFER_BIT ); int rows = 0; int cols = 0; byte = new char[2]; file.seekg (0, ios::beg); file.read(byte, 2); while(!file.eof()) {
alt = byte[1] | ( byte[0] maximo ) maximo = alt; h[cols][rows] = alt; cols++; if ( cols > 3600 ) { rows++; cols = 0; }
file.read(byte, 2); } for (rows = 1; rows < 3599; rows++) { for (cols = 1; cols < 3599; cols++) { altitude[cols][rows] = 0.1111111111*( h[cols][rows] + h[cols-1][rows-1] + h[cols][rows-1] + h[cols+1][rows-1] + h[cols-1][rows] + h[cols+1][rows] + h[cols-1][rows+1] + h[cols][rows+1] + h[cols+1][rows+1]); } } glPointSize(1.0f); glBegin(GL_POINTS); for (rows = 1; rows < 3600; rows++) { for (cols = 1; cols < 3600; cols++) { color = 0.0005555555555556f * (float)altitude[cols][rows]; glColor3f(color, color, color); glVertex3f(cols, rows, 0); } } glEnd(); cout