基本上我有这些tif图像,我需要通过递归读取像素数据来确定图像中的像素是否是融化的冰。这是通过脚本中设置的阈值确定的。配置为能够显示年份总熔融值和每个月的熔融值。它在我自己的机器上运行得很好,但是我需要在Linux虚拟机上远程运行它。它是有效的,但是它产生的总数正好是71146,比它应该产生的和它已经产生的要多
我相信,这是执行大部分处理的代码片段,最终导致我的问题
for file in os.listdir(current):
if os.path.exists(file):
if file.endswith(".tif"):
fname = os.path.splitext(file)[0]
day = fname[4:7]
im = Image.open(file)
for x in range(0,60):
for y in range(0,109):
p = round(im.getpixel((x,y)), 4)
if p >= threshold:
combined = str(x) + "-" + str(y)
if combined not in coords:
melt += 1
coords.append( combined )
totalmelt.append( melt )
然后将totalmelt相加得到年值:
total = sum(totalmelt)
阈值以前设置如下:
threshold = float(-0.0158)
我觉得我错过了一些明显的东西。我用Python玩了好一会儿,我现在从C++中过来。感谢您提供的任何解决方案
在内部循环之前,需要将
melt
重置为0
:相关问题 更多 >
编程相关推荐