本文介绍了阈值后温度为黑色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
add_heat函数将遍历跟踪器,并仅针对阈值调整那些特定区域上的热图.
apply_threshold会将低于阈值的所有像素转换为零.
add_heat function will loop through the trackers and will tweak the heatmap only on those specific areas for the thresholding
apply_threshold will convert all pixels to zero if it is below certain threshold.
我想根据密度显示温度.
I want to show the temperature based on the density.
以下是Im使用的功能
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
我这样称呼它,
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包含所有跟踪的坐标.但是,当我尝试显示最终结果时,它仍然是黑色的.我可以知道我在想什么吗?
trackers contains all the tracked coordinates. however when i try to show the final result, it is still black. May i know what am i missing?
推荐答案似乎您的问题出在这里:
Seems like your problem lies in here:
heatmap[int(rect.left()):int(rect.top()), int(rect.right()):int(rect.bottom())] += 1 return heatmap假设您想将热图与skimage一起使用,您可能应该这样做:
Assuming you want to use the heatmap with something like skimage, you should probably do it like this:
heatmap[top_row:bottom_row, leftmost_column:rightmost_column]在您的代码中它将如下所示:
which in your code will look like this:
heatmap[int(rect.bottom()):int(rect.top()), int(rect.left()):int(rect.right())] += 1 return heatmap您可能想了解有关numpy数组的更多信息. 当我看到此问题在哪里时,我能够说出正在发生什么情况起源.
You may want to read a little more about numpy arrays. I was able to tell what is happening as I saw where this question originated.
更多推荐
阈值后温度为黑色
发布评论