---
title: "transform(_:interpolation:backgroundColor:destination:)"
framework: accelerate
role: symbol
role_heading: Instance Method
path: "accelerate/vimage/pixelbuffer/transform(_:interpolation:backgroundcolor:destination:)-79mov"
---

# transform(_:interpolation:backgroundColor:destination:)

Applies a perspective warp to a floating-point 16-bit planar image.

## Declaration

```swift
func transform(_ transform: vImage_PerpsectiveTransform, interpolation: vImage_PerpsectiveTransform.Interpolation, backgroundColor: Pixel_16F, destination: vImage.PixelBuffer<Format>)
```

## Parameters

- `transform`: The projective-transformation matrix that the function applies.
- `interpolation`: An enumeration that specifies the interpolation mode.
- `backgroundColor`: The background color.
- `destination`: The destination pixel buffer.

## Discussion

Discussion Use this function to apply a projective-transformation structure to a pixel buffer. Projective transformations warp an image in 3D and allow you to, for example, map a 2D asset to an image of a billboard or television screen. The following code defines source and destination quadrilaterals that specify a projective-transformation structure: let sourceQuadrilateral = (CGPoint(x: 0, y: 0),             // Top-left.                            CGPoint(x: 1000, y: 0),          // Top-right.                            CGPoint(x: 1000, y: 1000),       // Bottom-right.                            CGPoint(x: 0, y: 1000))          // Bottom-left.

let destinationQuadrilateral = (CGPoint(x: 300, y: 375),    // Top-left.                                 CGPoint(x: 700, y: 125),    // Top-right.                                 CGPoint(x: 700, y: 875),    // Bottom-right.                                 CGPoint(x: 300, y: 625))    // Bottom-left.

guard let warp = vImage_PerpsectiveTransform(     source: sourceQuadrilateral,     destination: destinationQuadrilateral) else {     return } You pass the vImage_PerpsectiveTransform structure to this function to apply the warp to the source pixel buffer and write the result to the destination buffer. sourceBuffer.transform(warp,                        interpolation: .linear,                        backgroundColor: backgroundColor,                        destination: destinationBuffer) The illustration below shows the original image on the left and the warped image on the right:

important: This function doesn’t work in place — that is, the source and destination buffers need to point to different memory.

## See Also

### Related Documentation

- [Transforming an image in three dimensions](accelerate/transforming-an-image-in-three-dimensions.md)

### Applying projective transformations to images

- [transform(_:interpolation:backgroundColor:destination:)](accelerate/vimage/pixelbuffer/transform(_:interpolation:backgroundcolor:destination:)-94t75.md)
- [transform(_:interpolation:backgroundColor:destination:)](accelerate/vimage/pixelbuffer/transform(_:interpolation:backgroundcolor:destination:)-902c9.md)
- [transform(_:interpolation:backgroundColor:destination:)](accelerate/vimage/pixelbuffer/transform(_:interpolation:backgroundcolor:destination:)-9pv8u.md)
- [transform(_:interpolation:backgroundColor:destination:)](accelerate/vimage/pixelbuffer/transform(_:interpolation:backgroundcolor:destination:)-4wvdj.md)
- [transform(_:interpolation:backgroundColor:destination:)](accelerate/vimage/pixelbuffer/transform(_:interpolation:backgroundcolor:destination:)-7qnl8.md)
