Showing posts with label speckle patterns. Show all posts
Showing posts with label speckle patterns. Show all posts

Saturday, February 11, 2012

Texture, Part 5

I have often wanted to create cross-hatching using the computer, since it is a favorite drawing technique. In the previous two parts of the Texture post series, I have described how it is possible to create speckles, mutually avoiding points in the tiled plane (like stippling patterns), create cells around each point, cleanly delineated using Voronoi tessellation, then construct crossfade mask sets for the cells, enabling you to place images within each cell to create arranged textures. This technique may be further exploited to create hatching patterns by expressing a hatching within each cell.

Speckle patterns are the key to arrangement in a random, pleasing pattern. And Voronoi tessellations are the key to providing a natural partitioning of the tiled plane into adjoining cells.

But what about the hatches themselves? What function makes them look best? What can be done with them?

The first thing is to control the crossfade amount. This is the amount of softness between the cells. With z-buffer cell merging, this creates a kind of interpenetration of hatches.

Next, we try changing the crossfade amount with linear additive cell merging. This creates a very pleasing regularity like rolling over clay with a roller with evenly spaced ridges, but with different angles in different places.

In fact, the last one is so convincing that we try it with different hatch spacings. Awesome regularity of the pattern quickly becomes chaos. Because we are using hatches that are regularly spaced with different angles, we end up with extremely band-limited results.

It's as if we applied a notch filter to some random texture! But this is not produced using Fourier transforms or notch (combined lowpass and highpass) filters. It is straight linear synthesis.

Also, it's tough to make pleasing hatches that satisfy the eye. This is done by assigning random angles to each of the cells, but looking at the neighbors and trying to not match the neighbors' angles. In fact, once we see the neighbors' angles, we look for the biggest gap and simply bisect that angular gap to create the angle for our cell. It makes for a pretty random-looking result. Pure randomness would not look as random, oddly enough.

If we restrict ourselves to only put out one hatch per cell, then we get a curious pattern of random sticks.

We can vary the number of hatches that occur inside each cell. If we increase the crossfade to a large amount and increase the spacing to a similarly large amount, we get a really complicated mesh of sticks strewn into a pile.

Cut down on the spacing and we end up with a very complex fibrous structure not unlike a kind of matting.

It is very satisfying to see the range of cool patterns that can result from hatching. Other patterns will probably be even more interesting inside crossfade masks.

So now we have a way of making stippling patterns, hatching patterns, and cellular patterns. And we have found that combining the techniques can lead us to incredible texture synthesis possibilities.

I want to end this post with a really interesting texture I created today, using Fourier synthesis. The original source was a hatching, derived from linear additive cell merging with an incredibly large crossfade, and then processed with a notch filter. Finally, I viewed magnitude and changed the edge of the filter to provide some interesting shines in between the main convolutions of the pattern. The result is dark and visceral, like something from H. R. Giger. Enjoy!









Thursday, February 9, 2012

Texture, Part 4

There are still numerous ways to make textures that have yet to be discussed. One of these, annealing, is particularly visually appealing in a graphic kind of way. In this post, I will discuss the finer nuances of slice-and-dice textures. But first, I think I will show annealing.

To the right you see an annealed texture. The annealing processes based on the technique of simulated annealing. In my interpretation of it, I employ two operations that work against each other iteratively to hone the look of a graphic.

In this case it the first operation is blur. This softens the image. The second operation is increase contrast. This hardens the edges of an image and creates a graphic print look.

As you iteratively apply annealing to an image, it is converted into a graphic representation of that same image, with clean, smooth, rounded black and white areas. With each iteration, the results get a bit smoother, and small features are eliminated also. Simulated annealing comes from metallurgy, where a bit of metal is heated and softened, and then cooled in increments to create different tensile strengths and even crystallization.

In image processing, I have borrowed the term and used it to create a similar process in which an image can be resolved into its most basic forms, and under the control of the user.

For instance, this lacunar image is opened in texture, adjusted 15% lighter, and then it is annealed five times using a small 1.82 pixel blur interleaved with a contrast increase with a slope of about 3.9. You see the five steps in the above example. Obviously, this drastically changes the character of the image.

Now, our task is to use several tricks to create the interesting texture you see at the top of this page (well, at least something a bit like it).

The trick comes from the Fourier transform. An image of spots may be filtered using the Fourier transform and using the spot-shaped filter on the left. This spot is elongated in the frequency domain, and, as I explained in Texture, Part 3, this makes the image spots (in the spatial domain) elongate in the perpendicular direction. Once this is done, the spots lengthen and merge and the result may be filtered with a notch filter to accentuate the spatial frequency that corresponds to the distance between the spots. This process can create stripes, but when you use speckle patterns to seed it, the stripes don't always line up and they create a cool irregular pattern, like the stripes on a zebra or a tiger.

Another technique, called reaction-diffusion, can also generate this kind of pattern.

Anyway, here is an image created using speckle-pattern synthesis and Fourier-domain filtering. The brain looks at this and sees patterns in sand dunes.

Actually, once, on the island of Fanø on the west coast of Jutland, I was driving on the large flat beach they have there. On that particular day, the wind direction and speed was in exactly the same direction and speed that I was driving. This made the patterns in the sand, which were pushed by the wind, become stationary relative to the car. Except that they were still evolving: annealed by the force of the wind, countered by the weight of the sand particles. Patterns soon formed and it was quite an experience, I have to say, to watch them twist and turn, evolving and convolving. The experience only lasted for a few minutes, and it has never occurred again, but I think it might still be made on a computer. I'll look into it.

So, after annealing this pattern, we get a graphic result that matches, but is still different. That's because the pattern does tend to evolve and simplify during the annealing steps.

It is an unusual effect, but I like it.

Though annealing is a metallurgical process, reaction-diffusion is a chemical process, and is readily simulated on a computer. We graphics guys are always looking for new cool-looking techniques to exploit!

And now I think I will exploit speckle patterns some more with some slice-and-dice patterns I made today.

Speckle patterns, like the one you see on the right, are like stippling patterns, but tiling inside the unit square so they can be repeated indefinitely. This works to my advantage, because Texture is used to create these tiling patterns. Like the paper textures in Painter.

In between the spots, you see the Voronoi tessellation. This partitions the tile into cellular areas. Inside each of these cells, we can place some bit of an image. When that image is the same for every cell, you get a very interesting effect.

I placed a bit of light and darkness into each of these cells, using an additive crossfade between each of the cells, and then I softened the result using a slight lowpass filter using the Fourier transform.

The texture I got was like a cellular bump texture, but shaded. You can see it to the left here. I get the shading by offsetting the light area to the lower left of each cell, leaving the darker area to the upper right of each cell.

Then I softened the result to make it appear very physically real and realizable.

Then I did something interesting. I created a speckle with about 150% of the spots, so each cell was smaller. This allowed me considerable play in which shaded portion to place in the cell, since I was using the above image as a source.

I ended up with the image you see to the right. This image is even more physically real, with shadows and catchlights on each cell. And because I used the z-buffer crossfade technique with a very large crossfade width, the edges of each cell are compressed into each other in a novel way, like the seeds on a sunflower.

This technique can make the lines that delineate each cell curved. It's all a function of the z-buffer compositing technique used in merging the cells.

This technique, using a previously sliced-and-diced image as the source for the next one is an iterative technique I used to get more and more complex textures. The trick is deciding which point in the source texture should be used inside all of the cells of the next. It really smacks of genetic programming. I say this because my eye becomes the agent of natural selection as the texture evolves from iteration to iteration.

Today, while making textures, I had a line pattern (which was wavy in one section) and I used that section to slice-and-dice into another texture, using z-buffering to merge the cells.

You can actually see where the fingers of texture interweave into each other on occasion. This is the value of z-buffering over the additive cell merging method: the texture looks more physically real.

Fortunately this technique scales. Here is an example with 5000 stones laid out in a paving stone pattern (or at least a nice pattern). See if you can find the repeat (it's only slightly larger than the amount I have shown).

I'm having way too much fun today!