Package topo :: Package pattern :: Module image :: Class GenericImage
[hide private]
[frames] | no frames]

Class GenericImage

source code


Generic 2D image generator.

Generates a pattern from a Python Imaging Library image object. Subclasses should override the _get_image method to produce the image object.

The background value is calculated as an edge average: see edge_average(). Black-bordered images therefore have a black background, and white-bordered images have a white background. Images with no border have a background that is less of a contrast than a white or black one.

At present, rotation, size_normalization, etc. just resample; it would be nice to support some interpolation options as well.

Nested Classes [hide private]

Inherited from param.parameterized.Parameterized: __metaclass__

Instance Methods [hide private]
 
_get_image(self, p) source code
 
function(self, p)
Function to draw a pattern that will then be scaled and rotated.
source code
 
__getstate__(self)
Return the object's state (as in the superclass), but replace the '_image' attribute's Image with a string representation.
source code
 
__setstate__(self, state)
Load the object's state (as in the superclass), but replace the '_image' string with an actual Image object.
source code

Inherited from base.patterngenerator.PatternGenerator: __call__

Inherited from param.parameterized.Parameterized: __init__, __repr__, __str__, debug, defaults, force_new_dynamic_value, get_param_values, get_value_generator, inspect_value, message, print_param_values, script_repr, set_default, set_dynamic_time_fn, set_param, state_pop, state_push, verbose, warning

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __subclasshook__

Class Methods [hide private]

Inherited from param.parameterized.Parameterized: params, print_param_defaults

Class Variables [hide private]
  __abstract = True
bool(x) -> bool
  aspect_ratio = param.Number(default= 1.0, bounds= (0.0, None),...
Ratio of width to height; size*aspect_ratio gives the width.
  size = param.Number(default= 1.0, bounds= (0.0, None), softbou...
Height of the image.
  pattern_sampler = param.ClassSelector(class_= ImageSampler, de...
The PatternSampler to use to resample/resize the image.
  cache_image = param.Boolean(default= True, doc= ...
If False, discards the image and pattern_sampler after drawing the pattern each time, to make it possible to use very large databases of images without running out of memory.
  name = <param.parameterized.String object at 0xb589dac>
String identifier for this object.

Inherited from base.patterngenerator.PatternGenerator: bounds, mask, mask_shape, offset, orientation, output_fns, position, scale, x, xdensity, y, ydensity

Inherited from param.parameterized.Parameterized: print_level

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

function(self, p)

source code 

Function to draw a pattern that will then be scaled and rotated.

Instead of implementing __call__ directly, PatternGenerator subclasses will typically implement this helper function used by __call__, because that way they can let __call__ handle the scaling and rotation for them. Alternatively, __call__ itself can be reimplemented entirely by a subclass (e.g. if it does not need to do any scaling or rotation), in which case this function will be ignored.

Overrides: base.patterngenerator.PatternGenerator.function
(inherited documentation)

__getstate__(self)

source code 
Return the object's state (as in the superclass), but replace the '_image' attribute's Image with a string representation.
Overrides: param.parameterized.Parameterized.__getstate__

__setstate__(self, state)

source code 
Load the object's state (as in the superclass), but replace the '_image' string with an actual Image object.
Overrides: param.parameterized.Parameterized.__setstate__

Class Variable Details [hide private]

__abstract

bool(x) -> bool

Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.

Value:
True

aspect_ratio

Ratio of width to height; size*aspect_ratio gives the width.
Value:
param.Number(default= 1.0, bounds= (0.0, None), softbounds= (0.0, 2.0), precedence\
= 0.31, doc= """
        Ratio of width to height; size*aspect_ratio gives the width.""")

size

Height of the image.
Value:
param.Number(default= 1.0, bounds= (0.0, None), softbounds= (0.0, 2.0), precedence\
= 0.30, doc= """
        Height of the image.""")

pattern_sampler

The PatternSampler to use to resample/resize the image.
Value:
param.ClassSelector(class_= ImageSampler, default= PatternSampler(background_value\
_fn= edge_average, size_normalization= 'fit_shortest', whole_pattern_output_fns= [\
DivisiveNormalizeLinf()]), doc= """
        The PatternSampler to use to resample/resize the image.""")

cache_image

If False, discards the image and pattern_sampler after drawing the pattern each time, to make it possible to use very large databases of images without running out of memory.
Value:
param.Boolean(default= True, doc= """
        If False, discards the image and pattern_sampler after drawing the pattern\
 each time,
        to make it possible to use very large databases of images without
        running out of memory.""")