Package topo :: Package patterns :: Module image :: Class PatternSampler
[hide private]
[frames] | no frames]

Class PatternSampler

source code

                                  object --+    
                                           |    
base.parameterizedobject.ParameterizedObject --+
                                               |
                                              PatternSampler

Stores a SheetCoordinateSystem whose activity represents the supplied pattern_array, and when called will resample that array at the supplied Sheet coordinates according to the supplied scaling parameters.

(x,y) coordinates outside the pattern_array are returned as the background value.



Nested Classes [hide private]

Inherited from base.parameterizedobject.ParameterizedObject: __metaclass__

Instance Methods [hide private]
 
__init__(self, pattern_array=None, image=None, whole_pattern_output_fn=IdentityOF(name='IdentityOF00032', norm_value=None, print_leve..., background_value_fn=None)
Create a SheetCoordinateSystem whose activity is pattern_array (where pattern_array is a Numeric array), modified in place by whole_pattern_output_fn.
source code
 
__call__(self, x, y, sheet_xdensity, sheet_ydensity, scaling, width=1.0, height=1.0)
Return pixels from the pattern at the given Sheet (x,y) coordinates.
source code
 
get_image_size(self) source code
 
__apply_size_normalization(self, x, y, sheet_xdensity, sheet_ydensity, scaling)
Initial pattern scaling (size_normalization), relative to the default retinal dimension of 1.0 in sheet coordinates.
source code

Inherited from base.parameterizedobject.ParameterizedObject: __getstate__, __repr__, __setstate__, __str__, as_uninitialized, debug, defaults, force_new_dynamic_value, get_param_values, get_value_generator, inspect_value, message, print_param_values, script_repr, verbose, warning

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

Class Methods [hide private]

Inherited from base.parameterizedobject.ParameterizedObject: params, print_param_defaults

Class Variables [hide private]

Inherited from base.parameterizedobject.ParameterizedObject: name, print_level

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, pattern_array=None, image=None, whole_pattern_output_fn=IdentityOF(name='IdentityOF00032', norm_value=None, print_leve..., background_value_fn=None)
(Constructor)

source code 

Create a SheetCoordinateSystem whose activity is pattern_array (where pattern_array is a Numeric array), modified in place by whole_pattern_output_fn.

If supplied, background_value_fn must accept an array and return a scalar.

Overrides: base.parameterizedobject.ParameterizedObject.__init__

__call__(self, x, y, sheet_xdensity, sheet_ydensity, scaling, width=1.0, height=1.0)
(Call operator)

source code 

Return pixels from the pattern at the given Sheet (x,y) coordinates.

sheet_density should be the density of the sheet on which the pattern is to be drawn.

scaling determines how the pattern is scaled initially; it can be:

'stretch_to_fit': scale both dimensions of the pattern so they would fill a Sheet with bounds=BoundingBox(radius=0.5) (disregards the original's aspect ratio).

'fit_shortest': scale the pattern so that its shortest dimension is made to fill the corresponding dimension on a Sheet with bounds=BoundingBox(radius=0.5) (maintains the original's aspect ratio).

'fit_longest': scale the pattern so that its longest dimension is made to fill the corresponding dimension on a Sheet with bounds=BoundingBox(radius=0.5) (maintains the original's aspect ratio).

'original': no scaling is applied; one pixel of the pattern is put in one unit of the sheet on which the pattern being displayed.

The pattern is further scaled according to the supplied width and height.

__apply_size_normalization(self, x, y, sheet_xdensity, sheet_ydensity, scaling)

source code 

Initial pattern scaling (size_normalization), relative to the default retinal dimension of 1.0 in sheet coordinates.

See __call__ for a description of the various scaling options.