Showing posts with label Image Hose. Show all posts
Showing posts with label Image Hose. Show all posts

Tuesday, January 24, 2012

Patterns, Part 2

Back in 1993, I tested a special capability that, unfortunately, has since disappeared. It allowed you to devise patterns that used a set of basis tiles, so that each tile could be chosen from this basis set. I call these tiling grammars.

At the right is an example of such a pattern. When I write pattern, I mean a non-repeating arrangement of items taken from a small set.

In this case, you can easily see how a space-filling curve can be generated from a small set. But what isn't really obvious is that this image is made by randomly placing square images into a grid.

Each grid element can have one of two images in it. With this image, I have taken care to create an image that (almost) doesn't have any obvious loops in it.

Well, OK, it does have one, in the lower left corner. But it doesn't have any circles in it. That, it turns out would be legal in this particular pattern grammar. Loops (and loops within loops within loops) would also be legal.
Here is the basis set for this particular image. It consists of two tiles as you can see. In each square, one tile connects the middle of the top edge with the middle of the right edge and also connects the middle of the left edge with the middle of the bottom edge. The other tile is either a mirror-symmetry of the first, or it is rotated 90 degrees from the first, whichever you like.

But wait, there are more options along these lines. For instance, I can create two more tiles that connect vertically and horizontally. In one tile, the horizontal crossing takes precedence, and in the other, the vertical crossing takes precedence. Now what would happen if we randomly expressed a tile from this basis?

Well, we can easily generate this test as well. Here, to the left, we see that suddenly, this image is starting to look like a subway map.

This grammar can generate interweavings of any kind. Weavings are made of warp (vertical threads) and weft (horizontal threads). Since one element is warp-over and another element is weft-over, we can represent all possible interweavings.

But what makes this interesting is that the threads can also turn.

You can represent knots as well, of course, since we include pass-under and pass-over elements.

Suddenly, this pattern has taken on more dimensions than before. Just 4 elements and so much richness of representation!

I thought on this, and realized that I could also include ends: threads that do not cross the tile, but rather end. I increased the basis by 4 more tiles. This time, the four diagonal sad-faces were added.

It is not obvious to me what this grammar will generate. But I think it's going to be interesting nonetheless! This seems to leading to noodles and other patterns made of threads that have ends. What will it look like?

Here is an example output randomly from this grammar. The most interesting part is that the complexity has definitely increased. Notice that the threads seem to look like bacteria in a culture mold. But regular, of course.

One obvious thing is that dots have appeared. And letters, like lower-case f and t.

You can identify each thread by itself, and where it goes.

And yes, a sad face has appeared in upper right.

After making this, it occurred to me that it would be possible to add 3 more elements to the basis. A tile containing 4 ends, and horizontal and vertical crossings with ends on the other sides of the tile.

Here is the new basis set, with the three new tiles added.

Perhaps the new elements look like the division symbol. But with the interconnections, this will likely be obscured by the neighboring elements, hiding it.

One thing we can say just by looking at the basis set: there might be more dots than in the last generated example. And more vertical and horizontal lines, particularly those which have no other line crossing them. So this will undoubtedly lead to more open space in some areas.

Here is the result of generating a random placement using this new basis set.

The result is using fewer and fewer curves. There are twice as many free-floating dots as in the last one.

One thing to remember is that each previous level is really just a subset of this next level.

Perhaps even more interesting than ends is the possibility of branching. We can assume that there are no curves and try to construct a maze grammar.

This would not have crossings, per se, rather it would be more square, with cross, the four t's, horizontal and vertical paths, with ends as well, but not really circular or curved. It occurs to me to try this case.

Here is the new basis, that operates only horizontally and vertically, and contains branching. I don't think it could generate a maze, though. On the average, it will probably generate circuits (closed loops).

This grammar is very foursquare. I have rounded off the edges to make it a little more presentable.

Here is the result of generating a random placement from this basis set.

It is a very busy pattern with very few dots. It does tend to be a little maze-like, and the pieces in it are heavily connected.

The tiling grammars I have presented here are reminiscent of Wang tilings.

Perhaps they are even closer to Thue-Morse tilings.

All of these are related to the work I did back in 1993, when the image hose was just invented and I realized that it might bear on this class of tiling grammars.

Monday, January 23, 2012

Painter's Image Hose

In Painter 3, a new kind of brush was added: the Image Hose. With this tool, you could draw using random snippets of image data. Each bit of image data could be individually masked and even shadowed. So you could literally paint with reality. To right, I have included an image created with Corel Painter 12. First a background of dirt was drawn with the image hose, and then some leaves we're drawn on top, also with the image hose.


How did the image hose begin? John Derry and I were sitting outside at a Restaurant in Chicago on July 31, 1992 and he suddenly wanted to be able to paint with the tree. I considered this for a while, and then i took down a note. My note said: analyze and grow texture from an example. But how??


Imagine each of the tree's leaves had a picture and they could be placed randomly. I remember we came to the conclusion that with only a few leaf pictures and perhaps some randomness of rotation angle or shading that you could paint a reasonable tree image. This was ideal since memory was, and continues to be, at a premium. In those days, that would be true on a Mac. In these days, that would be true on an iOS device, like an iPad.

The idea was in our heads that we could store a few images and draw using the set of images. So I came up with a way of doing it, which was initially called the structured clone.

As shown on the left, by October 1992 I already had some idea that the images could be stored in an array. Each element was individually w by h pixels, and they were arranged into a potentially three-dimensional structure. Each element is clearly spelled out to have an arbitrary 24-bit color image with an 8-bit alpha mask, treated like a penmask in the usual way.

A penmask is what we called the mask of a dab of paint. In those days, a brush stroke was always made up of a sequence of paint dabs placed along the bush storke's path. In this case, the brush stroke could be made up of a sequence of masked images instead.

I say it can be indexed by 0, 1, 2, or even 3 parameters - this is the dimensionality of the image hose, what I called the rank.
These parameters were such things as random, pressure, tilt, bearing, velocity, etc. In the random case, a new image element was chosen for that rank each time a new dab was placed along the stroke.

Let's imagine an example. I create 36 images in a 6x6 array. The rows contain six different orientations of a leaf, one orientation for each row. The columns contain six different sizes for each leaf, from small to large. I could use pressure to index the column, so the harder I press, the larger the leaf. I could use stroke direction or even stylus bearing to access the rows, which might allow me to control the orientation of the leaves by using my hand also. In this way, you could have more control over creating a tree just be drawing leaves.

Another thing we started doing was giving each image hose element a drop shadow. This meant that as you drew a pile of leaves, the leaves begin to shadow each other and thus shading would develop, making the pile appear to be three-dimensional.

To the right I have included a pile of randomly-oriented cubes created with the Image Hose in Painter 12. The drop shadow on each one is down and slightly to the right. This produces a slight shading below.

When we finished working on the Image Hose, we filed a patent in December 1995. You can find the details in the US Patent Office; it is patent number 5,767,860. It is one of the only things we decided to patent at Fractal Design, and so it is the only patent I share with John Derry.

Thoughts on How I Might Do It Differently


Today, there are quite a few different constraints on how things work, but compute power is much greater than it was in the early 1990s. The main thing I would do differently is to compute most of the changes on th fly. In Painter 4, we decided to do just that, computing scale, rotation, and opacity on the fly. But nowadays, I would probably allow for hue, saturation, and lightness changes, shadow depth, shadow opacity, and shadow feather to change on the fly as well.

This would mean that the only thing stored in the image hose database definition would be the random elements themselves. This would prevent much of the hand work in creating an image hose "nozzle".
It would be good to allow for 3D rotation and scaling as well. So that might mean creating a 3D definition for each element, which could be a bit complicated. The shading could also change on the fly.

I would probably allow for the nozzle to be made of several kinds of items, and separate them into groups. For example, you could make one group the stems, another group the leaves, and a final group the flowers. They would be stored into a single image hose nozzle definition. Then you might use pressure to choose between them, or you can hold down some modifier key, such as the command key or the command and open key to get each level when drawing.

Another thing I would like is to draw into a lens layer using an image hose, so that distortions can be applied s you draw. For example, you could draw shiny stones, then you could draw the water distortions on top to make the stones look like they are in a stream bed. And then perhaps the shines could be drawn on top as the sun sparkles on the water using another kind of image hose.

Something I tried but isn't still available in Painter is a grid-based image hose. This one draws each element inside a grid. You can randomly choose elements that are designed to connect with each other.

Here is an example of a tile design that could go into an image hose element and then placed randomly. Each element is designed to match at top, left, bottom and right, and so it won't matter how you place them, they will always match.

I would like to try this in square and hexagonal arrangements. Even in half-drop arrangements. It would be easy to design elements, since Painter supports drawing into half-drop patterns.

In this way, the image hose could help you to create mazes and other kinds of patterns that repeat, but without really repeating.