创建脚的压力热图

时间:2016-01-19 22:10:46

标签: python

对于一些背景知识,我是一个项目的一部分,我们正在创建一个足部影响压力图。将制作8x4传感器布局。每个横截面都是一个传感器,产生32个独特的压力点。

我更熟悉传感器数据的数据解析,但我并不完全知道绘制足部压力/热图的最佳方法。从本质上讲,它看起来像this。我的想法是使用某种绘图工具来创建脚形轮廓并尝试找到每个传感器点的像素点或位置。

每个传感器'例如,可以由5×5像素块构成,以使着色更好地类似于压力图。这是my very first crude design of 8x3 sensors。每个块都类似于传感器' (我忘记了第四栏)。为了更好地表示压力图,我想到了将每个传感器变成5x5或10x10像素块以更好地分散颜色。我最后想到创建最终视觉效果(第一个图像链接)是以某种方式将脚形状掩盖在矩形形状上,这将使脚的外部只是空白/白色,并将压力图颜色保持在脚的轮廓内。我怎么能掩盖脚的形状?

如果有更好的工具,我愿意接受建议,或者只是推动我可以使用的资源。我感谢所有的帮助!

2 个答案:

答案 0 :(得分:0)

要像第一张图像一样创建热图,您需要更多传感器 - 以获得更高的分辨率。为了得到你的轮廓,你可以设置一个阈值,在该阈值下方框会显示为白色,最后你需要将你的数据从蓝色(最少)到红色(大多数)进入阈值,比方说,32个分区。

所以你需要得到一个范围:

r = float(highest-lowest)
r_resolution = r/32

并将所述范围内的每个分区设置为沿着色标的一个增量。

至于将传感器细分为像素 - 你在谈论插值,尽管你想插入的程度可能太高。

答案 1 :(得分:0)

要创建足部形状,您可以创建并向地块添加补丁,以遮盖背景(请参阅Fill OUTSIDE of polygon | Mask array where indicies are beyond a circular boundary?)。

我使用立方贝塞尔曲线(CURVE4)制作了粗糙的脚形。我在CorelDRAW中制作了我的(因为这就是我所拥有的),但是有很多免费工具用于绘制立方贝塞尔曲线,或者你可以在代码中手动调整点数。有一个用于处理路径的教程here

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as patches
from matplotlib.path import Path

# Create a heat map with some fake data
ax = plt.subplot(111)
plt.pcolor(np.random.random((10,10)))

# Define a path that is a foot shape
foot_verts = [(3.2, 7.5),                         #Start point
             (2.9, 5.6), (4.1, 4.4), (4, 3.5),    #Cubic Bezier controls and end point
             (4.1,2.5), (3.9, 1.3), (4.4, 0.6),
             (5, 0), (6.3, 0.2), (6.8, 0.5),
             (7.3, 1.7), (6.7, 2.6), (6.5, 3.8),
             (6.4, 5.1), (7.6, 5.7), (7.2, 8.3),
             (6.7, 10.8), (3.5, 9.4), (3.2, 7.5)]

foot_codes = [Path.MOVETO,
              Path.CURVE4, Path.CURVE4, Path.CURVE4,
              Path.CURVE4, Path.CURVE4, Path.CURVE4,
              Path.CURVE4, Path.CURVE4, Path.CURVE4,
              Path.CURVE4, Path.CURVE4, Path.CURVE4,
              Path.CURVE4, Path.CURVE4, Path.CURVE4,
              Path.CURVE4, Path.CURVE4, Path.CURVE4]

# Define a path that is the same size as the plot area
xlim = ax.get_xlim()
ylim = ax.get_ylim()

ax_verts = [(xlim[0],ylim[0]),
            (xlim[0],ylim[1]),
            (xlim[1],ylim[1]),
            (xlim[1],ylim[0]),
            (xlim[0],ylim[0])]

ax_codes = [Path.MOVETO,
            Path.LINETO,
            Path.LINETO,
            Path.LINETO,
            Path.LINETO
            ]

#Create a patch that is the plot area minus the foot shape and add to the plot
path = Path(ax_verts + foot_verts, ax_codes + foot_codes)
patch = patches.PathPatch(path, facecolor='white', edgecolor='none')
ax.add_patch(patch)

plt.show()

Foot heatmap

相关问题