Package random_image

This module contains functions that can be used to generate textures. More...


Functions

def random_grid
def corr
 Takes a grid, and returned a slighlty altered version of that grid.
def corr2
 Returns an altered copy of the given grid.
def corr_window
 This function calculates the average energey in a moving (wrapped) window.
def add_circle
 Function that draws a circle at a given point in a grid (no-antialiasing).
def add_cone
 Function that draws a "cone" at a given point in a grid (no-antialiasing).
def add_square
 Function that draws a square at a given point in a grid (no-antialiasing).
def scale_lists_to_int
 Scales a set of data points (in the range 0.
def samples_to_estimation_grid
 Tries to estimate a distribution from a list of sample points of that distribution.
def samples_to_image
 Tries to estimate a distribution from a list of sample points of that distribution, and generates an image of that estimation.


Detailed Description

This module contains functions that can be used to generate textures.

See:


Function Documentation

def random_image.add_circle (   grid,
  center,
  radius,
  amplitude 
)

Function that draws a circle at a given point in a grid (no-antialiasing).

This function is mainly used as an argument for samples_to_estimation_grid or samples_to_image.

Definition at line 149 of file random_image.py.

def random_image.add_cone (   grid,
  center,
  radius,
  amplitude 
)

Function that draws a "cone" at a given point in a grid (no-antialiasing).

The same as add_circle, except that the amplitude falls linearly towards the edges. This function is mainly used as an argument for samples_to_estimation_grid or samples_to_image.

Definition at line 170 of file random_image.py.

def random_image.add_square (   grid,
  center,
  radius,
  amplitude 
)

Function that draws a square at a given point in a grid (no-antialiasing).

This function is mainly used as an argument for samples_to_estimation_grid or samples_to_image.

Definition at line 183 of file random_image.py.

def random_image.corr (   grid,
  acc_probs,
  t = .9 
)

Takes a grid, and returned a slighlty altered version of that grid.

Each pixel in the new grid is a blend between the corresponding pixel in the old grid and another pixel close by. The second pixel is chosen from a square window around the first pixel, with a probability determined by the accumulative probabilities poassed to the function.

Parameters:
grid The grid to process.
acc_probs A list of accumulative probabilities. These probabilities are associated with a square. For instance, if list is [0.1, 0.2, 0.3, 0.3, 0.3, 0.4, 0.6, 0.7, 1.0] then the probabilities are:
 0.1 0.1 0.1
 0.0 0.0 0.1
 0.2 0.1 0.3

Parameters:
t Is the blend factor.

Definition at line 74 of file random_image.py.

def random_image.corr2 (   grid,
  props,
  t = .9 
)

Returns an altered copy of the given grid.

This is essentially a blur function, with the proportions of blur described by a grid. For example, if the grid is 3 by 3, then 9 pixels are used in to calculate each new pixel. They are blended together in the propertions described in the props grid. This value is then blended with the center pixel in the ratio described by the parameter t. (This is not necessary - it is to make easier comparissons between this function and the corr function).

Parameters:
grid The grid to process
props The proportions to blend pixels.
t The blend factor to use with the main pixel.

Definition at line 118 of file random_image.py.

def random_image.corr_window (   grid,
  n 
)

This function calculates the average energey in a moving (wrapped) window.

This is use to determine some of the statistical properties of the results of corr and corr2.

Definition at line 135 of file random_image.py.

def random_image.random_grid (   distribution,
  dims,
  period = 1 
)

Definition at line 40 of file random_image.py.

def random_image.samples_to_estimation_grid (   samples,
  image_dims,
  shape_function = add_circle 
)

Tries to estimate a distribution from a list of sample points of that distribution.

Definition at line 203 of file random_image.py.

def random_image.samples_to_image (   samples,
  image_dims,
  fname,
  shape_function = add_circle 
)

Tries to estimate a distribution from a list of sample points of that distribution, and generates an image of that estimation.

Definition at line 220 of file random_image.py.

def random_image.scale_lists_to_int (   samples,
  scale 
)

Scales a set of data points (in the range 0.

.1) to integer values in the range 0..scale.

Parameters:
samples A list of tuples, each representing a 2D point.

Definition at line 192 of file random_image.py.


Generated on Sun May 24 21:48:22 2009 by  doxygen 1.5.8