Results 1 to 9 of 9

Thread: How to get good cntour lines in GIMP from a height or elevation map?

  1. #1

    Default How to get good cntour lines in GIMP from a height or elevation map?

    Is there a way to get contour lines in GIMP starting with a height or elevation map?

    I'm looking for 1 pixel lines of a single color.

    Edge detect doesn't really produce what I'm looking for
    - too thick and multicolored.

    I did find a script here, but it wouldn't work.

    https://www.cartographersguild.com/s...ad.php?t=25929

    I can brute force it using shink selection repeatedly, but would like to know if anyone's got a better solution.

  2. #2
    Administrator waldronate's Avatar
    Join Date
    Mar 2007
    Location
    The High Desert
    Posts
    3,607

    Default

    Try posterize followed by edge detect. The posterize will reduce the number of intensity levels in your image to the number of levels that you posterize to. Edge detect will then only hit where the edges of the changes were. A very similar effect will happen if you treat the posterized heightfield as a bump map and shine a light straight down the Z axis: the flat areas will be illuminated brightly and the transitions will be dark (you may need to crank up the light intensity and vertical exaggeration for this to work well).

  3. #3

    Default

    Note that the unsatisfactory results are after already posterizing. The lines come up 2-3 pixels thick and in 4-5 colors .

  4. #4
    Administrator waldronate's Avatar
    Join Date
    Mar 2007
    Location
    The High Desert
    Posts
    3,607

    Default

    I missed the importance of single-pixel lines; I interpreted that as "thin" lines. There are morphological thinning operations available in some image-processing packages, but I don't know which (if any) are implemented in the GIMP. The most correct results would come from using a third-part contour tracer.

    An ugly workaround might be to resample the image to double its resolution (use bicubic to get smooth elements), posterize, edge detect, resample back to the original resolution (get 1 to 1.5 pixel wide lines), and then threshold the image to convert it to black and white.

  5. #5
    Guild Apprentice mewo2's Avatar
    Join Date
    Jun 2017
    Location
    Swansea, Wales
    Posts
    33

    Default

    The easiest way is to posterise, then select by colour, selection to path, and stroke path. That will give you good control over the thickness of the contour lines - you can even produce dotted and dashed lines this way.

  6. #6
    Administrator Redrobes's Avatar
    Join Date
    Dec 2007
    Location
    England
    Posts
    7,245
    Blog Entries
    8

    Default

    What I tend to do is flood fill every alternate colour in black and white like zebra stripes then do a bit of smooth and then whack the contrast up to max so it is only two colours - not greyscale. Then do the edge detect. It guarantees that you get a single edge. Its like the posterize but done in high contrast. An edge detect with only two colours next to each other should normally give you a single pixel line. You should get that with posterize but the zebra thing does definitely enforce it.

    I did a mini tut of that process in reverse where you want the greyscale from contours. But its the same kind of thing.
    https://www.cartographersguild.com/s...l=1#post296662

  7. #7
    Guild Expert johnvanvliet's Avatar
    Join Date
    Jul 2012
    Location
    N 42.39 W 83.44
    Posts
    1,091
    Blog Entries
    4

    Default

    there is a VERY GREAT gimp plugin
    G'Mic

    use the " isophotes " under " Contours "


    filter - after selecting the lines and removing the colors
    Last edited by johnvanvliet; 07-29-2017 at 04:05 PM.
    --- 90 seconds to Midnight ---
    --------

    --- Penguin power!!! ---


  8. #8

    Default

    Thanks for all the suggestions! I have a few different ideas now to mess about with. Off work for a couple weeks (college job, summer work is over until mid August), so I'll have plenty of time to mess about with them.

    And I just realized I had a typo in the title.

  9. #9

    Default

    Quote Originally Posted by johnvanvliet View Post
    there is a VERY GREAT gimp plugin
    G'Mic

    use the " isophotes " under " Contours "


    filter
    Missed that post while replying. Cool tool, thanks!

Posting Permissions

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