Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Image processing 如何使用Python显示数字高程模型(DEM)(.raw)?_Image Processing_Computer Vision_Rawimage - Fatal编程技术网

Image processing 如何使用Python显示数字高程模型(DEM)(.raw)?

Image processing 如何使用Python显示数字高程模型(DEM)(.raw)?,image-processing,computer-vision,rawimage,Image Processing,Computer Vision,Rawimage,我想使用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.resi

我想使用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()
我得到了这个结果:


原始DEM文件放在这里:

您的代码没有问题,这就是文件中的内容。您可以使用命令行中的ImageMagick将其转换为JPEG或PNG,如下所示:

magick -size 4096x4096 -depth 8 GRAY:DEM.raw result.jpg
你会得到几乎相同的结果:

问题在别处

根据Fred(@fmw42)的提示,我的意思是“仔细和科学地进行实验”,如果我将您的图像处理为4096x2048像素,具有16个bpp和MSB第一个端点,我可以得到更可能的结果:

magick -size 4096x2048 -depth 16 -endian MSB gray:DEM.raw  -normalize result.jpg 

DEM通常不是16位整数吗?从中,它说高程是连续的;断裂或其他不连续使用值为-32767的“空心”高程表示。每个立面都被描述为一个占据块中固定位置的六个字符可读整数。因此我认为您不应该将其指定为uint8@fmw42我同意你的想法,Fred,但是文件大小确实对应于4096x4096的8位数据,而不是你明智地建议的16位或ASCII格式。嗯。。。我想OP需要检查他的消息来源。我发现了一些东西,谢谢你@Mark Setchell