OPENCV GAMMA校正EXR

发布于 2025-02-10 18:07:28 字数 795 浏览 2 评论 0原文

如何伽玛校正一个32位.exr文件以看起来像该问题图像中所需的结果?基本上从衬里转换为SRGB? 我从将EXR转换为JPEG使用ImageIO和Python

我不太了解这些值(65535),然后更改它们将导致怪异的输出图像。

import os
os.environ['OPENCV_IO_ENABLE_OPENEXR']='True'

import numpy as np
import cv2
im=cv2.imread("D:\CG_CONTENT\HDRIS\HDRI_BROWSER\Concrete_Office_Outside_sm.exr",-1)
im=im*65535
im[im>65535]=65535
im=np.uint16(im)
cv2.imwrite("D:\CG_CONTENT\HDRIS\HDRI_BROWSER\Concrete_Office_Outside_sm_test8.png",im)

在此图像的左侧,我具有代码的输出,但是我需要右侧的图像之类的东西。

How can I gamma correct a 32bit .exr file to look like the desired result in the image of this question? Basically converting from liner to sRGB somehow?
I got this code(and modified it a bit) from convert EXR to JPEG using ImageIO and Python

I don't quite understand those values (65535), and changing them will result in weird output images.

import os
os.environ['OPENCV_IO_ENABLE_OPENEXR']='True'

import numpy as np
import cv2
im=cv2.imread("D:\CG_CONTENT\HDRIS\HDRI_BROWSER\Concrete_Office_Outside_sm.exr",-1)
im=im*65535
im[im>65535]=65535
im=np.uint16(im)
cv2.imwrite("D:\CG_CONTENT\HDRIS\HDRI_BROWSER\Concrete_Office_Outside_sm_test8.png",im)

On the left of this image I have the output from the code, but I need something like the image on the right.
output vs desired output

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

池予 2025-02-17 18:07:28

因此,为了将线性图像正确转换为SRGB,我必须使用传输函数,对于SRGB,可以使用γ简化。

这是我最终使用的东西,并且效果很好。

    #Read image (.exr)
    im=cv2.imread(newPath,-1)
    
    #Remove alpha if present
    im = im[:,:,:3]    
    
    #resize image
    dsize = (400,200)
    ldrDrago = cv2.resize(im, dsize)    
        
    #Convert to sRGB
    ldrDrago = ldrDrago ** (1 / 2.2)
    
    
    #Write jpeg
    cv2.imwrite(filename+".jpg", ldrDrago * 255)

So in order to properly converted a linear image to sRGB I had to use a transfer function, which for sRGB, can be simplified with gamma.

Here's what I ended up using, and worked very well.

    #Read image (.exr)
    im=cv2.imread(newPath,-1)
    
    #Remove alpha if present
    im = im[:,:,:3]    
    
    #resize image
    dsize = (400,200)
    ldrDrago = cv2.resize(im, dsize)    
        
    #Convert to sRGB
    ldrDrago = ldrDrago ** (1 / 2.2)
    
    
    #Write jpeg
    cv2.imwrite(filename+".jpg", ldrDrago * 255)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文