MultiArray
public struct MultiArray<T: MultiArrayType>
Wrapper around MLMultiArray to make it more Swifty.
-
Undocumented
Declaration
Swift
public let array: MLMultiArray
-
Undocumented
Declaration
Swift
public let pointer: UnsafeMutablePointer<T>
-
Undocumented
Declaration
Swift
private(set) public var strides: [Int]
-
Undocumented
Declaration
Swift
private(set) public var shape: [Int]
-
Creates a new multi-array filled with all zeros.
Declaration
Swift
public init(shape: [Int])
-
Creates a new multi-array initialized with the specified value.
Declaration
Swift
public init(shape: [Int], initial: T)
-
Creates a multi-array that wraps an existing MLMultiArray.
Declaration
Swift
public init(_ array: MLMultiArray)
-
Returns the number of elements in the entire array.
Declaration
Swift
public var count: Int
-
Returns a transposed version of this array. NOTE: The new array still uses the same underlying storage (the same MLMultiArray object).
Declaration
Swift
public func transposed(_ order: [Int]) -> MultiArray
-
Changes the number of dimensions and their sizes.
Declaration
Swift
public func reshaped(_ dimensions: [Int]) -> MultiArray
-
Declaration
Swift
public var description: String
-
Converts the multi-array to a UIImage.
Use the
offset
andscale
parameters to put the values from the array in the range [0, 255]. The offset is added first, then the result is multiplied by the scale.For example: if the range of the data is [0, 1), use
offset: 0
andscale: 255
. If the range is [-1, 1], useoffset: 1
andscale: 127.5
.Declaration
Swift
public func image(offset: T, scale: T) -> UIImage?
-
Converts the multi-array into an array of RGBA pixels.
Note
The multi-array must have shape (3, height, width). If your array has a different shape, usereshape()
ortranspose()
first.Declaration
Swift
public func toRawBytesRGBA(offset: T, scale: T) -> (bytes: [UInt8], width: Int, height: Int)?
-
Converts the multi-array into an array of grayscale pixels.
Note
The multi-array must have shape (height, width). If your array has a different shape, usereshape()
ortranspose()
first.Declaration
Swift
public func toRawBytesGray(offset: T, scale: T) -> (bytes: [UInt8], width: Int, height: Int)?
-
Converts a single channel from the multi-array to a grayscale UIImage.
Note
The multi-array must have shape (channels, height, width). If your array has a different shape, usereshape()
ortranspose()
first.Declaration
Swift
public func image(channel: Int, offset: T, scale: T) -> UIImage?