阈值化后温度为黑色

Temperature is black after thresholding

我想根据密度显示温度。

以下是我正在使用的功能,

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

看来你的问题出在这里:

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.

的位置时,我能够说出发生了什么