c4b4d4
c4b4d4

Reputation: 1074

Color interpolation/smoothing in discrete-colored height map

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?

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?

Upvotes: 1

Views: 738

Answers (1)

Mark Setchell
Mark Setchell

Reputation: 207465

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

Upvotes: 2

Related Questions