Create Geometry based on an Image? I want to generate a grid of Objects based on an Image Texture.


I want to read the pixel data from an image
I want to generate an Object for every pixel (e.g. a plane) and colorize the object based on the pixel color


I want to use one single material for all objects and only change its color value.

Is this possible with python? Or is there another way?
How can I store color data in an object?

The Final Look should be something like this:


My code so far...

import bpy

cubeSize = 0.5

image = bpy.data.images["vangogh.jpg"]
width = image.size[0]
height = image.size[1]


for x in range(width):
    for y in range(height):
        plane = bpy.ops.mesh.primitive_plane_add(size=cubeSize, location=(x*cubeSize, y*cubeSize, 0.0))

        index = x + y * width

        r = image.pixels[index]
        g = image.pixels[index+1]
        b = image.pixels[index+2]
You can do this easily with animation nodes in the blender 2.80.

Create a number of instances (with deep copy) and place them using the grid distribution node. Then use the same grid points or vectors to sample the texture with Texture Node, which gives you the color of texture at that point of the grid and by changing the scale of the grid points you can scale the texture mapping as you want. 

Use these colors as input color for the vertex of the previously created objects. All the object has material but by using the attribute node in materials you can assign the color to individual objects based on their vertex colors. Here are screenshots of my node tree: