» 您尚未登录:请 登录 | 注册 | 标签 | 帮助 | 小黑屋 |


发新话题
打印

[数码手机] iPhone拍摄的hdr照片如何在win上看并保留亮度信息?

你问这个我可不困了

先说结论,你无法在win上直接显示iphone拍的hdr,它是苹果的私有算法,用的普通的8bit 图像+ hdr gain map,然后含在jpg或者heic的容器里,因为这么做可以向下兼容
非要在win下显示的话,你可以吧gain map提出来,将pq的亮度信息还原到原始的8bit图,需要用到libheif https://github.com/strukturag/libheif
命令行为。heif-convert <source_file>.HEIC <result_file>.png,你能得到本体以及gain map两个文件

然后用下面这个py
https://github.com/m13253/heif-hdrgainmap-decode
执行
./heif-hdrgainmap-decode.py 本体.heic gainmap.png output.exr 得到一个无损的通用hdr file

你可以进一步处理成浮点10bit的avif

win下目前现成查看hdr exr或者avif的应用
https://www.adobe.com/go/gainmap_demoapp_win

进阶的话还可以倒过来玩,把相机的raw处理成ios可显示的hdr,仅限mac os,要用到coreimage,swift编译,代码如下,自行修改文件path


import CoreImage
import CoreGraphics
import Foundation

extension CIImageRepresentationOption {
    @available(iOS 14.1, macOS 11.0, macCatalyst 14.1, *)
    static var hdrGainMapImage: Self { .init(rawValue: "kCIImageRepresentationHDRGainMapImage") } // not public, but should work
}

let image = CIImage(data: FileManager.default.contents(atPath: "/Users/xxx/Downloads/test.tif")!)!  // your input image
let gainMap = CIImage(data: FileManager.default.contents(atPath: "/Users/xxx/Downloads/map.tif")!)!  // your HDR gain map

// Get metadata, and especially the {MakerApple} tags from the main image.
var imageProperties = image.properties
var makerApple = imageProperties[kCGImagePropertyMakerAppleDictionary as String] as? [String: Any] ?? [:]

// Set HDR-related tags as desired.
// makerApple["33"] = 0.0 // 0x21, seems to describe the global HDR headroom. Can be 0.0 or un-set when setting the tag below.
makerApple["48"] = 0.0 // 0x30, seems to describe the effect of the gain map to the HDR effect, between 0.0 and 8.0 with 0.0 being the max.

// Set metadata back on image before export.
imageProperties[kCGImagePropertyMakerAppleDictionary as String] = makerApple
let modifiedImage = image.settingProperties(imageProperties)

let ciContext = CIContext()
let outputPath = URL(fileURLWithPath: "/Users/xxx/Downloads/out.heic") // path of the output image

try! ciContext.writeHEIFRepresentation(of: modifiedImage,
                                       to: outputPath,
                                       format: .RGBA8,
                                       colorSpace: CGColorSpace(name: CGColorSpace.displayP3)!,
                                       options: [.hdrGainMapImage: gainMap])



4楼孜孜不倦的给一些乱七八糟的答案已经很多年了


TOP

另外,ios 17以及sonoma会全面更新coreimage的代码,直接支持pq hdr,不再需要gain map了。windows的话,最新版本的chrome可以支持hdr avif,jpx 好像被google抛弃了,相关代码被移除了



TOP

posted by wap, platform: iPad
引用:
原帖由 @夏青  于 2023-7-12 22:43 发表
jxr格式了解一下?

无非就是格式壁垒
说的那么玄乎23333
jxr是微软的私有格式,快如坟了,自己的新app都放弃支持


TOP

posted by wap, platform: iPhone
引用:
原帖由 @sxyzero  于 2023-12-20 14:21 发表
今年要过了,还有没有方便点的办法呢?
Make a wish


https://www.adobe.com/go/gainmap_demoapp_win

TOP

发新话题
     
官方公众号及微博