Dimensions¶
-
class
imagepypelines_image.
Dimensions
(channels_none_if_2d=False, order='HWC')¶ Bases:
imagepypelines_image.blocks.ImageBlock
Retrieves the dimensions of the image, including number of channels. If channels_none_if_2d is True, then grayscale images will return n_channels = None. Otherwise n_channels will be equal to 1 for grayscale imagery.
-
channels_none_if_2d
¶ whether or not to return n_channels = None for grayscale imagery instead of n_channels = 1.
- Type
- Default Enforcement:
- image
type: np.ndarray shapes: [(None,None), (None,None,None)]
- Batch Size:
“each”
Attributes Summary
arguments in the order they are expected
A unique id for this block
Number of arguments for the process function
Methods Summary
__call__
(*args)Allows any block to act as a callable, aliasing the process method
check_setup
(task_args)briefly checks setup with the provided task inputs.
copy
()fetches a shallow copy of this block with the UUID updated
deepcopy
()fetches a deep copy of this block with the UUID updated
enforce
(arg[, types, shapes, containers])sets the block up to make sure the given arg is the assigned type and shapes
all values must be json serializable
runs after
runs before all batches are processed
process
(image)Retrieves the height, width, and number of channels in the image.
rename
(name)renames the block to the given name.
Attributes Documentation
-
id
¶ A unique id for this block
This id is a combination of the block’s non-unique name and part of it’s uuid (last 6 characters by default). The entropy of this id can be increased by increasing ImagePypelines UUID_ORDER variable
- Type
Methods Documentation
-
__call__
(*args)¶ Allows any block to act as a callable, aliasing the process method
-
check_setup
(task_args)¶ briefly checks setup with the provided task inputs.
This function can be overloaded to add additional functionality if desired. By default it simply checks if too many or too few arguments were provided.
Note
Be very careful making task-specific modifications to the block setup in this function. It’s called once for every task this block is in. Changes made for one task may not apply to another task.
-
copy
()¶ fetches a shallow copy of this block with the UUID updated
-
deepcopy
()¶ fetches a deep copy of this block with the UUID updated
-
enforce
(arg, types=None, shapes=None, containers=None)¶ sets the block up to make sure the given arg is the assigned type and shapes
- Parameters
arg (str) – name the process function argument you want to enforce checking on
types (
tuple
oftype
) – the types to restrict this argument to. If left as None, then no type checking will be doneshapes (
tuple
oftype
) – the shapes to restrict this argument to. If left as None, then no shape checking will be donecontainers (
tuple
oftype
) – the containers to restrict this argument to. If left as None, then no container checking will be done. if batch_type is “each”, then the container is irrelevant and can be safely ignored!
- Returns
self
- Return type
Block
Note
This function must be called after the parent block is instantiated!
That is, in your __init__ function, you must call super().__init__ before calling self.enforce
-
get_default_node_attrs
()¶ all values must be json serializable
-
postprocess
()¶ runs after
all batches are processed
-
preprocess
()¶ runs before all batches are processed
-
process
(image)¶ Retrieves the height, width, and number of channels in the image.
if channels_none_if_2d is True, then grayscale images will return n_channels = None, otherwise n_channels = 1 for grayscale images.
Notes
assume image channels are the last axis
- Parameters
image (np.ndarray) – the input image
- Returns
tuple containing:
height(int): number of rows in image width(int): number of columns in image n_channels(int): number of channels in image
- Return type
(tuple)
-
rename
(name)¶ renames the block to the given name. The id is reset in this process
-