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

Class PatternSampler

source code


When called, resamples - according to the size_normalization parameter - an image at the supplied (x,y) sheet coordinates.

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

Nested Classes [hide private]

Inherited from param.parameterized.Parameterized: __metaclass__

Instance Methods [hide private]
 
_get_image(self) source code
 
_set_image(self, image) source code
 
_del_image(self) source code
 
__call__(self, image, x, y, sheet_xdensity, sheet_ydensity, width=1.0, height=1.0)
Return pixels from the supplied image at the given Sheet (x,y) coordinates.
source code
 
__apply_size_normalization(self, x, y, sheet_xdensity, sheet_ydensity, size_normalization) source code

Inherited from param.parameterized.Parameterized: __getstate__, __init__, __repr__, __setstate__, __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]
  whole_pattern_output_fns = param.HookList(class_= TransferFn, ...
Functions to apply to the whole image before any sampling is done.
  background_value_fn = param.Callable(default= None, doc= ...
Function to compute an appropriate background value.
  size_normalization = param.ObjectSelector(default= 'original',...
Determines how the pattern is scaled initially, relative to the default retinal dimension of 1.0 in sheet coordinates:
  name = <param.parameterized.String object at 0xb26faac>
String identifier for this object.

Inherited from ImageSampler: image

Inherited from param.parameterized.Parameterized: print_level

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

_get_image(self)

source code 
Overrides: ImageSampler._get_image

_set_image(self, image)

source code 
Overrides: ImageSampler._set_image

_del_image(self)

source code 
Overrides: ImageSampler._del_image

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

source code 

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

The image is assumed to be a NumPy array or other object that exports the NumPy buffer interface (i.e. can be converted to a NumPy array by passing it to numpy.array(), e.g. Image.Image). The whole_pattern_output_fns are applied to the image before any sampling is done.

To calculate the sample, the image is scaled according to the size_normalization parameter, and any supplied width and height. sheet_xdensity and sheet_ydensity are the xdensity and ydensity of the sheet on which the pattern is to be drawn.

Overrides: ImageSampler.__call__

Class Variable Details [hide private]

whole_pattern_output_fns

Functions to apply to the whole image before any sampling is done.
Value:
param.HookList(class_= TransferFn, default= [], doc= """
        Functions to apply to the whole image before any sampling is done.""")

background_value_fn

Function to compute an appropriate background value. Must accept an array and return a scalar.
Value:
param.Callable(default= None, doc= """
        Function to compute an appropriate background value. Must accept
        an array and return a scalar.""")

size_normalization

Determines how the pattern is scaled initially, relative to the default retinal dimension of 1.0 in sheet coordinates:

'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, filling the entire bounding box).

'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, fitting the image into the bounding box but not necessarily filling it).

'original': no scaling is applied; each pixel of the pattern corresponds to one matrix unit of the Sheet on which the pattern being displayed.

Value:
param.ObjectSelector(default= 'original', objects= ['original', 'stretch_to_fit', \
'fit_shortest', 'fit_longest'], doc= """
        Determines how the pattern is scaled initially, relative to the
        default retinal dimension of 1.0 in sheet coordinates:
            
        '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).
...