Extrude grid faces based on image texture

Using Blender 2.8
Is there already a way to take a grid and extrude faces along the normal based on an image? If I have a 15x15 pixel grayscale image, I’d like to extrude where black means do not extrude the underlying grid face and white means extrude to whatever maximum height; gray values are varying heights.


I tried using a displacement modifier, but that ends up leaving the mesh as a plane and raising/lowering vertices. I want to have extruded faces that are flat. I’m using no interpolation on the image, so the pixels are crisp.

I am able to read the image using a python script, but have not been able to figure out how to generate the mesh in 2.8. I don’t mind going completely scripted; I can figure out the coordinates of each vertex. All of the posts I’ve read where people are doing something similar (adding vertices and faces) gives me errors in 2.8.

Or maybe there is already an addon out there that does what I want?

If you want to create algorithm yourself, how to add/modify geometry surely quite a few people know here. You may want to ask that question in Coding -> Python Support.

I finally figured out how to make it work with bmesh.