POV-Ray : Newsgroups : povray.general : Create heightmap from contour lines Server Time
27 Dec 2024 14:36:54 EST (-0500)
  Create heightmap from contour lines (Message 1 to 10 of 13)  
Goto Latest 10 Messages Next 3 Messages >>>
From: scott
Subject: Create heightmap from contour lines
Date: 2 Jan 2013 05:13:40
Message: <50e40854$1@news.povray.org>
Not specifically for POV but I'm after a method to create a heightmap 
from a contour map. All I have available is the map showing contours of 
constant height, I have traced these and made them into arrays of points 
but I can't figure out a way to generate a height map from this.

I tried already for each point interpolating between the two nearest 
contours but it leads to not a very smooth result (jumps and sharp 
angles). Does anyone know a better way to do this that would lead to a 
smooth looking surface?


Post a reply to this message

From: William F Pokorny
Subject: Re: Create heightmap from contour lines
Date: 2 Jan 2013 07:32:44
Message: <50e428ec$1@news.povray.org>
On 01/02/2013 05:13 AM, scott wrote:
> Not specifically for POV but I'm after a method to create a heightmap
> from a contour map. All I have available is the map showing contours of
> constant height, I have traced these and made them into arrays of points
> but I can't figure out a way to generate a height map from this.
>
> I tried already for each point interpolating between the two nearest
> contours but it leads to not a very smooth result (jumps and sharp
> angles). Does anyone know a better way to do this that would lead to a
> smooth looking surface?
Hi Scott,
While it's a tool still on my "I need to play with that tool someday" 
list, perhaps give meshlab (meshlab.org) a try? It has features which 
turn point clouds into meshes along with options for smoothing. The 
input can be an ascii file one vertex/tuple per line.
Bill P.


Post a reply to this message

From: Le Forgeron
Subject: Re: Create heightmap from contour lines
Date: 2 Jan 2013 07:55:16
Message: <50e42e34$1@news.povray.org>
Le 02/01/2013 11:13, scott nous fit lire :
> Not specifically for POV but I'm after a method to create a heightmap
> from a contour map. All I have available is the map showing contours of
> constant height, I have traced these and made them into arrays of points
> but I can't figure out a way to generate a height map from this.

in povray terminology, I think it would be easier to generate a mesh
from your points.

> 
> I tried already for each point interpolating between the two nearest
> contours but it leads to not a very smooth result (jumps and sharp
> angles). Does anyone know a better way to do this that would lead to a
> smooth looking surface?

Assuming that your map is a single plane projection (no special case of
a vertical elevation to provide such fancy things as a balcony over some
empty space), you have first to generate the tesselation (set of
triangles) from your set of points. (not as easy as it sound, you should
keep only the nearest points in 2D-projection plane, not the nearest in
3D... yet it must cover once and only once the plane (do not have
overlapping triangles))

Then for each vertex, you can compute the average normal at that vertex
by averaging the normal of its contributing triangles.


Post a reply to this message

From: scott
Subject: Re: Create heightmap from contour lines
Date: 2 Jan 2013 08:28:35
Message: <50e43603$1@news.povray.org>
>> Not specifically for POV but I'm after a method to create a heightmap
>> from a contour map. All I have available is the map showing contours of
>> constant height, I have traced these and made them into arrays of points
>> but I can't figure out a way to generate a height map from this.
>
> in povray terminology, I think it would be easier to generate a mesh
> from your points.

I was hoping there would be an easier way to generate a heightmap rather 
than triangulating a mesh, and there to also be a way to keep the 
gradient continuous rather than sharp changes along the contour lines. I 
got quite close by doing a simple linear interpolation from the 2 
nearest contours, but maybe I need to do a higher order interpolation.

> Assuming that your map is a single plane projection (no special case of
> a vertical elevation to provide such fancy things as a balcony over some
> empty space), you have first to generate the tesselation (set of
> triangles) from your set of points. (not as easy as it sound, you should
> keep only the nearest points in 2D-projection plane, not the nearest in
> 3D... yet it must cover once and only once the plane (do not have
> overlapping triangles))

Yeh this is pretty much what I expected needed to be done to generate a 
mesh, but I was scared of coding the tessellation step and what the 
results might be, especially if the contour lines were quite complex (eg 
some areas very close together and others much further apart).

> Then for each vertex, you can compute the average normal at that vertex
> by averaging the normal of its contributing triangles.

There's still the problem with how to deal with areas above the highest 
contour and below the lowest contour, I would like it to somehow follow 
on the gradient the other side of the contour rather than just be flat.


Post a reply to this message

From: scott
Subject: Re: Create heightmap from contour lines
Date: 2 Jan 2013 08:28:49
Message: <50e43611$1@news.povray.org>
On Wed 02/01/13 12:32, William F Pokorny wrote:
> On 01/02/2013 05:13 AM, scott wrote:
>> Not specifically for POV but I'm after a method to create a heightmap
>> from a contour map. All I have available is the map showing contours of
>> constant height, I have traced these and made them into arrays of points
>> but I can't figure out a way to generate a height map from this.
>>
>> I tried already for each point interpolating between the two nearest
>> contours but it leads to not a very smooth result (jumps and sharp
>> angles). Does anyone know a better way to do this that would lead to a
>> smooth looking surface?
> Hi Scott,
> While it's a tool still on my "I need to play with that tool someday"
> list, perhaps give meshlab (meshlab.org) a try? It has features which
> turn point clouds into meshes along with options for smoothing. The
> input can be an ascii file one vertex/tuple per line.
> Bill P.

Thanks I'll take a look.


Post a reply to this message

From: Le Forgeron
Subject: Re: Create heightmap from contour lines
Date: 2 Jan 2013 09:04:58
Message: <50e43e8a$1@news.povray.org>
Le 02/01/2013 14:28, scott nous fit lire :

>> Then for each vertex, you can compute the average normal at that vertex
>> by averaging the normal of its contributing triangles.
> 
> There's still the problem with how to deal with areas above the highest
> contour and below the lowest contour, I would like it to somehow follow
> on the gradient the other side of the contour rather than just be flat.

As the contributing triangles at a top vertex would either be :
* horizontal (same height)
* inclined (lower height)
the normal for the vertex is not going to be vertical.
As a consequence, the horizontal smooth_triangle at the top is going to
have normal that would generate a faked curve.

You would then need to sub-tesselate the mesh to generate
sub-true-triangles according to the computed normales (that
sub-tesselation should be done with a central point at the triangle
center, not only with intermediates points along the triangle's sides)

Assuming you have "random coordinate points", you might generate a
regular mesh using a regular triangle pattern, as long as the side of
your projected triangle is smaller than (half at least ?) the smallest
distance between the nearest two points in your points.
For each vertex of your mesh, compute its height with a weighted average
of all coordinates points.
The weight of Point k must inversely proportional to the distance of the
projected Point k with the projected vertex. When the distance is 0, the
weight should override any other contribution.

For instance, you could use as individual weight: 1/exp(distance)
(it's imperfect, as distance of 0 is not overriding any other values)

Using a bigger value than e for the exponential might provides smaller
influences of far values.

You can also clip the influence of a point once the distance is too far.
(typically twice the maximal distance between two adjacent lines of your
original curves): intercept with a test & replace weight by 0.


Post a reply to this message

From: Kenneth
Subject: Re: Create heightmap from contour lines
Date: 2 Jan 2013 14:05:01
Message: <web.50e483bc4643925cc2d977c20@news.povray.org>
scott <sco### [at] scottcom> wrote:

> >
> > in povray terminology, I think it would be easier to generate a mesh
> > from your points.
>
> I was hoping there would be an easier way to generate a heightmap rather
> than triangulating a mesh, and there to also be a way to keep the
> gradient continuous rather than sharp changes along the contour lines. I
> got quite close by doing a simple linear interpolation from the 2
> nearest contours, but maybe I need to do a higher order interpolation.
>

I happened to be re-reading section 2.3.10 in the docs today ("SDL Tutorial: A
Raytracer") and the subsections there beginning at 2.3.10.10 detail some nice
code about creating a 'similar' kind of mesh. Perhaps your interpolation of
points could be applied to that setup in some way?  Just an idea.


Post a reply to this message

From: Christian Froeschlin
Subject: Re: Create heightmap from contour lines
Date: 3 Jan 2013 20:34:54
Message: <50e631be$1@news.povray.org>
scott wrote:

> I tried already for each point interpolating between the two nearest 
> contours but it leads to not a very smooth result (jumps and sharp 
> angles). Does anyone know a better way to do this that would lead to a 
> smooth looking surface?

I think such a thing has been posted here once, basically an
iterative 2d process starting with an height field (image) that has
the known heights at the contour lines seeded and is then smoothed over
and over again (and in each step the contour heights are restored).

It sounds like an stbenge thing to me ;) but I can't seem to find it.


Post a reply to this message

From: scott
Subject: Re: Create heightmap from contour lines
Date: 4 Jan 2013 03:09:23
Message: <50e68e33$1@news.povray.org>
>> I tried already for each point interpolating between the two nearest
>> contours but it leads to not a very smooth result (jumps and sharp
>> angles). Does anyone know a better way to do this that would lead to a
>> smooth looking surface?
>
> I think such a thing has been posted here once, basically an
> iterative 2d process starting with an height field (image) that has
> the known heights at the contour lines seeded and is then smoothed over
> and over again (and in each step the contour heights are restored).
>
> It sounds like an stbenge thing to me ;) but I can't seem to find it.

Sounds interesting, should be able to add something like that in to my 
existing code to have a play with that idea. If I end up with anything 
remotely useful I'll post it, it's in C# though.


Post a reply to this message

From: BertvdB
Subject: Re: Create heightmap from contour lines
Date: 4 Jan 2013 03:55:00
Message: <web.50e6982f4643925cd25d21bf0@news.povray.org>
You ever tried Wilbur http://www.ridgenet.net/~jslayton/software.html, it can be
used for most of geographicale data to create heightmaps in a lot of formats.


Post a reply to this message

Goto Latest 10 Messages Next 3 Messages >>>

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.