DNG原始图片导入为16位深,但意外的plt.show()结果 [英] DNG raw pictures imported as 16 bit deep but unexpected plt.show() result
问题描述
尝试使用 rawpy
在Python中处理原始DNG图片,结果很奇怪。
import rawpy
从matplotlib import pyplot导入imageio
为plt
path ='/ home / stefan / aiJ / RAW.DNG'
with rawpy.imread(path)as raw:
rgb = raw.postprocess()
plt.imshow(rgb)
plt.show()
结果是一个带有8位值的rgb图像数组,而我的相机会产生14位原始图像。
可视化 rgb
数组得出预期结果:
从某些googleing中我了解到可以导入相同的文件,但输出为16位。
我在后处理函数中使用了以下参数:
rgb = raw.postproc ess(output_bps = 16,demosaic_algorithm = None,output_color = rawpy.ColorSpace.Adobe)
现在 rgb
数组包含16位值,但可视化结果如下:
有人能告诉我如何获得类似于第一个结果但处理16位值的可视化?
最初我认为这与我的相机产生14位图像而不是16位的事实有关,但是将参数 output_bps
更改为14会导致更糟糕的可视化结果。
提前致谢!
根据要求,我会在这里添加PENTAX K的原始图片-5但它是18MB大,论坛有2MB的限制(可能是另一种传递文件的方式?)。
plt.imshow(rgb [:,:0])
等等带;或者将rgb转换为8位并显示,用
rgb8 =(rgb / 256).astype('uint8' )
plt.imshow(rgb8)
Trying to process raw DNG pictures in Python with rawpy
ends with strange results.
import rawpy
import imageio
from matplotlib import pyplot as plt
path = '/home/stefan/AIJ/RAW.DNG'
with rawpy.imread(path) as raw:
rgb = raw.postprocess()
plt.imshow(rgb)
plt.show()
The result is an rgb picture array with 8-bit values while my camera generates 14 bit raw pictures.
Visualizing the rgb
array gives an expected result:
From some googleing I understood that it is possible to import the same file but with an output in 16-bit.
I used the following parameters in the postprocess function:
rgb = raw.postprocess(output_bps=16,demosaic_algorithm=None,output_color = rawpy.ColorSpace.Adobe)
Now the rgb
array contains 16 bit values but visualizing results in the following:
Could someone tell me how I could obtain a visualization similar to the first result but handling 16-bit values?
Initially I thought it was related to the fact that my camera is producing 14 bit images rather than 16 bit, but changing the parameter output_bps
into 14 gives even worse visualization results.
Thanks in advance!
On request, I would add here the raw picture from a PENTAX K-5 but it is 18MB big and the forum has a limit of 2MB (may be another way to pass you the file?).
I don't think the issue has to do with how you are reading the image, as imshow
does not display 16-bit RGB images. So, if you are interested in visually checking the results of reading in the 16-bit image, I would suggest either inspecting bands individually, with
plt.imshow(rgb[:, :, 0])
and so on for each band; or converting the rgb to 8-bit and displaying that, with
rgb8 = (rgb / 256).astype('uint8')
plt.imshow(rgb8)
这篇关于DNG原始图片导入为16位深,但意外的plt.show()结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!