Functions

The following functions are available globally.

  • Ensures that x is in the range [min, max].

    Declaration

    Swift

    public func clamp<T>(_ x: T, min: T, max: T) -> T where T : Comparable
  • Fast conversion from MLMultiArray to CGImage using the vImage framework.

    Declaration

    Swift

    public func createCGImage(fromFloatArray features: MLMultiArray,
                              min: Float = 0,
                              max: Float = 255) -> CGImage?

    Parameters

    features

    A multi-array with data type FLOAT32 and three dimensions (3, height, width).

    min

    The smallest value in the multi-array. This value, as well as any smaller values, will be mapped to 0 in the output image.

    max

    The largest value in the multi-array. This and any larger values will be will be mapped to 255 in the output image.

    Return Value

    a new CGImage or nil if the conversion fails

  • Undocumented

    Declaration

    Swift

    public func createUIImage(fromFloatArray features: MLMultiArray,
                              min: Float = 0,
                              max: Float = 255) -> UIImage?