简体   繁体   English

将 CIFilter 保存为 RAW 图像

[英]Save CIFilter as RAW image

So CIFilter takes in a RAW DNG image.所以CIFilter接收一个 RAW DNG 图像。 Is there a way I can output the image back as a RAW?有没有办法可以将图像作为 RAW 输出?

I'm trying to blend RAW images loaded in as CIFilter 's and then output them as a RAW back.我正在尝试混合作为CIFilter加载的 RAW 图像,然后将它们作为 RAW 输出。 It's a simple interpolation of the buffer's RAW values.这是缓冲区 RAW 值的简单插值。 Yes I understand that RAW photos don't have pixels.是的,我知道 RAW 照片没有像素。 I'm just trying to work with the underlying BAYER filter representation here.我只是想在这里使用底层的 BAYER 过滤器表示。 Is there any way to do this using CIFilter .有什么方法可以使用CIFilter做到这CIFilter How about using a third party library?使用第三方库怎么样?

EDIT: What I'm Trying to Do:编辑:我正在尝试做的事情:

So I'm trying to blend (something like exposure stacking ) multiple images taken using a Bracketed Photo Capture .所以我试图混合(类似于曝光叠加)使用Bracketed Photo Capture 拍摄的多张图像。 So I have multiple RAW photos' pixel buffer and I'm trying to average them out their pixel values.所以我有多张 RAW 照片的像素缓冲区,我试图平均它们的像素值。

Before doing that, I'm trying to confirm that my pixel values are correct.在此之前,我试图确认我的像素值是否正确。 So I take a photo of a red green or blue sheet of paper so that it is all one solid color(ish), and I try to see if the pixel buffer values are what I would expect.因此,我拍摄了一张红绿色或蓝色纸的照片,使其全部为纯色(ish),然后我尝试查看像素缓冲区值是否符合我的预期。 iPhones have RGGB bayer layout so I'd expect a very solid red picture to have the following layout: iPhone 具有RGGB bayer 布局,因此我希望非常纯的红色图片具有以下布局:

        Col0 Col1 Col3 Col4...
Row 0: [HIGH LOW  HIGH LOW ....]
Row 1: [LOW  LOW  LOW  LOW ....]
Row 2: [HIGH LOW  LOW  LOW ....] 

I have the following code for that:我有以下代码:

func photoOutput(_ output: AVCapturePhotoOutput, didFinishProcessingPhoto photo: AVCapturePhoto, error: Error?) {
        guard error == nil else { print("Error capturing photo: \(error!)"); return }

        guard let pixelBuffer = photo.pixelBuffer else {return}
        guard let baseAddress = CVPixelBufferGetBaseAddress(pixelBuffer) else {return}
        let bufferHeight = Int(CVPixelBufferGetHeight(pixelBuffer))

        let uint16Buffer = baseAddress.assumingMemoryBound(to: UInt16.self)

        for row in 0..<bufferHeight {
            let col0 = uint16Buffer[row*bufferWidth + 0]
            let col1 = uint16Buffer[row*bufferWidth + 1]
            let col2 = uint16Buffer[row*bufferWidth + 2]
            let col3 = uint16Buffer[row*bufferWidth + 3]
            print(col0, col1, col2, col3) // See pixel values
            if (row > 3) {break} // don't print more than 4 rows for debugging
        }

    }

There is no way to do what you want with Core Image.没有办法用 Core Image 做你想做的事。 You can "only" develop and process RAW input on a pixel basis with CIFilters .您可以“仅”使用CIFilters在像素基础上开发和处理 RAW 输入。

However, you can access the data of the CVPixelBuffers directly with CVPixelBufferGetBaseAddress() (and some proper locking).但是,您可以直接使用CVPixelBufferGetBaseAddress() (以及一些适当的锁定)访问CVPixelBuffers的数据。 So you could do your blending on the CPU and maybe use vDSP to improve the performance.因此,您可以在 CPU 上进行混合,并可能使用vDSP来提高性能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM