Sunday, November 18, 2012

[zxevanas] Interpolated noise

Double the dimensions of the image, placing the original pixels at the (even, even) coordinates. Interpolate the (odd, odd)-coordinate pixels from the 4 diagonal neighbors. Then, interpolate the (odd, even) and (even, odd) pixels (a checkerboard) from the orthogonal neighbors. Repeat, doubling the dimensions again.

Here are some experiments generating synthetic noise starting from a random black-and-white array and random gray scale array. It is also possible to start from the checkerboard stage.

noise binary full 256 0 noise gray full 256 0

noise binary checkerboard 256 0 noise gray checkerboard 256 0

noise binary full 128 1 noise gray full 128 1

noise binary checkerboard 128 1 noise gray checkerboard 128 1

noise binary full 64 2 noise gray full 64 2

noise binary checkerboard 64 2 noise gray checkerboard 64 2

noise binary full 32 3 noise gray full 32 3

noise binary checkerboard 32 3 noise gray checkerboard 32 3

noise binary full 16 4 noise gray full 16 4

noise binary checkerboard 16 4 noise gray checkerboard 16 4

noise binary full 8 5 noise gray full 8 5

noise binary checkerboard 8 5 noise gray checkerboard 8 5

noise binary full 4 6 noise gray full 4 6

noise binary checkerboard 4 6 noise gray checkerboard 4 6

Eventually gamma matters, but not taken into account for this.

Applying pnmdepth 2 or 3 yields abstract art.

abstract art

Source code of Haskell implementation using IOArray. It uses way too much memory; there must be a space leak somewhere.

1 comment:

C.R. Drost said...

If you like random images like that, you may enjoy playing with power-law spectrums and FFTs, which can give you some fun textures. Here is some code to do this sort of thing in Python+NumPy+PIL (the numerical computation library with the fast Fourier transform and the imaging library): code.

Here's what that code produces: img. You can get something closer to what you're trying for by changing (1 + r) to (1 + r)**2, or higher exponents (high frequency terms look more noisy) -- when it just goes like 1/r I believe it's what's called "brown noise", because I think when you go to a "power spectrum" you take the squared absolute value of the inverse FFT. You can also make the low frequencies more prominent by changing the 1 in the 1 + r to something else. :D