0

For a little background, I'm part of a project where we are creating a pressure map of foot impacts. An 8x4 layout of the sensors will be made. Each cross-section would be a sensor, which results in 32 unique pressure points.

I am more familiar with the data parsing from sensor data, but I do not exactly know the best method to draw a pressure/heatmap of a foot. Essentially, it would look to be something like this. What I had in mind was to use some sort of drawing tool to create the foot shape outline and try to find the pixel point or placement for each sensor point.

Each 'sensor' could be made of a 5x5 pixel block for example to make the coloring resemble a pressure map better. Here is my very first crude design of 8x3 sensors. Each block would resemble a 'sensor' (I forgot a fourth column). To better represent a pressure map, I was thinking of then making each sensor into a 5x5 or 10x10 pixel block to disperse the colors better. My last thought to create the final visual (first image linked) was to somehow mask the foot shape over the rectangular shape, which would make the outside of the foot just blank/white and keep the pressure map colors inside the outline of the foot. How could I mask the foot shape?

If there is a better tool out there, I am open to suggestions, or just a nudge to a resource I can use. I appreciate all help!

Michael
  • 139
  • 2
  • 5
  • I guess this might be of interest: http://stackoverflow.com/questions/4087919/how-can-i-improve-my-paw-detection and http://stackoverflow.com/questions/4502656/how-to-sort-my-paws – jrjc Jan 19 '16 at 22:15
  • Can you post the code you used to create your first attempt? – Emma Jan 19 '16 at 22:37

2 Answers2

0

To create a heat map like your first image, you need more sensors--for a higher resolution. To get your outline, you can set a threshhold below which the box will appear white, and finally you need to map your data above the threshhold from blue (least) to red(most) in, let's say, 32 divisions.

So you need to get a range:

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

and set each division in said range to one increment along your colour scale.

As for subdividing your sensors into pixels--You're talking about interpolation, although the degree to which you want to interpolate is probably too high.

Owen Hempel
  • 434
  • 2
  • 8
  • Thanks, the resolution isn't the biggest concern. For visual purposes I will interpolate the sensors. What I'm more curious is how to mask the footprint image on top of the heat map, again for visual purposes to see a foot. – Michael Jan 19 '16 at 22:50
0

To create the foot shape you can create and add a patch to your plot that masks out the background (see Fill OUTSIDE of polygon | Mask array where indicies are beyond a circular boundary?).

I made a rough foot shape using cubic Bezier curves (CURVE4). I made mine in CorelDRAW (because that's what I have), but there are plenty of free tools out there for drawing with cubic Beziers, or you can just adjust the points manually in your code. There's a tutorial here for working with paths.

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

Community
  • 1
  • 1
Emma
  • 1,287
  • 2
  • 17
  • 22