使用RGB数据将输入数据剪切到有效显示范围(对于浮点数为[0..1],对于整数为[0..255]) [英] Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers)
本文介绍了使用RGB数据将输入数据剪切到有效显示范围(对于浮点数为[0..1],对于整数为[0..255])的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在将 MRI 切片转换为 PNG 格式后,我尝试对其运行图形切割算法.我一直遇到以下问题:
I tried to run the graph cut algorithm for a slice of an MRI after converting it into PNG format. I keep encountering the following problem:
Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers).
即使将 vmin
和 vmax
设置如下:
This is even after setting vmin
and vmax
as follows:
plt.imshow(out, vmin=0, vmax=255)
推荐答案
在缩放 [0, 255]
范围后将图像投射到 np.uint8
将消除此警告.如 issue matplotlib 中的一项功能.
Cast the image to np.uint8
after scaling [0, 255]
range will dismiss this warning. It seems like a feature in matplotlib
, as discussed in this issue.
plt.imshow((out * 255).astype(np.uint8))
这篇关于使用RGB数据将输入数据剪切到有效显示范围(对于浮点数为[0..1],对于整数为[0..255])的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文