2.1.2.1.2. sf_tools.image.distort module¶
IMAGE DISTORTION ROUTINES
This module contains methods for playing around with image properties.
Author: | Samuel Farrens <samuel.farrens@gmail.com> |
---|---|
Version: | 1.1 |
Date: | 20/10/2017 |
-
sf_tools.image.distort.
downsample
(image, factor)[source]¶ Downsample
This method downsamples (decimates) an image.
Parameters: - image (np.ndarray) – Input image array
- factor (int) – Downsampling factor
Returns: Return type: np.ndarray downsampled image array
Raises: ValueError
– For invalid downsampling factor
-
sf_tools.image.distort.
resize_even_image
(image)[source]¶ Resize even image
This method returns an image with odd dimensions.
Parameters: image (np.ndarray) – Input image array Returns: Return type: np.ndarray resized image array
-
sf_tools.image.distort.
roll_2d
(data, roll_rad=(1, 1))[source]¶ Roll in 2D
This method rolls an array in 2 dimensions.
Parameters: - data (np.ndarray) – Input 2D data array
- roll_rad (tuple) – Roll radius in each dimension
Returns: Return type: np.ndarray rolled array
-
sf_tools.image.distort.
rot_and_roll
(data)[source]¶ Rotate and roll
This method rotates (by 180 deg) and rolls a 2D array.
Parameters: data (np.ndarray) – Input 2D data array Returns: Return type: np.ndarray rotated and rolled array
-
sf_tools.image.distort.
gen_mask
(kernel_shape, image_shape)[source]¶ Generate mask
This method generates an image mask.
Parameters: Returns: Return type: np.ndarray boolean mask
-
sf_tools.image.distort.
roll_sequence
(data_shape)[source]¶ Roll sequence
This method generates the roll sequence for a 2D array.
Parameters: data_shape (tuple) – Shape of data Returns: Return type: list of roll radii
-
sf_tools.image.distort.
kernel_pattern
(kernel_shape, mask)[source]¶ Kernel pattern
This method generates the kernel pattern. Rather than padding the kernel with zeroes to match the image size one simply extracts the series of repitions of the base kernel patterns.
Parameters: - kernel_shape (tuple) – Shape of kernel
- mask (np.ndarray) – Boolean mask
Returns: Return type: np.ndarray kernel pattern
-
sf_tools.image.distort.
rearrange_kernel
(kernel, data_shape=None)[source]¶ Rearrange kernel
This method rearanges the input kernel elements for vector multiplication. The input kernel is padded with zeroes to match the image size.
Parameters: - kernel (np.ndarray) – Input kernel array
- data_shape (tuple) – Shape of the data
Returns: Return type: np.ndarray rearanged matrix of kernel elements