ImageTransformer

class ImageTransformer.ImageTransformer(inputCol='image', outputCol=None, stages=None)[source]

Bases: mmlspark._ImageTransformer._ImageTransformer

Resizes the image to the given width and height

Parameters:
  • height (int) – The height to resize to (>=0)
  • width (int) – The width to resize to (>=0)
blur(height, width)[source]

Blurs the image using a normalized box filter

Parameters:
  • height (double) – The height of the box filter (>= 0)
  • width (double) – The width of the box filter (>= 0)
colorFormat(format)[source]

Formats the image to the given image format

Parameters:format (int) – The format to convert to, please see OpenCV cvtColor function documentation for all formats
crop(x, y, height, width)[source]

Crops the image given the starting x,y coordinates and the width and height

Parameters:
  • x (int) – The initial x coordinate (>=0)
  • y (int) – The initial y coordinate (>=0)
  • height (int) – The height to crop to (>=0)
  • width (int) – The width to crop to (>=0)
flip(flipCode=1)[source]
gaussianKernel(appertureSize, sigma)[source]

Blurs the image by applying a gaussian kernel

Parameters:
  • appertureSize (double) – The aperture size, which should be odd and positive
  • sigma (double) – The standard deviation of the gaussian
resize(height, width)[source]

Resizes the image to the given width and height

Parameters:
  • height (int) – The height to resize to (>=0)
  • width (int) – The width to resize to (>=0)
threshold(threshold, maxVal, thresholdType)[source]

Thresholds the image, please see OpenCV threshold function documentation for more information

Parameters:
  • threshold – (double) The threshold value
  • maxVal (double) – The maximum value to use
  • thresholdType (double) – The type of threshold, can be binary, binary_inv, trunc, zero, zero_inv
ImageTransformer.toImage(array, path='', mode=16)[source]

Converts a one-dimensional array to a 2 dimensional image

Parameters:
  • array (array) –
  • path (str) –
  • ocvType (int) –
Returns:

2 dimensional image

Return type:

object

ImageTransformer.toNDArray(image)[source]

Converts an image to a 1-dimensional array

Parameters:image (object) – The image to be converted
Returns:The image as a 1-dimensional array
Return type:array