[英]How can I get a binary image from a probability map in a numpy array?
Hi I have the following heat map (probability map) of an object. 嗨,我有一个物体的以下热图(概率图)。
How can I convert this heatmap to a binary image?
如何将此热图转换为二进制图像? I want to take the maximum area of the object to increase the intersection with the image in the right side.
我想获取对象的最大面积,以增加与右侧图像的交集。 I really appreciate any help.
我非常感谢您的帮助。
To binarize, compare against a threshold: 要进行二值化,请与阈值进行比较:
thresh = 0.5
bin_map = prob_map > thresh
From there you can use a very large variety of solutions: 从那里,您可以使用各种各样的解决方案:
Saving a numpy array as an image 将numpy数组另存为图像
I recommend this one from migas: 我从migas推荐这个:
from PIL import Image
im = Image.fromarray(A)
im.save("your_file.jpeg")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.