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

Class GenericImage

source code

                        object --+        
                                 |        
 param.parameterized.Parameterized --+    
                                     |    
base.patterngenerator.PatternGenerator --+
                                         |
                                        GenericImage
Known Subclasses:

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, scaling, 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]
 
__setup_pattern_sampler(self)
If a new filename or whole_image_output_fn is supplied, create a PatternSampler based on the image found at filename.
source code
 
function(self, params)
Function to draw a pattern that will then be scaled and rotated.
source code
 
_get_image(self, params)
Get a new image, if necessary.
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_dynamic_time_fn, state_pop, state_push, verbose, warning

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

Class Methods [hide private]

Inherited from param.parameterized.Parameterized: params, print_param_defaults

Class Variables [hide private]
  __abstract = True
bool(x) -> bool
  output_fn = param.ClassSelector(OutputFn, default= IdentityOF())
Optional function to apply to the pattern array after it has been created.
  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.
  size_normalization = param.Enumeration(default= 'fit_shortest'...
How to scale the initial image size relative to the default area of 1.0.
  whole_image_output_fn = param.ClassSelector(OutputFn, default=...
Function applied to the whole, original image array (before any cropping).
  pattern_sampler_type = param.Parameter(default= PatternSampler...
The type of PatternSampler to use to resample/resize the image.
  cache_image = param.Boolean(default= True, doc= ...
If False, discards the image after drawing the pattern each time, to make it possible to use very large databases of images without running out of memory.

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

Inherited from param.parameterized.Parameterized: name, print_level

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__setup_pattern_sampler(self)

source code 

If a new filename or whole_image_output_fn is supplied, create a PatternSampler based on the image found at filename.

The PatternSampler is given the whole image array after it has been converted to grayscale.

function(self, params)

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)

_get_image(self, params)

source code 

Get a new image, if necessary.

If necessary as indicated by the parameters, get a new image, assign it to self._image and return True. If no new image is needed, return False.

__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

output_fn

Optional function to apply to the pattern array after it has been created. This function can be used for normalization, thresholding, etc.
Value:
param.ClassSelector(OutputFn, default= IdentityOF())

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.")

size_normalization

How to scale the initial image size relative to the default area of 1.0.
Value:
param.Enumeration(default= 'fit_shortest', available= ['fit_shortest', 'fit_longes\
t', 'stretch_to_fit', 'original'], precedence= 0.95, doc= """
        How to scale the initial image size relative to the default area of 1.0.""\
")

whole_image_output_fn

Function applied to the whole, original image array (before any cropping).
Value:
param.ClassSelector(OutputFn, default= DivisiveNormalizeLinf(), precedence= 0.96, \
doc= """
        Function applied to the whole, original image array (before any cropping).\
""")

pattern_sampler_type

The type of PatternSampler to use to resample/resize the image.
Value:
param.Parameter(default= PatternSampler, doc= """
        The type of PatternSampler to use to resample/resize the image.""")

cache_image

If False, discards the image 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 after drawing the pattern each time,
        to make it possible to use very large databases of images without
        running out of memory.""")