pad#
Functions#
|
Remove padding by c |
|
Remove padding by c |
|
Pad image by specified degrees of visual angle |
|
Pad image to specified visual size in degrees visual angle |
|
Pad image by specified amount(s) of pixels |
|
Pad image to a resulting specified shape in pixels |
|
Pad images in dictionary by specified degrees of visual angle |
|
Pad images in dictionary to specified visual size in degrees visual angle |
|
Pad images in dictionary by specified amount(s) of pixels Can specify different amount (before, after) each axis. |
|
Pad images in dictionary to a resulting specified shape in pixels |
- stimupy.utils.pad.remove_padding(arr, c)[source]#
Remove padding by c
- Parameters:
arr (numpy.ndarray) – input array
c (int) – padding amount.
- Returns:
arr – reduced array
- Return type:
- stimupy.utils.pad.add_padding(arr, c, val)[source]#
Remove padding by c
- Parameters:
arr (numpy.ndarray) – input array
c (int) – padding amount
val (float) – background value
- Returns:
arr – padded array
- Return type:
- stimupy.utils.pad.pad_by_visual_size(img, padding, ppd, pad_value=0.0)[source]#
Pad image by specified degrees of visual angle
Can specify different amount (before, after) each axis.
- Parameters:
img (numpy.ndarray) – image-array to be padded
padding (float, or Sequence[float, float], or Sequence[Sequence[float, float], ...]) – amount of padding, in degrees visual angle, in each direction: ((before_1, after_1), … (before_N, after_N)) unique pad widths for each axis (float,) or float is a shortcut for before = after = pad width for all axes.
ppd (Sequence[Number] or Sequence[Number, Number]) – pixels per degree
pad_value (Numeric, optional) – value to pad with, by default 0.0
- Returns:
img padded by the specified amount(s)
- Return type:
See also
- stimupy.utils.pad.pad_to_visual_size(img, visual_size, ppd, pad_value=0)[source]#
Pad image to specified visual size in degrees visual angle
- Parameters:
img (numpy.ndarray) – image-array to be padded
visual_size (Sequence[int, int, ...]) – desired visual size (in degrees visual angle) of img after padding
ppd (Sequence[Number] or Sequence[Number, Number]) – pixels per degree
pad_value (Numeric, optional) – value to pad with, by default 0.0
- Returns:
img padded by the specified amount(s)
- Return type:
See also
- stimupy.utils.pad.pad_by_shape(img, padding, pad_value=0)[source]#
Pad image by specified amount(s) of pixels
Can specify different amount (before, after) each axis.
- Parameters:
img (numpy.ndarray) – image-array to be padded
padding (int, or Sequence[int, int], or Sequence[Sequence[int, int], ...]) – amount of padding, in pixels, in each direction: ((before_1, after_1), … (before_N, after_N)) unique pad widths for each axis (int,) or int is a shortcut for before = after = pad width for all axes.
pad_val (float, optional) – value to pad with, by default 0.0
- Returns:
img padded by the specified amount(s)
- Return type:
- stimupy.utils.pad.pad_to_shape(img, shape, pad_value=0)[source]#
Pad image to a resulting specified shape in pixels
- Parameters:
img (numpy.ndarray) – image-array to be padded
shape (Sequence[int, int, ...]) – desired shape of img after padding
pad_value (float, optional) – value to pad with, by default 0.0
- Returns:
img padded to specified shape
- Return type:
- Raises:
ValueError – if img.shape already exceeds shape
- stimupy.utils.pad.pad_dict_by_visual_size(dct, padding, ppd, pad_value=0.0, keys=('img', '*mask'))[source]#
Pad images in dictionary by specified degrees of visual angle
Can specify different amount (before, after) each axis.
- Parameters:
dct (dict) – dict containing image-arrays to be padded
padding (float, or Sequence[float, float], or Sequence[Sequence[float, float], ...]) – amount of padding, in degrees visual angle, in each direction: ((before_1, after_1), … (before_N, after_N)) unique pad widths for each axis (float,) or float is a shortcut for before = after = pad width for all axes.
ppd (Sequence[Number] or Sequence[Number, Number]) – pixels per degree
pad_value (Numeric, optional) – value to pad with, by default 0.0
keys (Sequence[String, String] or String) – keys in dict for images to be padded
- Returns:
same as input dict but with larger key-arrays and updated keys for “visual_size” and “shape”
- Return type:
- stimupy.utils.pad.pad_dict_to_visual_size(dct, visual_size, ppd, pad_value=0, keys=('img', '*mask'))[source]#
Pad images in dictionary to specified visual size in degrees visual angle
- Parameters:
dct (dict) – dict containing image-arrays to be padded
visual_size (Sequence[int, int, ...]) – desired visual size (in degrees visual angle) of img after padding
ppd (Sequence[Number] or Sequence[Number, Number]) – pixels per degree
pad_value (Numeric, optional) – value to pad with, by default 0.0
keys (Sequence[String, String] or String) – keys in dict for images to be padded
- Returns:
same as input dict but with larger key-arrays and updated keys for “visual_size” and “shape”
- Return type:
- stimupy.utils.pad.pad_dict_by_shape(dct, padding, pad_value=0, keys=('img', '*mask'))[source]#
Pad images in dictionary by specified amount(s) of pixels Can specify different amount (before, after) each axis.
- Parameters:
dct (dict) – dict containing image-arrays to be padded
padding (int, or Sequence[int, int], or Sequence[Sequence[int, int], ...]) – amount of padding, in pixels, in each direction: ((before_1, after_1), … (before_N, after_N)) unique pad widths for each axis (int,) or int is a shortcut for before = after = pad width for all axes.
pad_val (float, optional) – value to pad with, by default 0.0
keys (Sequence[String, String] or String) – keys in dict for images to be padded
- Returns:
same as input dict but with larger key-arrays and updated keys for “visual_size” and “shape”
- Return type:
- stimupy.utils.pad.pad_dict_to_shape(dct, shape, pad_value=0, keys=('img', '*mask'))[source]#
Pad images in dictionary to a resulting specified shape in pixels
- Parameters:
- Returns:
same as input dict but with larger key-arrays and updated keys for “visual_size” and “shape”
- Return type:
- Raises:
ValueError – if img.shape already exceeds shape