【发布时间】:2019-04-26 17:09:46
【问题描述】:
我想使用 Python 显示一个 DEM 文件 (.raw),但结果可能有问题。
下面是我的代码:
img1 = open('DEM.raw', 'rb')
rows = 4096
cols = 4096
f1 = np.fromfile(img1, dtype = np.uint8, count = rows * cols)
image1 = f1.reshape((rows, cols)) #notice row, column format
img1.close()
image1 = cv2.resize(image1, (image1.shape[1]//4, image1.shape[0]//4))
cv2.imshow('', image1)
cv2.waitKey(0)
cv2.destroyAllWindows()
我得到了这个结果: display result
原始DEM文件放在这里:DEM.raw
【问题讨论】:
-
DEM 通常不是 16 位整数吗?
-
来自en.wikipedia.org/wiki/USGS_DEM,上面写着
The elevations are contiguous; breaks or other discontinuities are expressed using "void" elevations of value -32767. Each elevation is described as a six-character readable integer occupying a fixed location in a block.所以我认为你不应该将它指定为uint8 -
@fmw42 我同意你的两个想法,Fred,但文件大小确实对应于 4096x4096 的 8 位数据,而不是你明智建议的 16 位或 ASCII 格式。嗯……我认为 OP 需要检查他的消息来源。
-
我发现了一些东西,谢谢@Mark Setchell
标签: image-processing computer-vision rawimage