scikit-ipp API

skipp.filters

gaussian

skipp.filters.gaussian(image, sigma, output, mode, cval, multichannel, preserve_range, truncate)

Gaussian filter. The function has skimage.filters.gaussian like signature, see: https://scikit-image.org/ :param image: Input image (grayscale or color) to filter. :type image: array-like :param sigma: Standard deviation for Gaussian kernel. :type sigma: scalar, optional :param output: The output parameter passes an array in which to store the

filter output.

Parameters
  • mode ({'constant', 'nearest', 'mirror'}, optional) – The mode parameter determines how the array borders are handled, where cval is the value when mode is equal to ‘constant’. Default is ‘nearest’.

  • cval (scalar, optional) – Value to fill past edges of input if mode is ‘constant’. Default is 0.0

  • multichannel (bool, optional (default: None)) –

  • preserve_range (bool, optional) –

  • truncate (float, optional) – Truncate the filter at this many standard deviations.

Returns

filtered_image – the filtered image array

Return type

ndarray

Notes

This function uses Intel(R) Integrated Performance Primitives (Intel(R) IPP) funcs: ippiFilterGaussianBorder_<mod> on the backend, that performs Gaussian filtering of an image with user-defined borders, see: FilterGaussianBorder on https://software.intel.com/content/www/us/en/develop/documentation/ipp-dev-reference/ - The image should be a numpy array with uint8, uint16, int16 or float32

dtype.

  • Currently output, multichannel and preserve_range are not processed.

Examples

>>> a = np.zeros((3, 3), dtype=np.float32)
>>> a[1, 1] = 1
>>> a
array([[0., 0., 0.],
       [0., 1., 0.],
       [0., 0., 0.]])
>>> gaussian(a, sigma=0.4)  # mild smoothing
array([[0.00163118, 0.03712554, 0.00163118],
       [0.03712554, 0.844973  , 0.03712554],
       [0.00163118, 0.03712554, 0.00163118]], dtype=float32)
>>> gaussian(a, sigma=1)  # more smoothing
array([[0.05858153, 0.09658462, 0.05858153],
       [0.09658462, 0.15924111, 0.09658462],
       [0.05858153, 0.09658462, 0.05858153]], dtype=float32)
>>> # Several modes are possible for handling boundaries
>>> gaussian(a, sigma=1, mode='nearest')
array([[0.05858153, 0.09658462, 0.05858153],
       [0.09658462, 0.15924111, 0.09658462],
       [0.05858153, 0.09658462, 0.05858153]], dtype=float32)

median

skipp.filters.median(image, selem, out, mask, shift_x, shift_y, mode, cval, behavior)

Median filter. Return local median of an image. The function has skimage.filters.median like signature, see: https://scikit-image.org/ :param image: Input image. :type image: array-like :param selem: If behavior=='ipp', selem is a 2-D array of 1’s and 0’s. :type selem: ndarray, optional :param out: If None, a new array is allocated. :type out: ndarray, (same dtype as image), optional :param mode: The mode parameter determines how the array borders are handled, where

cval is the value when mode is equal to ‘constant’. Default is ‘nearest’.

Parameters
  • cval (scalar, optional) – Value to fill past edges of input if mode is ‘constant’. Default is 0.0

  • behavior ({'ipp'}, optional) –

Returns

out – Output image.

Return type

2-D array (same dtype as input image)

Notes

This function uses Intel(R) Integrated Performance Primitives (Intel(R) IPP) funcs: ippiFilterMedianBorder_<mod> on the backend, that performs median filtering of an image with user-defined borders, see: FilterMedianBorder on https://software.intel.com/content/www/us/en/develop/documentation/ipp-dev-reference/ - The image should be a numpy array with uint8, uint16, int16 or float32

dtype.

  • Currently out and behavior are not processed. The behavior disabled due to only one option existence, default is ipp The mask, shift_x and shift_y are not processed - will be deprecated since scikit-image v0.17.

  • skimage.filters.median requiers the image, that should be a 2-dimensional array. skipp.filters.median can also processing also multichannel (3-channel) images.

  • scikit-ipp supports only recantagle shape selem with ones.

  • Indicates an error if selem shape has a field with a zero, negative or even value.

Examples

>>> from skimage import data
>>> import numpy as np
>>> from skipp.filters import median
>>> img = data.camera()
>>> mask = np.ones((5,5), dtype=np.uint8, order='C')
>>> med = median(img, mask)

laplace

skipp.filters.laplace(image, ksize, mask)

Find the edges of an image using the Laplace operator. The function has skimage.filters.laplace like signature, see: https://scikit-image.org/ :param image: Image to process. :type image: ndarray :param ksize: Define the size of the discrete Laplacian operator such that it

will have a size of (ksize,) * image.ndim.

Parameters

mask (ndarray, optional) – An optional mask to limit the application to a certain area. Note that pixels surrounding masked regions are also masked to prevent masked regions from affecting the result.

Returns

output – The Laplace edge map. Same dtype as image

Return type

ndarray

Notes

This function uses Intel(R) Integrated Performance Primitives (Intel(R) IPP) funcs: ippiFilterBorder_<mod> on the backend, that filters an image using a rectangular filter with coeffs (Laplace (3x3)):

| 0  -1   0 |
|-1   4  -1 |
| 0  -1   0 |

for implementing laplace filtering as is in scikit-image, see: FilterBorder on https://software.intel.com/content/www/us/en/develop/documentation/ipp-dev-reference/ - Currently converting integer images into float32 is not supported. - The image should be a numpy array with uint8, uint16, int16 or float32

dtype.

Examples

>>> from skimage import data
>>> import numpy as np
>>> from skipp.filters import laplace
>>> img = data.camera().astype(np.float32)
>>> lap = laplace(img)

sobel

skipp.filters.sobel(image, mask)

Find edges in an image using the Sobel filter. The function has skimage.filters.sobel like signature, see: https://scikit-image.org/ :param image: Image to process. :type image: 2-D array :param mask: An optional mask to limit the application to a certain area.

Note that pixels surrounding masked regions are also masked to prevent masked regions from affecting the result.

Returns

output – The Sobel edge map.

Return type

2-D array of float32

Notes

This function uses Intel(R) Integrated Performance Primitives (Intel(R) IPP) funcs: ippiFilterSobel_<mod> on the backend, see: FilterSobel on https://software.intel.com/content/www/us/en/develop/documentation/ipp-dev-reference/ - Currently converting integer images into float32 is not supported. - The image should be an array of numpy.float32 dtype. - skimage.filters.sobel is a wrapper on scipy.ndimage

convolve func. convolve uses reflect border mode. reflect border mode is equivalent of Intel(R) IPP ippBorderMirrorR border type. ippiFilterSobel_<mode> doesn’t supports this border type.

Take the square root of the sum of the squares of the horizontal and vertical Sobels to get a magnitude that’s somewhat insensitive to direction. The 3x3 convolution kernel used in the horizontal and vertical Sobels is an approximation of the gradient of the image (with some slight blurring since 9 pixels are used to compute the gradient at a given pixel). As an approximation of the gradient, the Sobel operator is not completely rotation-invariant.

Examples

>>> from skimage import data
>>> from skipp.filters import sobel
>>> camera = data.camera().astype(np.float32)
>>> edges = sobel(camera)

sobel_h

skipp.filters.sobel_h(image, mask)

Find the horizontal edges of an image using the Sobel transform. The function has skimage.filters.sobel_h like signature, see: https://scikit-image.org/ :param image: Image to process. :type image: 2-D array :param mask: An optional mask to limit the application to a certain area.

Note that pixels surrounding masked regions are also masked to prevent masked regions from affecting the result.

Returns

output – The Sobel edge map.

Return type

2-D array

Notes

This function uses Intel(R) Integrated Performance Primitives (Intel(R) IPP) funcs: ippiFilterSobelHorizBorder_<mod> on the backend, see: FilterSobelHorizBorder on https://software.intel.com/content/www/us/en/develop/documentation/ipp-dev-reference/ We use the following kernel:

| 1   2   1 |
| 0   0   0 |
|-1  -2  -1 |
  • Currently converting integer images into float32 is not supported.

  • The image should be an array of numpy.float32 dtype.

  • skimage.filters.sobel_h is a wrapper on scipy.ndimage convolve func. convolve uses reflect border mode. reflect border mode is equivalent of Intel(R) IPP ippBorderMirrorR border type. ippiFilterSobelHorizBorder_<mode> doesn’t supports this border type.

Examples

>>> from skimage import data
>>> from skipp.filters import sobel_h
>>> camera = data.camera().astype(np.float32)
>>> edges = sobel_h(camera)

sobel_v

skipp.filters.sobel_v(image, mask)

Find the vertical edges of an image using the Sobel transform. The function has skimage.filters.sobel_v like signature, see: https://scikit-image.org/ :param image: Image to process. :type image: 2-D array :param mask: An optional mask to limit the application to a certain area.

Note that pixels surrounding masked regions are also masked to prevent masked regions from affecting the result.

Returns

output – The Sobel edge map.

Return type

2-D array

Notes

This function uses Intel(R) Integrated Performance Primitives (Intel(R) IPP) funcs: ippiFilterSobelVertBorder_<mod> on the backend, see: FilterSobelVertBorder on https://software.intel.com/content/www/us/en/develop/documentation/ipp-dev-reference/ We use the following kernel:

| 1   0  -1 |
| 2   0  -2 |
| 1   0  -1 |
  • Currently converting integer images into float32 is not supported.

  • The image should be an array of numpy.float32 dtype.

  • skimage.filters.sobel_v is a wrapper on scipy.ndimage convolve func. convolve uses reflect border mode. reflect border mode is equivalent of Intel(R) IPP ippBorderMirrorR border type. ippiFilterSobelVertBorder_<mode> doesn’t supports this border type.

Examples

>>> from skimage import data
>>> from skipp.filters import sobel_v
>>> camera = data.camera().astype(np.float32)
>>> edges = sobel_v(camera)

prewitt

skipp.filters.prewitt(image, mask)

Find the edge magnitude using the Prewitt transform. The function has skimage.filters.prewitt like signature, see: https://scikit-image.org/ :param image: Image to process. :type image: 2-D array :param mask: An optional mask to limit the application to a certain area.

Note that pixels surrounding masked regions are also masked to prevent masked regions from affecting the result.

Returns

output – The Prewitt edge map.

Return type

2-D array

Notes

This function uses Intel(R) Integrated Performance Primitives (Intel(R) IPP) funcs: ippiFilterPrewittVertBorder_<mod> and ippiFilterPrewittHorizBorder_<mod> on the backend see: FilterPrewittHorizBorder, FilterPrewittVertBorder https://software.intel.com/content/www/us/en/develop/documentation/ipp-dev-reference/ Return the square root of the sum of squares of the horizontal and vertical Prewitt transforms. The edge magnitude depends slightly on edge directions, since the approximation of the gradient operator by the Prewitt operator is not completely rotation invariant. - Currently converting integer images into float32 is not supported. - The image should be an array of numpy.float32 dtype. - skimage.filters.prewitt is a wrapper on scipy.ndimage

convolve func. convolve uses reflect border mode. reflect border mode is equivalent of Intel(R) IPP ippBorderMirrorR border type. ippiFilterPrewittVertBorder_<mode> and ippiFilterPrewittHorizBorder_<mode> don’t support this border type.

Examples

>>> from skimage import data
>>> from skipp.filters import prewitt
>>> camera = data.camera().astype(np.float32)
>>> edges = prewitt(camera)

prewitt_h

skipp.filters.prewitt_h(image, mask)

Find the horizontal edges of an image using the Prewitt transform. The function has skimage.filters.prewitt_h like signature, see: https://scikit-image.org/ :param image: Image to process. :type image: 2-D array :param mask: An optional mask to limit the application to a certain area.

Note that pixels surrounding masked regions are also masked to prevent masked regions from affecting the result.

Returns

output – The Prewitt edge map.

Return type

2-D array

Notes

This function uses Intel(R) Integrated Performance Primitives (Intel(R) IPP) funcs: ippiFilterPrewittHorizBorder_<mod> on the backend see: FilterPrewittHorizBorder https://software.intel.com/content/www/us/en/develop/documentation/ipp-dev-reference/ We use the following kernel:

| 1   1   1 |
| 0   0   0 |
|-1  -1  -1 |
  • Currently converting integer images into float32 is not supported.

  • The image should be an array of numpy.float32 dtype.

  • skimage.filters.prewitt_h is a wrapper on scipy.ndimage convolve func. convolve uses reflect border mode. reflect border mode is equivalent of Intel(R) IPP ippBorderMirrorR border type. ippiFilterPrewittHorizBorder_<mode> doesn’t support this border type.

Examples

>>> from skimage import data
>>> from skipp.filters import prewitt_h
>>> camera = data.camera().astype(np.float32)
>>> edges = prewitt_h(camera)

prewitt_v

skipp.filters.prewitt_v(image, mask)

Find the vertical edges of an image using the Prewitt transform. The function has skimage.filters.prewitt_v like signature, see: https://scikit-image.org/ :param image: Image to process. :type image: 2-D array :param mask: An optional mask to limit the application to a certain area.

Note that pixels surrounding masked regions are also masked to prevent masked regions from affecting the result.

Returns

output – The Prewitt edge map.

Return type

2-D array

Notes

This function uses Intel(R) Integrated Performance Primitives (Intel(R) IPP) funcs: ippiFilterPrewittVertBorder_<mod> on the backend see: FilterPrewittVertBorder https://software.intel.com/content/www/us/en/develop/documentation/ipp-dev-reference/ We use the following kernel:

| 1   0  -1 |
| 1   0  -1 |
| 1   0  -1 |
  • Currently converting integer images into float32 is not supported.

  • The image should be an array of numpy.float32 dtype.

  • skimage.filters.prewitt_v is a wrapper on scipy.ndimage convolve func. convolve uses reflect border mode. reflect border mode is equivalent of Intel(R) IPP ippBorderMirrorR border type. ippiFilterPrewittVertBorder_<mode> doesn’t support this border type.

Examples

>>> from skimage import data
>>> from skipp.filters import prewitt_v
>>> camera = data.camera().astype(np.float32)
>>> edges = prewitt_v(camera)

skipp.morphology

erosion

skipp.morphology.erosion(image, selem, out, shift_x, shift_y)

Return greyscale morphological erosion of an image.

Morphological erosion sets a pixel at (i,j) to the minimum over all pixels in the neighborhood centered at (i,j). Erosion shrinks bright regions and enlarges dark regions.

The function has skimage.morphology.erosion like signature, see: https://scikit-image.org/

Parameters
  • image (ndarray) – Image array.

  • selem (ndarray, optional) – The neighborhood expressed as an array of 1’s and 0’s. If None, use cross-shaped structuring element (connectivity=1).

  • out (ndarrays, optional) – The array to store the result of the morphology. If None is passed, a new array will be allocated.

  • shift_y (shift_x,) – shift structuring element about center point. This only affects eccentric structuring elements (i.e. selem with even numbered sides).

Returns

eroded – The result of the morphological erosion.

Return type

array, same shape and type as image

Notes

This function uses Intel(R) Integrated Performance Primitives (Intel(R) IPP) funcs: ippiErodeBorder_<mod> on the backend, that performs dilation of an image, see: ErodeBorder on https://software.intel.com/content/www/us/en/develop/documentation/ipp-dev-reference/

  • The selem should be only uint8 dtype.

  • The image and out should be the same data type

  • Currently dilation function supports image of the following types: - one channel image: uint8, uint16, int16, float32 - three channel image: uint8, float32 - four channel image: uint8, float32

  • Currently out, shift_x, shift_y are not processed.

  • If selem is None: scikit-ipp creates directly ndarray with shape (3, 3) like a skimage.morphology.selem.diamond(radius=1) for 2D grayscale images and ndarray with shape (3, 3, 3) like a (`skimage.morphology.selem.diamond(radius=1) for each channel).

Examples

>>> # Erosion shrinks bright regions
>>> import numpy as np
>>> from skimage.morphology import square
>>> from skipp.morphology import erosion
>>> bright_square = np.array([[0, 0, 0, 0, 0],
...                           [0, 1, 1, 1, 0],
...                           [0, 1, 1, 1, 0],
...                           [0, 1, 1, 1, 0],
...                           [0, 0, 0, 0, 0]], dtype=np.uint8)
>>> erosion(bright_square, square(3))
array([[0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0],
       [0, 0, 1, 0, 0],
       [0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0]], dtype=uint8)

dilation

skipp.morphology.dilation(image, selem, out, shift_x, shift_y)

Return greyscale morphological dilation of an image.

Morphological dilation sets a pixel at (i,j) to the maximum over all pixels in the neighborhood centered at (i,j). Dilation enlarges bright regions and shrinks dark regions.

The function has skimage.morphology.dilation like signature, see: https://scikit-image.org/

Parameters
  • image (ndarray) – Image array.

  • selem (ndarray, optional) – The neighborhood expressed as a 2-D array of 1’s and 0’s. If None, use cross-shaped structuring element (connectivity=1).

  • out (ndarray, optional) – The array to store the result of the morphology. If None, is passed, a new array will be allocated. Should be the same type and shape as image.

  • shift_y (shift_x,) – shift structuring element about center point. This only affects eccentric structuring elements (i.e. selem with even numbered sides).

Returns

dilated – The result of the morphological dilation.

Return type

array, same shape and type as image

Notes

This function uses Intel(R) Integrated Performance Primitives (Intel(R) IPP) funcs: ippiDilateBorder_<mod> on the backend, that performs dilation of an image, see: DilateBorder on https://software.intel.com/content/www/us/en/develop/documentation/ipp-dev-reference/

  • The selem should be only uint8 dtype.

  • The image and out should be the same data type

  • Currently dilation function supports image of the following types: - one channel image: uint8, uint16, int16, float32 - three channel image: uint8, float32 - four channel image: uint8, float32

  • Currently out, shift_x, shift_y are not processed.

  • If selem is None: scikit-ipp creates directly ndarray with shape (3, 3) like a skimage.morphology.selem.diamond(radius=1) for 2D grayscale images and ndarray with shape (3, 3, 3) like a (`skimage.morphology.selem.diamond(radius=1) for each channel).

Examples

>>> # Dilation enlarges bright regions
>>> import numpy as np
>>> from skimage.morphology import square
>>> from skipp.morphology import dilation
>>> bright_pixel = np.array([[0, 0, 0, 0, 0],
...                          [0, 0, 0, 0, 0],
...                          [0, 0, 1, 0, 0],
...                          [0, 0, 0, 0, 0],
...                          [0, 0, 0, 0, 0]], dtype=np.uint8)
>>> dilation(bright_pixel, square(3))
array([[0, 0, 0, 0, 0],
       [0, 1, 1, 1, 0],
       [0, 1, 1, 1, 0],
       [0, 1, 1, 1, 0],
       [0, 0, 0, 0, 0]], dtype=uint8)

skipp.transform

class AffineTransform

class skipp.transform.AffineTransform

2D affine transformation.

The same interface as is for skimage.transform.AffineTransform, see: https://scikit-image.org/

Has the following form:

X = a0*x + a1*y + a2 =
  = sx*x*cos(rotation) - sy*y*sin(rotation + shear) + a2

Y = b0*x + b1*y + b2 =
  = sx*x*sin(rotation) + sy*y*cos(rotation + shear) + b2

where sx and sy are scale factors in the x and y directions, and the homogeneous transformation matrix is:

[[a0  a1  a2]
 [b0  b1  b2]
 [0   0    1]]
Parameters
  • matrix ((3, 3) array, optional) – Homogeneous transformation matrix.

  • scale ((sx, sy) as array, list or tuple, optional) – Scale factors.

  • rotation (float, optional) – Rotation angle in counter-clockwise direction as radians.

  • shear (float, optional) – Shear angle in counter-clockwise direction as radians.

  • translation ((tx, ty) as array, list or tuple, optional) – Translation parameters.

params

Homogeneous transformation matrix.

Type

(3, 3) array

__add__(other)

Combine this transformation with another.

inverse(coords)

Apply inverse transformation. :param coords: Destination coordinates. :type coords: (N, 2) array

Returns

coords – Source coordinates.

Return type

(N, 2) array

warp

skipp.transform.warp(image, inverse_map, map_args, output_shape, order, mode, cval, clip, preserve_range)

Warp an image according to a given coordinate transformation.

The function has skimage.transform.warp like signature, see: https://scikit-image.org/

Parameters
  • image (ndarray) – Input image.

  • inverse_map (transformation object or ndarray) –

    Inverse coordinate map, which transforms coordinates in the output images into their corresponding coordinates in the input image. There are a number of different options to define this map, depending on the dimensionality of the input image. A 2-D image can have 2 dimensions for gray-scale images, or 3 dimensions with color information.

    • For 2-D images, you can directly pass a transformation object, e.g. skipp.transform.AffineTransform.

    • For 2-D images, you can pass a (3, 3) homogeneous transformation matrix, e.g. skipp.transform.AffineTransform.params.

    Note, that a (3, 3) matrix is interpreted as a homogeneous transformation matrix. See example section for usage.

  • map_args (dict, optional) – Keyword arguments passed to inverse_map.

  • output_shape (tuple (rows, cols), optional) – Shape of the output image generated. By default the shape of the input image is preserved. Note that, even for multi-band images, only rows and columns need to be specified.

  • order (int, optional) –

    The order of interpolation. The order has to be in the range 0-5:
    • 0: Nearest-neighbor

    • 1: linear (default)

    • 2: Bi-quadratic [not supported]

    • 3: cubic

    • 4: Bi-quartic [not supported]

    • 5: Bi-quintic [not supported]

  • mode ({'constant', 'edge', 'transp'}, optional) – Points outside the boundaries of the input are filled according to the given mode.

  • cval (float, optional) – Used in conjunction with mode ‘constant’, the value outside the image boundaries.

  • clip (bool, optional) – Whether to clip the output to the range of values of the input image. This is enabled by default, since higher order interpolation may produce values outside the given input range.

  • preserve_range (bool, optional) – Whether to keep the original range of values.

Returns

warped – The warped input image, same type as image.

Return type

ndarray

Notes

This function uses Intel(R) Integrated Performance Primitives (Intel(R) IPP) funcs: ippiWarpAffineLinear_<mod>, ippiWarpAffineNearest_<mod> and ippiWarpAffineCubic_<mod> on the backend, that performs warp affine transformation of an image using the linear, nearest neighbor or cubic interpolation method, see: WarpAffineLinear, WarpAffineCubic, WarpAffineNearest on https://software.intel.com/content/www/us/en/develop/documentation/ipp-dev-reference/

  • transform.warp function gets an upper bound on the number of threads that could be used, and takes it for improving performance of warping by using OpenMP with parallelization. It divides the processing of the destination (output) image into tiles in the number of available threads, for processing each tile separately on each thread. The number of tiles corresponds to the number of available threads. If it is possible it uses multiple threads for procesing all tiles simultaneously.

  • Currently warp function supports image of the following types for one, three and four channel images:

    uint8, uint16, int16, float32, float64

  • Currently modes don’t match the behaviour of numpy.pad.

  • Currently map_args, clip, preserve_range are not processed.

  • scikit-image uses Catmull-Rom spline (0.0, 0.5). In scikit-ipp the same method was implemented. [1]

References

1

Don P. Mitchell, Arun N. Netravali. Reconstruction Filters in Computer Graphics. Computer Graphics, Volume 22, Number 4, AT&T Bell Laboratories, Murray Hill, New Jersey, August 1988.

Examples

>>> from skipp.transform import warp
>>> from skimage import data
>>> image = data.camera()
>>> # The following image warps are all equal but differ substantially in
>>> # execution time. The image is shifted to the bottom.
>>> # Use a transformation matrix to warp an image (fast):
>>> matrix = np.array([[1, 0, 0], [0, 1, -10], [0, 0, 1]])
>>> warped = warp(image, matrix)
>>> # Use a geometric transform to warp an image (fast):
>>> from skipp.transform import AffineTransform
>>> tform = AffineTransform(translation=(0, -10))
>>> warped = warp(image, tform)

resize

skipp.transform.resize(image, output_shape, order, mode, cval, clip, preserve_range, anti_aliasing, anti_aliasing_sigma, num_lobes)

Resize image to match a certain size.

Performs interpolation to up-size or down-size 2D images. Note that anti-aliasing should be enabled when down-sizing images to avoid aliasing artifacts.

The function has skimage.transform.resize like signature, see: https://scikit-image.org/

Parameters
  • image (ndarray) – Input image.

  • output_shape (tuple (rows, cols), optional) – Shape of the output image generated. By default the shape of the input image is preserved. Note that, even for multi-band images, only rows and columns need to be specified.

Returns

resized – Resized version of the input.

Return type

ndarray

Other Parameters
  • order (int, optional) – The order of the spline interpolation, default is 1. The order has to be in the range 0-7:

    • 0: Nearest-neighbor

    • 1: Linear (default)

    • 2: Bi-quadratic [not supported]

    • 3: Cubic

    • 4: Bi-quartic [not supported]

    • 5: Bi-quintic [not supported]

    • 6: Lanczos

    • 7: Super

  • mode ({‘constant’, ‘edge’, ‘transp’}, optional) – Points outside the boundaries of the input are filled according to the given mode. Modes match the behaviour of numpy.pad.

  • cval (float, optional) – Used in conjunction with mode ‘constant’, the value outside the image boundaries.

  • clip (bool, optional) – Whether to clip the output to the range of values of the input image.

  • preserve_range (bool, optional) – Also see https://scikit-image.org/docs/dev/user_guide/data_types.html

  • anti_aliasing (bool, optional) – Whether to apply a Gaussian filter to smooth the image prior to down-scaling. It is crucial to filter when down-sampling the image to avoid aliasing artifacts.

  • anti_aliasing_sigma ({float, tuple of floats}, optional) – Standard deviation for Gaussian filtering to avoid aliasing artifacts.

  • num_lobes (int, optional) – Used in conjunction with order 6 (Lanczos). The parameter for specifying Lanczos (2 or 3) filters. Options:

    • 2: 2-lobed Lanczos 4x4

    • 3: 3-lobed Lanczos 6x6

Notes

This function uses Intel(R) Integrated Performance Primitives (Intel(R) IPP) funcs on the backend: ippiResizeNearest_<mod>, ippiResizeLinear_<mod>, ippiResizeCubic_<mod>, ippiResizeLanczos_<mod>, ippiResizeSuper_<mod> that changes an image size using nearest neighbor, linear, cubic, Lanczos or super interpolation method, and ippiResizeAntialiasing_<mod>, that changes an image size using using the linear and cubic interpolation method with antialiasing, see: ResizeNearest, ResizeLinear, ResizeCubic, ResizeLanczos, ResizeSuper,`ResizeAntialiasing` on https://software.intel.com/content/www/us/en/develop/documentation/ipp-dev-reference/

  • transform.resize function gets an upper bound on the number of threads that could be used, and takes it for improving performance of warping by using OpenMP with parallelization. It divides the processing of the destination (output) image into tiles in the number of available threads, for processing each tile separately on each thread. The number of tiles corresponds to the number of available threads. If it is possible it uses multiple threads for procesing all tiles simultaneously.

  • Currently resize function supports image of the following types for one, three and four channel images:

    uint8, uint16, int16, float32.

  • Currently modes don’t match the behaviour of numpy.pad.

  • Currently clip, preserve_range and anti_aliasing_sigma are not processed.

  • if antialiasing is True, supported interpolation methods are linear and cubic.

  • if antialiasing is False, supported interpolation methods are nearest, linear, cubic, Lanczos and super.

  • if antialiasing is True, supported boundary mode is edge.

  • if antialiasing is False, supported boundary mode is edge.

  • The Lanczos interpolation (order=6) have the following filter sizes: 2-lobed Lanczos 4x4, 3-lobed Lanczos 6x6.

  • Indicates an error (RuntimeError: ippStsSizeErr: Incorrect value for data size) in the following cases: - If the source image size is less than the filter size of the chosen

    interpolation method (except ippSuper).

    • If one of the specified dimensions of the source image is less than the corresponding dimension of the destination image (for ippSuper method only).

    • If the width or height of the source or destination image is negative.

Examples

>>> from skimage import data
>>> from skipp.transform import resize
>>> image = data.camera()
>>> resize(image, (100, 100)).shape
(100, 100)

rotate

skipp.transform.rotate(image, angle, resize, center, order, mode, cval, clip, preserve_range)

Rotate image by a certain angle around its center.

The function has skimage.transform.rotate like signature, see: https://scikit-image.org/

Parameters
  • image (ndarray) – Input 2D image.

  • angle (float) – Rotation angle in degrees in counter-clockwise direction.

  • resize (bool, optional) – Determine whether the shape of the output image will be automatically calculated, so the complete rotated image exactly fits. Default is False.

  • center (iterable of length 2) – The rotation center. If center=None, the image is rotated around its center, i.e. center=(cols / 2 - 0.5, rows / 2 - 0.5). Please note that this parameter is (cols, rows), contrary to normal skimage ordering.

Returns

rotated – Rotated version of the 2D input image.

Return type

ndarray

Other Parameters
  • order (int, optional) – The order of the spline interpolation, default is 1. The order has to be in the range 0-5:

    • 0: Nearest-neighbor

    • 1: linear (default)

    • 2: Bi-quadratic [not supported]

    • 3: cubic

    • 4: Bi-quartic [not supported]

    • 5: Bi-quintic [not supported]

  • mode ({‘edge’, ‘constant’, ‘transp’}, optional) – Points outside the boundaries of the input are filled according to the given mode.

  • cval (float, optional) – Used in conjunction with mode ‘constant’, the value outside the image boundaries.

  • clip (bool, optional) – Whether to clip the output to the range of values of the input image.

  • preserve_range (bool, optional) – Whether to keep the original range of values.

Notes

This function uses skipp.transform.warp on the backend, and skipp.transform.warp in turn uses Intel(R) Integrated Performance Primitives (Intel(R) IPP) funcs: ippiWarpAffineLinear_<mod>, ippiWarpAffineNearest_<mod> and ippiWarpAffineCubic_<mod> on the backend, that performs warp affine transformation of an image using the linear, nearest neighbor or cubic interpolation method, see: WarpAffineLinear, WarpAffineCubic, WarpAffineNearest on https://software.intel.com/content/www/us/en/develop/documentation/ipp-dev-reference/

  • Currently rotate function supports image of the following types for one, three and four channel images:

    uint8, uint16, int16, float32, float64

  • Currently modes don’t match the behaviour of numpy.pad.

  • Currently clip, preserve_range are not processed.

  • scikit-image uses Catmull-Rom spline (0.0, 0.5). In scikit-ipp the same method was implemented. [1]

  • Modificated version of skimage.transform.rotate (v0.17). scikit-ipp uses skipp.transform.AffineTransform instead of skimage.transform.SimilarityTransform

References

1

Don P. Mitchell, Arun N. Netravali. Reconstruction Filters in Computer Graphics. Computer Graphics, Volume 22, Number 4, AT&T Bell Laboratories, Murray Hill, New Jersey, August 1988.

Examples

>>> from skimage import data
>>> from skipp.transform import rotate
>>> image = data.camera()
>>> rotate(image, 2).shape
(512, 512)
>>> rotate(image, 2, resize=True).shape
(530, 530)
>>> rotate(image, 90, resize=True).shape
(512, 512)