Type Method

filterWithImageURL:options:

A filter which allows the processing of RAW images

Declaration

+ (CIFilter *)filterWithImageURL:(NSURL *)url options:(NSDictionary<CIRAWFilterOption, id> *)options;

Parameters

url

The location of a RAW image file.

options

An options dictionary. You can pass any of the keys defined in RAW Image Options.

Return Value

A CIFilter object.

Discussion

The first step when working with RAW images in Core Image is to process the image using either filterWithImageData:options: or filterWithImageURL:options:. These initializers create a CIFilter object with an outputImage which is a CIImage representation of the supplied RAW image.

The newly created filter object allows you fine control over the image processing that isn't available when working with processed images such a JPEG. The following listing shows how to create a Core Image filter based on a URL named imageURL. The image is processed so that its neutral temperature is set to 2,000 Kelvin (giving a blue tint) and its baseline exposure doubled. Finally, a Core Image vignette filter is applied to the processed image in the same way it would be with any other source image:

Listing 1

Processing a RAW image.

let rawFilter = CIFilter(imageURL: imageURL, options: nil)
rawFilter?.setValue(2000,    
                    forKey: kCIInputNeutralTemperatureKey)
if let baselineExposure = rawFilter?.value(forKey: kCIInputBaselineExposureKey) as? NSNumber {    
    rawFilter?.setValue(baselineExposure.doubleValue * 2.5,                        forKey: kCIInputBaselineExposureKey)
}
let vignettedImage = rawFilter?.outputImage?.applyingFilter(    
    "CIVignette",    
    withInputParameters: [kCIInputIntensityKey: 5])
if let outputImage = vignettedImage {    
    imageView.image = UIImage(ciImage: outputImage)
}

See Also

Creating a Filter from a RAW Image

+ filterWithImageData:options:

A filter which allows the processing of RAW images

+ filterWithCVPixelBuffer:properties:options:

Creates a filter from a Core Video pixel buffer.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software