Results 1 to 5 of 5

Thread: Contour Lines/Maps in GIMP

  1. #1
    Guild Member Zach's Avatar
    Join Date
    Jan 2014
    Location
    New England
    Posts
    61

    Default Contour Lines/Maps in GIMP

    This isn't strictly a tutorial per se, but I can find no better place to put this up. I created a GIMP Script-Fu plugin that will take any heightfield and generate a contour map of it. Somebody requested that I post it, so here it is.

    There are two scripts: Contour Line, which adds one contour line to the heightfield, and Contour Map, which adds a lot of contour lines at once by calling Contour Line.

    To install the scripts in GIMP, put both .scm files in any of the folders GIMP looks in for scripts (to find this out, go to GIMP Preferences→Folders→Scripts). Then refresh the scripts by going to Filters→Script-Fu→Refresh Scripts, or just by restarting GIMP.

    The script expects a simple image in shades of grey, which represents a height field (see the first example image). Contour Map allows you to set the upper and lower bounds of height (to do the whole thing use 0 and 255 respectively), set the width of the contour lines, set how much elevation is skipped between lines, and set how much smoothing the lines will receive. The example maps are only 512 x 512, so there are a lot of little artifacts that would disappear on larger maps.
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	example1.png 
Views:	222 
Size:	83.5 KB 
ID:	60610   Click image for larger version. 

Name:	example2.png 
Views:	355 
Size:	204.5 KB 
ID:	60611  
    Attached Files Attached Files

  2. #2
    Guild Artisan Jacktannery's Avatar
    Join Date
    Jun 2011
    Location
    Dublin, Ireland
    Posts
    924

    Default

    That's brilliant - well done Zach.

  3. #3
    Guild Member ltan's Avatar
    Join Date
    Feb 2011
    Posts
    69
    Blog Entries
    1

    Default

    Perhaps I am the only one who had issues running these scripts, but here is what I figured out {in case it helps others}

    When you are using a height map, make sure that you are using grey scale colors, but the image is in RGB.



    The next step is to call the Contour Map script.



    The following dialog should open, and the example here has already been filed out to what I was using at the time.



    After adjusting the sliders / numbers to those that you want, clicky the Ok button. These settings made a busy topo map that took a minute or so to run.



    These lines are tooo light for my liking. There are two options that can be done to correct this. The first option is to duplicate the Contour Map layer until the desired contrast is achieved. The other option is to delete the Contour Map layer and redo the script with a different Hardness selected.



    I found 0.6 to be almost too dark when I re-ran the script, so this will be something that I will probably play with on every map. Of course it could just be the level of detail that I am having the script run with that is jamming everything together and looking busy.



    And that was indeed the issue with this height map. I was changing the height difference too gradually which crams all of the contours ontop of each other. Not idea for the small-ish image that I am using, well previewing, as when the image is viewed at full resolution the lines are not so squashed.

    From here artistic license can be given to the end user to allow some nice looking topo maps. Thanks for the scripts Zach!!!!




    Sorry for the rambling.
    Last edited by ltan; 10-09-2014 at 10:40 PM.
    -L-

  4. #4

    Default

    Hi Zach!

    As a tip, to get smother strokes in your script, convert the selections to paths then stroke those.

    For example, if you change this bit in your script:
    Code:
      (gimp-edit-stroke theLayer)
    to be:
    Code:
      (plug-in-sel2path RUN-NONINTERACTIVE theImage theLayer)
      (gimp-selection-none theImage)
      (gimp-edit-stroke-vectors theLayer (vector-ref (cadr (gimp-image-get-vectors theImage)) 0))
      (gimp-image-remove-vectors theImage (vector-ref (cadr (gimp-image-get-vectors theImage)) 0))
    You will end up with smoother contour lines.

    Here is an example (the stroked selection on the left half, the stroked path on the right half):
    Click image for larger version. 

Name:	stroke.png 
Views:	155 
Size:	95.9 KB 
ID:	68391

    You could also go crazy and use the plug-in-sel2path-advanced command that lets you specify corner thresholds, align thresholds, and all other kinds of path tracing voodoo, but that could be overkill

    -Rob A>

  5. #5
    Guild Novice
    Join Date
    Nov 2014
    Location
    New Zealand
    Posts
    21

    Praise

    Thank you for this. A great tool to have. I PDFed it (because I'm anal like that).
    Click image for larger version. 

Name:	Contour Lines-Maps in GIMP.pdf 
Views:	709 
Size:	210.2 KB 
ID:	73270

Posting Permissions

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