Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: Reverse Quantizing, AKA - how to get a heightfield from contour lines

  1. #1
      RobA is offline
    Administrator RobA's Avatar
    Join Date
    Apr 2007
    Location
    Niagara, Canada
    Posts
    5,532

    Post Reverse Quantizing, AKA - how to get a heightfield from contour lines

    Reading Geoff's post on creating a heightfield got me thinking about the best way to do it.

    Starting with contour lines (which are basically quantized heightfields) how can I go back and get the heightfield I started with (or least a close approximation)

    Ideally, this should retain the detailed information of the contour lines, while providing a smooth representation of the heightfield between.

    The common suggestion seems to stack up the contour lines, filling each band with colours reflecting the elevations, then blur them all. The problems I have experienced are that 1) with too little blur, we get steps, and with too much blur, all definition of the shape and detail at the contour lines is lost.

    Look at these full size, the thumbnailer really messed these up!

    So I drew a problematic (sharp edges, variable slopes) heightfield:
    Reverse Quantizing, AKA - how to get a heightfield from contour lines-hf_orig.png

    This represents my best case 3d render:
    Reverse Quantizing, AKA - how to get a heightfield from contour lines-r_hf_orig.png

    Now I quantized the image with 8 levels to represent what I could get from contour lines:
    Reverse Quantizing, AKA - how to get a heightfield from contour lines-hf_q.png

    I ran this with three different blur amounts, 5px, 35px and 50px. Unfortunately stepping was horible in the 5 px, noticeable in the 35, and minimal in the 50, but all detail was lost in the 50, with the image looking like a smooth hump.

    So I pulled the quantized image into inkscape, ran the bitmap tracer on it to get the 8 paths representing the countour levels, then interpolated the colour with 8 steps between each of the adjacent contour paths. This produces pretty good results, but the small interpolation were visible as fine steps, so I applied a 2% blur to all the objects in Inkscape and ran it one last time.

    The results here were quite good! there is still a small band at each of the contour lines...due (I think) to double copies of each of the original contour lines. The detail however is excellent, with the original shape very well preserved:
    Reverse Quantizing, AKA - how to get a heightfield from contour lines-r_hf_ink_blur.png

    Lastly, here is a test sheet with all of them for comparison purposes:
    Reverse Quantizing, AKA - how to get a heightfield from contour lines-comparison.png

    This technique works well for single shapes...but I am not sure how well it would work for complex shapes... they may break the interpolate function. Something to play with later, I guess...

    -Rob A>

  2. #2
      ravells is offline
    Community Leader Gracious Donor ravells's Avatar
    Join Date
    Jun 2006
    Location
    London, UK
    Posts
    10,901

    Default

    Very cool!

    Being able to generate a smooth heightfield from contours would be amazingly useful in terms of controlling where you want your mountains etc to go, how high they are and how steep.

    By 'interpolate' do you mean a gradient fill from one one colour's level to the next or is what is referred to as a 'blend' in illustrator, where you create new vector shapes that ...er..interpolate from one shape to the next. (have I answered my own question?)

    I'd like to play around with this too. If the shapes are complex, I wonder whether feathering or using an inner glow might work to blend the colours between levels?

    If we can crack this problem, then overlaying the resulting image against a faint perlian noise background would provide a nice natural 'noise' to the mountains.

  3. #3
      RobA is offline
    Administrator RobA's Avatar
    Join Date
    Apr 2007
    Location
    Niagara, Canada
    Posts
    5,532

    Default

    Interpolate actually creates new shapes between two paths and optionally interpolates the style attributes. Here is an example of interpolating between two shapes apart from each other, and of a white circle on a black square (similar to the way I did the contour interpolating).
    Reverse Quantizing, AKA - how to get a heightfield from contour lines-interpolate.png

    Now please explain what is the 'blend' in illustrator - I don't know what it is...

    -Rob A>

  4. #4

  5. #5
      bricka is offline
    Guild Novice
    Join Date
    Nov 2007
    Posts
    11

    Default

    I think this is a good place to explain in more detail what I've already done about this; I've written a Python script which will interoplate between contours in a rather vanilla way. For each point not on a contour, it finds the closest points to the contours on either side and calculates the height according to the distances to these points, so if a point was halfway between the nearest points on each of the 1000 and 2000 metre contours, it would be set to 1500 metres. Points within the topmost contour line are interpolated relative to the top two contours, which seems the only sensible thing to do.

    This works well enough for a first approximation, but it lacks detail and isn't very useful for my purposes, which require a lot more realism. I tried to make the results more realistic by incorporating some plasma-generated landscaping, without much success. Ideally my program could take a quantised heightmap, interpolate in between the discrete levels, and apply some magic to generate realistic-looking mountains and so on. Any ideas?

  6. #6

  7. #7
      su_liam is offline
    Guild Artisan su_liam's Avatar
    Join Date
    Aug 2007
    Location
    Port Alberta, Regina(IRL: Eugene, OR)
    Posts
    707

    Default

    Funny coincidence. I've just been working on a similar problem. I was playing around with a heightfield I found on the net(I've been looking into the possibility of stitching together real-world heightmaps and subtly altering them to produce interesting and "realistic" extraterrestrial landscapes). The heightmap had serious stairsteps so, in Bryce, I used several iterations of the smoothing, noise, erode and eroded tools to obliterate the steps(mostly), and then applied a fractal at very low opacity on top of that. Thus far my methods aren't at all systematic(just to taste) and won't necessarily maintain the original landform with great fidelity.

    Attached, I have an image generated from the original hf at upper left. From lower right clockwise: a heavily modified version(this was my second try, I lost the first one, which was my favorite ), a less modified version, and on the upper right a minimally modified version(this is about as much of the original structure as I could maintain without obvious stepping.

    I'll try to add individual closeups and heightfields later. I'll also try to work out my methodology. This really isn't interpolation(since it doesn't maintain the existing contours), it's more like draping a canvas over a frame. Only the frame can get a little whacked out of shape.
    Attached Thumbnails Attached Thumbnails Reverse Quantizing, AKA - how to get a heightfield from contour lines-interpolation3.jpg  

  8. #8
      RobA is offline
    Administrator RobA's Avatar
    Join Date
    Apr 2007
    Location
    Niagara, Canada
    Posts
    5,532

    Default

    su_liam-

    Can you post that original heightfield (as b/w or contour lines)?

    It would be nice to have a standard example to play at with different techniques and compare the result.

    -Rob A>

  9. #9
      su_liam is offline
    Guild Artisan su_liam's Avatar
    Join Date
    Aug 2007
    Location
    Port Alberta, Regina(IRL: Eugene, OR)
    Posts
    707

    Default

    Quote Originally Posted by RobA View Post
    su_liam-

    Can you post that original heightfield (as b/w or contour lines)?

    It would be nice to have a standard example to play at with different techniques and compare the result.

    -Rob A>
    They're jpeg and not my original 16-bit tiffs, but here you go...

    interpOrig.jpg is the original. Mmm, duh?
    interpHeavy.jpg is the one at lower right.
    interpModerate.jpg is the one at lower left.
    interpLight.jpg is the one at upper right.

    edit: just noticed how bryce pooped all over the original aspect ratio. Sorry 'bout that.
    Attached Thumbnails Attached Thumbnails Reverse Quantizing, AKA - how to get a heightfield from contour lines-interporig.jpg   Reverse Quantizing, AKA - how to get a heightfield from contour lines-interpheavy.jpg   Reverse Quantizing, AKA - how to get a heightfield from contour lines-interpmoderate.jpg   Reverse Quantizing, AKA - how to get a heightfield from contour lines-interplight.jpg  
    Last edited by su_liam; 11-29-2007 at 02:37 PM.

  10. #10
      bricka is offline
    Guild Novice
    Join Date
    Nov 2007
    Posts
    11

    Default

    Quote Originally Posted by RobA View Post
    Bricka-

    How slow is it to process a large image?
    It certainly wouldn't win any awards for speed; a file of a million pixels takes a few minutes.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •