I have a grayscale image and I would like to convert it to a signed distance function.
Right now I'm using DistanceTransform
but I do not like the result.
image = Import[FileNameJoin[{NotebookDirectory[], "harbor.png"}]];
levelset =
ImageData[DistanceTransform[ColorNegate[image]] ] -
ImageData[DistanceTransform[image] ];
ListPlot3D[levelset]
harbor.png
output
You can clearly see the outline on the 3d plot which is really noisy, this is probably from the fact that DistanceTransform
works on black&white images not on grayscale images.
What I really need is correct gradients near boundary but right now they are complete mess. Is there an easy way how to achieve this?