multiply(by:preBias:postBias:destination:)
Multiplies each pixel in a 32-bit planar pixel buffer by the specified factor.
Declaration
func multiply(by factor: Float, preBias: Float, postBias: Float, destination: vImage.PixelBuffer<vImage.PlanarF>)Parameters
- factor:
The multiplication factor.
- preBias:
A value that the function adds to the source before multiplication.
- postBias:
A value that the function adds to the result after multiplication.
- destination:
The destination pixel buffer.
Discussion
This function applies the following operation to each pixel:
destination = ((source + preBias) * factor) + postBiasFor example, the following code multiplies each pixel value in a 32-bit planar buffer by 2:
let buffer = vImage.PixelBuffer<vImage.PlanarF>(
pixelValues: [0.1, 0.2, 0.3, 0.4, 0.5],
size: vImage.Size(width: 5,
height: 1))
buffer.multiply(by: 2,
preBias: 0, postBias: 0,
destination: buffer)
// Prints "[0.2, 0.4, 0.6, 0.8, 1.0]"
print(buffer.array)