[英]Save CIFilter as RAW image
所以CIFilter
接收一個 RAW DNG 圖像。 有沒有辦法可以將圖像作為 RAW 輸出?
我正在嘗試混合作為CIFilter
加載的 RAW 圖像,然后將它們作為 RAW 輸出。 這是緩沖區 RAW 值的簡單插值。 是的,我知道 RAW 照片沒有像素。 我只是想在這里使用底層的 BAYER 過濾器表示。 有什么方法可以使用CIFilter
做到這CIFilter
。 使用第三方庫怎么樣?
所以我試圖混合(類似於曝光疊加)使用Bracketed Photo Capture 拍攝的多張圖像。 所以我有多張 RAW 照片的像素緩沖區,我試圖平均它們的像素值。
在此之前,我試圖確認我的像素值是否正確。 因此,我拍攝了一張紅綠色或藍色紙的照片,使其全部為純色(ish),然后我嘗試查看像素緩沖區值是否符合我的預期。 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 ....]
我有以下代碼:
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
}
}
沒有辦法用 Core Image 做你想做的事。 您可以“僅”使用CIFilters
在像素基礎上開發和處理 RAW 輸入。
但是,您可以直接使用CVPixelBufferGetBaseAddress()
(以及一些適當的鎖定)訪問CVPixelBuffers
的數據。 因此,您可以在 CPU 上進行混合,並可能使用vDSP
來提高性能。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.