【问题标题】:Temperature is black after thresholding阈值化后温度为黑色
【发布时间】:2018-12-22 18:39:32
【问题描述】:

我想根据密度显示温度。

以下是我使用的功能,

def add_heat(heatmap, bbox_list):
    for i in range(len(bbox_list)):
        rect = trackers[i].get_position()

        heatmap[int(rect.left()):int(rect.top()), int(rect.right()):int(rect.bottom())] += 1
    return heatmap

def apply_threshold(heatmap, threshold):
    # Zero out pixels below the threshold
    heatmap[heatmap <= threshold] = 0
    # Return thresholded map

    cv2.imwrite("heatmap.png",heatmap)
    return heatmap
  1. add_heat 函数将循环遍历跟踪器,并仅在那些特定区域上调整热图以进行阈值处理
  2. apply_threshold 如果低于特定阈值,会将所有像素转换为零。

我这样称呼它,

heat = np.zeros_like(frame[:, :, 0]).astype(np.float)
heat = add_heat(heat,trackers)
heat = apply_threshold(heat, 80)
heatmap = np.clip(heat, 0, 255)

trackers 包含所有被跟踪的坐标。但是,当我尝试显示最终结果时,它仍然是黑色的。我可以知道我错过了什么吗?

【问题讨论】:

  • 请提供适当的最小、完整和可验证的示例。你在哪里/如何加载图像?什么形象?您要导入哪些模块?
  • 您的问题听起来很有趣但不清楚。请按照上面的建议添加更多详细信息。

标签: opencv heatmap detection dlib image-thresholding


【解决方案1】:

看来你的问题出在这里:

heatmap[int(rect.left()):int(rect.top()), int(rect.right()):int(rect.bottom())] += 1
return heatmap

假设你想使用像 skimage 这样的热图,你应该这样做:

heatmap[top_row:bottom_row, leftmost_column:rightmost_column]

在您的代码中将如下所示:

heatmap[int(rect.bottom()):int(rect.top()), int(rect.left()):int(rect.right())] += 1
return heatmap

您可能想了解更多关于 numpy 数组的信息。 当我看到这个问题originated 时,我能够知道发生了什么。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-09-25
    • 1970-01-01
    • 2020-11-12
    • 2023-03-14
    • 1970-01-01
    • 2017-06-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多