- 背景:**我建立了一个小型热成像相机,它可以保存70x70像素到SD卡。这些像素的颜色值范围从0到2^16。(实际上某些颜色,如黑色(值0)永远不会显示)。这个颜色的确定如下所述:c++ defined 16bit (high) color
我想用我的电脑用Python把这些数据转换成图像。
不幸的是,从另一个问题中收集到的一个例子并没有产生令人满意的结果:bad image
正如你所看到的,图像看起来不是很好。我的屏幕显示了这样的东西(注意,这两个例子不是同时捕获的):photo
白色框架不是csv文件的一部分。
这是我用来生成图像的代码:我已经尝试了color_max
值,但没有得到好的结果。
#Python CSV to Image converter
#pip2 install cImage
#pip2 install numpy
from PIL import Image, ImageDraw
from numpy import genfromtxt
color_max = 256
#original 256
g = open('IMAGE_25.TXT','r')
temp = genfromtxt(g, delimiter = ',')
im = Image.fromarray(temp).convert('RGB')
pix = im.load()
rows, cols = im.size
for x in range(cols):
for y in range(rows):
#print str(x) + " " + str(y)
pix[x,y] = (int(temp[y,x] // color_max // color_max % color_max),int(temp[y,x] // color_max % color_max),int(temp[y,x] % color_max))
im.save(g.name[0:-4] + '.jpeg')
这是csv文件:Image Data
在这种情况下,31表示蓝色,高值表示更红。
谢谢你的帮助!
以下是关于我的项目的一些附加信息:
Arduino热成像摄像机,支持SD卡并具有图像保存功能,使用Panasonic生产的AMG8833热成像传感器:Datasheet
GitHub (Arduino and Python Code)
3D-printable case used by me and original Arduino code
Schematic with SD card added
1条答案
按热度按时间nr7wwzry1#
我认为它应该是这样的: