简体   繁体   English

如何从numpy数组的概率图中获取二进制图像?

[英]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.

相关问题 如何从二进制分类中获得概率? 我可以将二进制输出视为连续输出来计算概率吗? - How can I get a probability from a binary classification? Can I treat a binary output like a continuous to calculate a probability? 如何将数组的二进制numpy列表转换为图像? - How can i transform my binary numpy list of arrays to an image? 如何检查numpy中的二进制映像是否几乎全是黑色? - How can i check in numpy if a binary image is almost all black? 从二进制 numpy 阵列检测表面(图像) - Detect surfaces from a binary numpy array (image) 如何在numpy数组中存储带尾随空值的二进制值? - How can I store binary values with trailing nulls in a numpy array? 如何将 integer 转换为其二进制表示形式为 numpy 数组? - How can I convert an integer to its binary representation as a numpy array? 如何确定 numpy 数组的概率分布函数是什么? - How to determine what is the probability distribution function from a numpy array? 如何一次计算所有每个numpy值的概率? - How can I calculate probability for all each numpy value at once? 如何解释numpy数组的二进制? - How do I interpret the binary of a numpy array? 如何使用 OpenCV、Python 将图像的 RGB 值作为 numpy 数组 - How can i get the RGB values of an image as numpy array using OpenCV, Python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM