Color interpolation/smoothing in discrete-colored height map

600 Views Asked by At

I am currently trying to smooth a height-map of a 2D world. I have multiple images of different 2D worlds, so it's something I'm not going to do manually but rather create a script.

Sample of a heightmap:

Height-map

As you can see, colors do not blend. I'm looking to blend every space to the color of their neighbours so the slope of the height map is smooth.

What have I tried?

  • Applying a blur filter, but it's not enough and gives bad quality results.

  • Applying small noise filters but it's not even close to what I need.

So far...

Here is what happens if I apply the height-map as it is without interpolating the color with it's neighbours.

enter image description here

The result is flat surfaces, instead of slopes/mountain. Hope to make my goal clear.

I believe that interpolating the heights with their neighbours and adding random noise on the surfaces will result in a good quality height-map.

I appreciate your help.

Bonus

Do you have any idea how would I create a simulated normal map from the result of this smooth height-map?

1

There are 1 best solutions below

0
On

You could try resizing your image down and then back up again to take advantage of interpolation, e.g. for 5% of original size:

magick U0kEbl.png.jpeg -set option:geom "%G" -resize "5%" -resize '%[geom]!' result.png

Here are results for 3%, 5% and 8% of original size:

enter image description here