View Full Version : Color contour images
10-01-2001, 06:13 AM
I want to write some code to display scientific modeling data as a color contour image. Will anyone please tell me the steps and procedures (algorithms) to achieve this goal? Thanks a lot.
I am currently working on the same project to use contour to represent some 3d data. I have used to matching square to do the contour drawing but have not figure out how to map the contour with colors....how's your project going? any progress? any new idea that I can share....
10-17-2001, 08:06 AM
Hi Wei, producing color images is not that hard. You may study Tutorial 35 on NeHe website. I could not figure out a way to add contour lines on the color images.
This forum topic http://www.opengl.org/discussion_boards/ubb/Forum3/HTML/003980.html shed some light on contouring. But they could not solve the stretching problem.
I hope we are on the same page. This is the contour image I am trying to produce. http://www.geop.ubc.ca/ubcgif/tutorials/magbasics/sld002.htm
Hi there, Thanks for your message. It helps alot. But there is one thing I am not sure is that what I did was to draw the contour line first and then try to color it. From your message, it seems to me that you color map the contour first and try to line on it. I don't know which one is right or better. Currently, I am still in the color contour stage. I will let you know if I make some progress. :-)
As far as I can tell, the best way to do this is by using an OpenGL 1D texture to create your color regions. This works great.
Regarding drawing black lines to "seperate" the color regions, the only way that I've been able to do it is with a marching squares algortihm. I then render the "lines" generated by the algorithm on the color surface using glPolygonOffset.
10-19-2001, 02:09 PM
Hi Pat and Wei, Will you please post any online resources where I can find marching square algorithm or code? Thanks.
[This message has been edited by contour (edited 10-19-2001).]
Hi Contour. I found matching square from book named" Interactive Computer Graphics-A top - down approach with OpenGL" and it has a little simple code..
Hi Pat, when you are using matching square, you have to calculate the values of z at the corners of a cell to determine whether the desired contour passes through the cell. Can you please tell me what algorithem you used to calculate that value. Thanks alot...
[This message has been edited by Wei (edited 10-22-2001).]
10-22-2001, 05:37 AM
Hi Wei, Thanks for your information. You may surf the following page on this forum for more details. http://www.opengl.org/discussion_boards/ubb/Forum3/HTML/004328.html
all you need is a 1d texture map.
make it 256 colors and add black at the
levels that you want the contour lines to
Hi Contour, how's your contour plot going? I am kind of stucking here in coloring contour. Do you have some sample programs of using 1D texture map to coloring contour that I can share...if you need, I can send you some matching square sample code...let me know...
10-22-2001, 09:06 AM
Hi Anon, you seem an expert in contouring. Will you please elaborate more about how to find the coordinates of contour lines and how to draw the black contour lines? I am a beginner of OpenGL and computer graphics. Thanks a lot.
Well Im not an expert but
I have don this. What you need to do
is implement 1d texture mapping.
look in the red book.
So at every node you have a scalar value that will tell you where along the 256 color bitmap you are. Opengl will interpolate between points.
ie 100m = red
0 m = blue
lets say you want a contour line at 10 meters then make the color at 10 m = black.
I do not put on contour lines but this should do an ok job.
10-22-2001, 10:13 AM
What about contour line stretching problem? For example, your hight field has a plateau at 100 m where you want to place a contour line. Then your contour line will be very thick there. Most of contour lines will be one pixel thick.
as I said I have not used contour lines,
that was just an idea. I guess that would be a problem. The data I work with has a steep gradient therefore I wouldnt have to worry about this. you could contour a 10m plateau roughly by just contouring 9.9m.
9.9 would be the black line and 10 m would be the approprite colour.
you have height/256 divisions in the colours.
The stretching of the black lines between contour colors is the reason that I decided to go with a marching squares algorithm.
My data is surface topography data in a grid of x,y points with a z value for each point. What I do is determine the min and max values of the entire surface data z values and divide the range (max-min) by the number of colors in your legend or color gradient. I then call the marching squares algorithm with a Z value corresponding to each color transition level.
[This message has been edited by Pat (edited 10-22-2001).]
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.