如何将16位深度图像(png格式)转换为32位图像?

2024-09-29 19:34:33 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个深度图像16单位一个人的手,在阈值后。我想恢复一些几何特征,如轮廓、凸壳等,但所有这些函数都能处理8位或32位图像,所以我需要转换。我在用python工作!在

我试过用一些开放的cv函数

img32 = np.array(thresh, dtype=np.float32) # This line only change the type, not values
img32 *= 65536 # Now we get the good values in 32 bit format
print img.dtype

但我的形象一直是16英寸。在


Tags: the函数图像np单位阈值特征array
1条回答
网友
1楼 · 发布于 2024-09-29 19:34:33

我不相信PNG支持浮点数据,所以我不确定您希望输出的格式是什么?在

如果原始的32位float RGB没问题,您可以使用ImageMagick,它安装在大多数Linux发行版上,并且很容易在osx和Windows上使用。命令应该是

convert input.png -depth 32 -define quantum:format=floating-point rgb:out.rgb

例如,如果您创建这样的1x1白色图像

^{pr2}$

你会得到这样一个12字节的图像

xxd out.rgb
0000000: 0000 803f 0000 803f 0000 803f

如果你创建一个这样的1x1黑色图像

convert -size 1x1 xc:black -depth 32 -define quantum:format=floating-point rgb:out.rgb

你会得到这样一个12字节的图像

xxd out.rgb
0000000: 0000 0000 0000 0000 0000 0000

相关问题 更多 >

    热门问题