Diffuse lighting, 200 pebbles

Some results from this input image


Here is what the segmented regions look like


So far, only the diffuse lighting is rendered on the pebbles. Here are some different results, each with slightly different settings. The input image is 400px by 400px. The x and y positions of the light are in the middle of the image, and the light is getting further away from the image in each picture. There are 200 segments in this image. Processing time was around 10 mins.

Dist between pixels; 1 unit

Light’s height; 1000 units


Dist between pixels; 5 unit

Light’s height; 5000 units


Dist between pixels; 10 unit

Light’s height; 10000 units


Dist between pixels; 15 unit

Light’s height; 15000 units


Dist between pixels; 20 unit

Light’s height; 20000 units


As you can see, there is a lot of clipping in the final images, and the boundaries of the regions do not have a proper gradient.


This final image was an early render of the diffuse lighting. It has many artifacting issues, and since the shapes are larger and longer, it has odd gradients that make it look like a height map of mountains rather than pebbles.


Problems with offset

Using a point as the interiorĀ contour is problematic for some irregularly shaped segments. Since the point is simply the average of all of the points that make up the boundary, the output will be biased towards it. This can be seen in the output of the previous post.

This can be solved by using an offset of the boundary, as can be seen here with the blue and red lines. Ehren has a function to take care of this, however it cannot offset it very far.


A solution to this is to useĀ morphological erosion. The technique includes going around the boundary pixel by pixel and removing any parts of the region that are within a certain distance of this boundary pixel. The outcome will look like this;imgEroded.png

With this technique, we are able to erode to any size we want, by just changing a single number. The above example is a 4px erosion, whereas the bottom example is a 20px erosion.