<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: -",
    "watchOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Accelerate",
  "identifier" : "/documentation/Accelerate/vImage/PixelBuffer/transform(_:interpolation:backgroundColor:destination:)-902c9",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Accelerate"
    ],
    "preciseIdentifier" : "s:10Accelerate6vImageO11PixelBufferVAaC14Interleaved8x4VRszrlE9transform_13interpolation15backgroundColor11destinationySo01vB21_PerpsectiveTransformV_AmAE13InterpolationOs5UInt8V_A3QtAEy_AGGtF"
  },
  "title" : "transform(_:interpolation:backgroundColor:destination:)"
}
-->

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

Applies a perspective warp to an interleaved 4-channel, 8-bit planar image.

```
func transform(_ transform: vImage_PerpsectiveTransform, interpolation: vImage_PerpsectiveTransform.Interpolation, backgroundColor: Pixel_8888, 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

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:

```swift
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.

```swift
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:

![Two versions of a grid divided by dotted lines into a 4 by 4 partition. The version on the left is a square grid and appears as a straight-on view. The version on the right is a square containing a grid warped so that the left edge of the square grid appears to be receding into the distance.](images/com.apple.accelerate/media-4165211@2x.png)

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

## See Also

  <doc://com.apple.accelerate/documentation/Accelerate/transforming-an-image-in-three-dimensions>



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)