【发布时间】:2015-07-29 16:11:55
【问题描述】:
我编写了这个脚本来打开一个原始图像并进行一些处理。
import numpy as np
import matplotlib.pyplot as plt
PATH = "C:\Users\Documents\script_testing_folder\\"
IMAGE_PATH = PATH +"simulation01\\15x15_output_det_00001_raw_df_00000.bin"
raw_image = np.fromfile(IMAGE_PATH, dtype=np.uint64)
raw_image.shape = (15,15)
plt.imshow(raw_image,cmap = 'gray')
total_intensity = ndimage.sum(raw_image)
print total_intensity
plt.show()
相比之下...当我在 ImageJ(file>import>raw (64bit real, 15x15 length and width)) 上打开相同的图像时,我有这个:
我试过环顾四周,但我不确定在 python 上重现相同图像时哪里出错了。任何帮助将不胜感激。
另外,当我使用以下方法对图像中的强度求和时:
total_intensity = ndimage.sum(raw_image)
print total_intensity
y 我得到 4200794456581938015,而在 ImageJ 上我得到 0.585。
我不确定我在这些步骤中哪里出错了......
谢谢!
编辑:如果有人想重现我得到的结果,请使用原始文件https://www.dropbox.com/s/po82z4uf2ku7k0e/15x15_output_det_00001_raw_df_00000.bin?dl=0
【问题讨论】:
-
你的图片文件是什么格式的?你能把它上传到某个地方吗?
-
不确定,但我最初的猜测是您想将 dtype 更改为 np.float64,因为 ImageJ 使用所谓的 64 位实数。另外,请注意 ImageJ 中的强度总和是小数。
-
dropbox.com/s/po82z4uf2ku7k0e/… 我试图处理的文件
-
刚试过float64,没用...
-
raw_image = np.fromfile(IMAGE_PATH, dtype=np.uint64):这是否以正确的方式加载您的数据?如果没有,它可能不会给你一个错误,因为它只是读取二进制数据并以某种方式解释它。我以前从未见过.bin图像。如果有帮助,有一种方法可以加载 16 位 tif:stackoverflow.com/a/18483020/2156909
标签: python numpy image-processing matplotlib imagej