Loading

Heightmap to STL

by mfussi, published

Heightmap to STL by mfussi Jan 1, 2012

Featured Thing!

Description

Small (and dirty ;) ) script to convert grayscale heightmaps to stl models. Usable for landscapes or terrain prints.

Supported Image Formats: GIF, PNG (preferred), JPEG, BMP

Recent Comments

view all

Can you make something like this for the reverse, that is convert STL or other 3D model format to grey scale height map image? I have a CNC router that works off of grey scale height maps as the input format and this would be an indispensable tool.

Hello, I am a graduate student in San Diego State University, Computer Science Dept. and working on my thesis project which involves 3D print. I found this script (heightmap2stl.jar) and trying to use it. I want to use this script in my Android app, so wanted to know if this is possible. Also wanted to check if I can get the source code of this jar file.

This would be really helpful to proceed for my thesis work. Hope to hear from you soon!

Thanks,
RAshmi

I fixed it. The issue with the java program I used is that it doesn't close the left and right ends properly with triangles (just uses rectangles), so add a column at each end of the same color (greyscale).

Liked By

view all

License

Give a Shout Out

If you print this Thing and display it in public proudly give attribution by printing and displaying this tag. Print Thing Tag

Instructions

Follow this tutorial to get a heightmap image from google earth.
digitalmindsoft.eu/forums/showthread.php?8504-Tutorial-to-extract-heightmaps-from-Google-Earth-in-GEM

After you finished step 10 convert the image with heightmap2stl.

Usage:
java -jar heightmap2stl.jar 'path to imagefile' 'height of model' 'height of base'

Arguments:
'path': Path to the heightmap (png, jpegs,... )
'height of model': Z scale of the model. Height of the max elevation.
'height of base': Height of the base, the model stands on.

sourceforge.net/projects/heightmap2stl/?source=directory - Feel free to contribute.

Attached is a low resolution model of the above provided heightmap.

Comments

You must be logged in to post a comment.

onebrokenneck on Nov 20, 2013 said:

Can you make something like this for the reverse, that is convert STL or other 3D model format to grey scale height map image? I have a CNC router that works off of grey scale height maps as the input format and this would be an indispensable tool.

on Sep 18, 2013 said:

Hello, I am a graduate student in San Diego State University, Computer Science Dept. and working on my thesis project which involves 3D print. I found this script (heightmap2stl.jar) and trying to use it. I want to use this script in my Android app, so wanted to know if this is possible. Also wanted to check if I can get the source code of this jar file.

This would be really helpful to proceed for my thesis work. Hope to hear from you soon!

Thanks,
RAshmi

Robotbeat on Jun 20, 2013 said:

The left and right ends are not entirely closed properly.... They look like rectangles that go up to the least high side, but they don't close the little triangle on the top. So, it doesn't print. Here's the thing that I made which isn't properly closed, you can see it in "Thingiview" even if you look close at the ends: http://www.thingiverse.com/thi...

Robotbeat on Jun 26, 2013 said:

I fixed it. The issue with the java program I used is that it doesn't close the left and right ends properly with triangles (just uses rectangles), so add a column at each end of the same color (greyscale).

Scott216 on May 13, 2013 said:

In my map, the highest point is 12441 ft and the lowest is 6800. if I make my base 10, what should I make the model height to be so the terrain stays to scale?

THG on May 13, 2013 said:

Hi, thanks for the cool JAR : ) I have a problem, after converting the PNG to to STL file, I opened it in MakerWare. It seems the grid lines are drawn into the model, it goes right into the model. Am I doing something wrong?

[IMG]http://i40.tinypic.com/1j9a83....[/IMG]

Screen shot at
http://tinypic.com/view.php?pi...

THG on May 14, 2013 said:

Silly me, I forgot to switch off the grid lines in MicroDEM. Works fine now : )

Scott216 on May 9, 2013 said:

Is there anything I can do in MicroDEM or GIMP that will result in
smaller STL file size? Right now I have a lot more resolution then I
need.

Also, do you have any tips on setting the heights so it's to scale?

Scott216 on May 9, 2013 said:

I get this error when I run the script:

Processing - 3D Topo test.tga
java.lang.IllegalArgumentException: Empty region!
at javax.imageio.ImageReader.computeRegions(ImageReader.java:2689)
at com.sun.imageio.plugins.wbmp.WBMPImageReader.read(WBMPImageReader.java:184)
at javax.imageio.ImageIO.read(ImageIO.java:1422)
at javax.imageio.ImageIO.read(ImageIO.java:1282)
at com.heightmap.Main.main(Main.java:49)

I don't know what it means. Your script and the tga file are in the same directory, this is the command I typed:
java -jar heightmap2stl.jar "3D Topo test.tga" 10 100

Scott216 on May 9, 2013 said:

I changed file type to png and that seems to work okay.

mbeccaria on May 7, 2013 said:

I'm wondering how you made the base come out properly. I have been using your script on a height map I created and when I slice the file using slic3r and check out the layers it seems like the object gets chopped in 1/2 along the z axis on the xy plane (that is, it starts printing halfway up the object and doesn't print the bottom half). I tried editing the stl file in freecad and meshlab by raising the object to the z floor and nothing seems to work. Can you provide a step by step tutorial from creating the file to creating the g-code? I literally have been working for hours on this and can't find anything helpful. Thanks,
Mike

amanda on Oct 28, 2012 said:

hey, thanks for posting this.  I put a test png image into the program, just 256px strip that ranged from 0-255, and I found that the stl file that was generated was curved.  So it seems that the relationship between greyscale value and height in this program is not linear?  can you suggest a way to make it linear?
thanks!
amanda

HarlanDMii on Feb 11, 2012 said:

I just discovered that the file can be imported directly into openscad. Open the .asc file that was downloaded from google earth.. open it with notepad.. delete the header part and save it as surface.dat

surface(file = "surface.dat", center = true, convexity = 20);

Note: You need a lot better computer than my laptop to render it.

pleppik on Jan 29, 2012 said:

This is pretty awesome.

I have a feature request: can you make it respect transparent pixels? If I have a transparent pixel in a GIF or PNG, make it a hole in the model (or outside the model if on the edge).

There are lots of non-rectangular things which can be modeled as 2D heightmaps, like medallions, sheriff's badges
, etc. This would open up a whole new set of tools for creating 3D objects: design in Photoshop or Illustrator, export as transparent PNG, and convert to STL.

spoogle on Jan 11, 2012 said:

Thanks, this is just what I needed. I've tried every 3d program I have and they all bail on my 1100x1500 binary height map. This program worked very well after I bumped up the memory limits in the JVM by passing -Xmx819200k on the command line (this is probably an unreasonably large number - I just needed it to be big enough to not exhaust the heap).

clintkc on Jan 2, 2012 said:

You can also use MICRODEM to simply export a 3D model (.OBJ) file of the displayed map. I used the GPS tool to enter real-world GPS coordinates for the 4 corners of my 40 acre property, then zoomed to that region
&
amp; exported a 3D model of it. This creates a VERY large file (mine was 205MB) which can then be edited in most 3D programs.

Alternately, you can also create a 3D height field (elevated mesh) using Rhinocerous, using a greyscale image of your property terrain data. ;) This creates a much smaller file to work with, as well.

mfussi on Jan 2, 2012 said:

thanks for the information, but i needed it two days ago ;) I searched and didn't found anything useable. So i had to code it myself.

67restomodder on Jan 2, 2012 said:

I am getting the following error when I try to use heightmap2stl:

Ripped-Pants:Downloads username$ java -jar heightmap2stl.jar sandias.tga 100 3

File: sandias.tga

Model height: 100.0

Base height: 3.0

-----------------------

Processing - sandias.tga

java.lang.IllegalArgumentException: Empty region!

at javax.imageio.ImageReader.computeRegions(ImageReader.java:2689)

at com.sun.imageio.plugins.wbmp.WBMPImageReader.read(WBMPImageReader.java:184)

at javax.imageio.ImageIO.read(ImageIO.java:1422)

at javax.imageio.ImageIO.read(ImageIO.java:1282)

at com.heightmap.Main.main(Main.java:49)

I am on a Mac with OS X 10.6.8 and the following Java verison:
java version "1.6.0_29"
Java(TM) SE Runtime Environment (build 1.6.0_29-b11-402-10M3527)
Java HotSpot(TM) 64-Bit Server VM (build 20.4-b02-402, mixed mode)

mfussi on Jan 2, 2012 said:

seems to be a problem with TGA pictures, use PNG instead.

yzorg on Jan 2, 2012 said:

Can you specify how to install, and start the software?

after unjar on my mac...

thers just this bunch of files with strange endings (.class,.so,.h,)

.. nothing i can open with anything i have.

crossover wont recognise it as app either.

mfussi on Jan 2, 2012 said:

Its a terminal application, so just download it. Open your terminal, navigate to your download folder and start it with this command:

java -jar heightmap2stl.jar 'path to imagefile' 'height of model' 'height of base'
Example: java -jar heightmap2stl.jar image.png 50 5

Hope this helps.

Vegetoast on Jan 2, 2012 said:

Sounds interesting but I am clueless with what to do with these files

Top