Model Heightmap

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
Post Reply
makafaka
Posts: 6
Joined: Sun May 30, 2021 9:06 pm

Model Heightmap

Post by makafaka »

I have a heightmap (grayscale bitmap) that I want to use in FreeCAD. Is it possible to add that in as a model? I am fairly new to FreeCAD. Thanks in advance.

Version: 0.18
Rev Number:
OS: Debian 10 64-bit
Last edited by makafaka on Wed Oct 27, 2021 11:22 pm, edited 2 times in total.
User avatar
M4x
Veteran
Posts: 1483
Joined: Sat Mar 11, 2017 9:23 am
Location: Germany

Re: Model Heightmap

Post by M4x »

"Latest version of FreeCAD" isn't detailed enough. Please have a look at the big red banner at the top.
User avatar
Roy_043
Veteran
Posts: 8552
Joined: Thu Dec 27, 2018 12:28 pm

Re: Model Heightmap

Post by Roy_043 »

Maybe with the Lithophane external workbench?:
https://github.com/furti/FreeCAD-Lithophane
TheMarkster
Veteran
Posts: 5513
Joined: Thu Apr 05, 2018 1:53 am

Re: Model Heightmap

Post by TheMarkster »

The macro FCBmpImport can import gray scale bmp as lithophane, too. Each pixel gets a height based on the level of black or white in that pixel. I haven't used the workbench, so I don't know which will give better results. If the resolution is too high the macro will probably bog down FreeCAD with too many objects. If you can post the file I'll give it a go with macro.
makafaka
Posts: 6
Joined: Sun May 30, 2021 9:06 pm

Re: Model Heightmap

Post by makafaka »

Roy_043 wrote: Wed Oct 27, 2021 7:22 am Maybe with the Lithophane external workbench?:
https://github.com/furti/FreeCAD-Lithophane
This appears to be Windows only. I tried it, it will import the image, but won't convert it to a lithophane successfully. It returns an empty object when I click "create the geometry .. shape of box" button.
TheMarkster wrote: Wed Oct 27, 2021 7:57 pm The macro FCBmpImport can import gray scale bmp as lithophane, too. Each pixel gets a height based on the level of black or white in that pixel. I haven't used the workbench, so I don't know which will give better results. If the resolution is too high the macro will probably bog down FreeCAD with too many objects. If you can post the file I'll give it a go with macro.
According to the git and my attempts with this addon, this will only work in BW images, which have 1-bit per pixel. This means that pixels must be one of two values: 0 or 1. Greyscale images have 8 bit precision, which means there are 256 values a pixel can take.

I don't really have a specific image file or FreeCAD document file, I am more just asking if any version of FreeCAD or any Addon/Macro supports this specific feature. If this doesn't exist, I will just create it. I am just new to the software, so I wanted to make sure that there is none existing in the community first.
TheMarkster
Veteran
Posts: 5513
Joined: Thu Apr 05, 2018 1:53 am

Re: Model Heightmap

Post by TheMarkster »

makafaka wrote: Wed Oct 27, 2021 11:37 pm
According to the git and my attempts with this addon, this will only work in BW images, which have 1-bit per pixel. This means that pixels must be one of two values: 0 or 1. Greyscale images have 8 bit precision, which means there are 256 values a pixel can take.

I don't really have a specific image file or FreeCAD document file, I am more just asking if any version of FreeCAD or any Addon/Macro supports this specific feature. If this doesn't exist, I will just create it. I am just new to the software, so I wanted to make sure that there is none existing in the community first.
Attachments
Snip macro screenshot-6191f2.png
Snip macro screenshot-6191f2.png (38.89 KiB) Viewed 1270 times
TheMarkster
Veteran
Posts: 5513
Joined: Thu Apr 05, 2018 1:53 am

Re: Model Heightmap

Post by TheMarkster »

I doubt if the workbench is windows only. It might be just not compatible with 0.18, which is fairly outdated by this point. I suggest trying one of the AppImages of 0.20. I imported this a few minutes ago:
Snip macro screenshot-ac13fa.png
Snip macro screenshot-ac13fa.png (270.28 KiB) Viewed 1251 times
Original png was converted to grayscale bmp and resized down to around 200x230 or something like that. The FreeCAD file is too large for the forum.

I made a compound of the line objects, and then a draft clone of the compound, which I scaled up in the z direction to create more contrast.

A warning with the macro, if you start getting errors in the report view abort the operation immediately with the abort button. Force kill FreeCAD if you have to. I have had it crash not just FreeCAD, but the entire system. Save and save often.
Attachments
Thomas_Jefferson_-_headshot.png
Thomas_Jefferson_-_headshot.png (155.55 KiB) Viewed 1251 times
makafaka
Posts: 6
Joined: Sun May 30, 2021 9:06 pm

Re: Model Heightmap

Post by makafaka »

TheMarkster wrote: Thu Oct 28, 2021 12:47 am I doubt if the workbench is windows only. It might be just not compatible with 0.18, which is fairly outdated by this point. I suggest trying one of the AppImages of 0.20. I imported this a few minutes ago:
Snip macro screenshot-ac13fa.png
Original png was converted to grayscale bmp and resized down to around 200x230 or something like that. The FreeCAD file is too large for the forum.

I made a compound of the line objects, and then a draft clone of the compound, which I scaled up in the z direction to create more contrast.

A warning with the macro, if you start getting errors in the report view abort the operation immediately with the abort button. Force kill FreeCAD if you have to. I have had it crash not just FreeCAD, but the entire system. Save and save often.
This worked! Thank you!
Post Reply