我在iOS中使用什么设置来捕获RAW而不降低噪声,但看起来与BGRA相同?

Vad*_*ick 11 iphone avfoundation ios dng cifilter

我们可以要求AVFoundation以BGRA等处理格式捕获照片,或要求它捕获RAW,然后使用Core Image将其处理到BGRA.后者让我们控制过程中使用的参数,而不是让它保持iOS使用的默认值.

在我的情况下,我想关闭降噪,但其他方面的图像与BGRA相似.所以我尝试过:

let rawData = AVCapturePhotoOutput.dngPhotoDataRepresentation(forRawSampleBuffer: self,
                                                                     previewPhotoSampleBuffer: nil)!
let options: [AnyHashable : Any] = [
  kCIInputNoiseReductionAmountKey: 0.0,
  kCIInputLuminanceNoiseReductionAmountKey: 0.0,
  kCIInputColorNoiseReductionAmountKey: 0.0]

let rawFilter = CIFilter(imageData: rawData, options: options)!
let outputImage = rawFilter.outputImage!
let context = CIContext()
let cgImage = context.createCGImage(outputImage, from: outputImage.extent)!
let uiImage = UIImage(cgImage: cgImage)
let data = UIImageJPEGRepresentation(uiImage, jpegQuality)!
// Save the data using PHPhotoLibrary
Run Code Online (Sandbox Code Playgroud)

但这会导致看起来更亮的RAW ......

在此输入图像描述

......比BGRA:

在此输入图像描述

右键单击照片并在新选项卡中打开以查看差异.

这只是一张照片,作为一个例子.我测试了许多不同的场景,发现无论我尝试什么设置,我都无法匹配JPEG的质量 - 它太亮,太暗,或者对比度太大等等.

然后我注意到有一个输入boost参数,默认值为1表示完全提升,所以我将其设置为0:

let options: [AnyHashable: Any] = [kCIInputBoostKey: 0.0]
Run Code Online (Sandbox Code Playgroud)

但这产生了一个没有足够对比度的暗淡图像:

在此输入图像描述

因此,问题是我应该使用什么设置让Core Image以与AVFoundation捕获的BGRA相同的视觉外观开发RAW到BGRA,除非没有降噪.