【发布时间】:2020-03-29 04:38:44
【问题描述】:
我在hdf5 文件中有一堆医学图像。
path_to_data = "data/train_large_axial_350_x_350.hdf5"
data = h5py.File(path_to_data,"r")
image_list = data["images"]
image = image_list[5]
如果我这样做了
cv2.imwrite("maps/image.jpg", image)
我明白了:
但是,如果我这样做了
plt.imshow(image)
我明白了:
这是什么原因?如何绘制图像以使其看起来像 cv2.imwrite 生成的图像?
【问题讨论】:
-
image是什么类型? -
这能回答你的问题吗? why cv2.imwrite() changes the color of pics?
-
色序 BGR、RGB
-
@abhilb 这是一张灰度图——即使是 3 通道,所有通道都是相同的,所以在这种情况下顺序无关紧要。
-
也许你有一个默认的 matplotlib 颜色图处于活动状态。
plt.imshow(img, cmap='gray')的结果是什么?
标签: python opencv matplotlib plot