12

Currently, if I want to compare pressure under each of the paws of a dog, I only compare the pressure underneath each of the toes. But I want to try and compare the pressures underneath the entire paw.

But to do so I have to rotate them, so the toes overlap (better). Because most of the times the left and right paws are slightly rotated externally, so if you can't simply project one on top of the other. Therefore, I want to rotate the paws, so they are all aligned the same way.

alt text

Currently, I calculate the angle of rotation, by looking up the two middle toes and the rear one using the toe detection then I calculate the the angle between the yellow line (axis between toe green and red) and the green line (neutral axis).

Now I want to rotate the array would rotate around the rear toe, such that the yellow and green lines are aligned. But how do I do this?

Note that while this image is just 2D (only the maximal values of each sensor), I want to calculate this on a 3D array (10x10x50 on average). Also a downside of my angle calculation is that its very sensitive to the toe detection, so if somebody has a more mathematically correct proposal for calculating this, I'm all ears.

I have seen one study with pressure measurements on humans, where they used the local geometric inertial axis method, which at least was very reliable. But that still doesn't help me explain how to rotate the array!

alt text

If someone feels the need to experiment, here's a file with all the sliced arrays that contain the pressure data of each paw. To clarfiy: walk_sliced_data is a dictionary that contains ['ser_3', 'ser_2', 'sel_1', 'sel_2', 'ser_1', 'sel_3'], which are the names of the measurements. Each measurement contains another dictionary, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] (example from 'sel_1') which represent the impacts that were extracted.

Community
  • 1
  • 1
Ivo Flipse
  • 10,222
  • 18
  • 50
  • 63

2 Answers2

3

Why would you do it that way? Why not simply integrate the whole region and compare? In this case you'll get a magnitude of the force and you can simply compare scalars which would be much easier.

If you need to somehow compare regions(and hence that's why you need to align them) then maybe attempt a feature extraction and alignment. But this would seem to fail if the pressure maps are not similar(say someone is not putting much wait on one foot).

I suppose you can get really complex but it sounds like simply calculating the force is what you want?

BTW, you can use a simple correlation test to find the optimal angle and translation if the images are similar.

To do this you simply compute the correlation between the two different images for various translations and rotations.

AbstractDissonance
  • 1
  • 2
  • 16
  • 31
  • I like your suggestion about trying to correlate the images, to get them all aligned, but that doesn't explain me how I can rotate the images. Furthermore, if you have a look [at my question regarding sorting the paws](http://stackoverflow.com/q/4502656/77595), you'll see that I need to rotate the paws to have them properly standardized. Because currently the large variation within the population makes it hard to sort a paw that's rotated differently from those in the training set – Ivo Flipse Jan 22 '11 at 12:08
  • Your paws are "images". You rotate them like any other image. if your image is given by f(x,y) then your rotated image is f(x*cos(t) - y*sin(t), y*cos(t) + x*sin(t)). The only problem with this method is that it doesn't work well on discrete functions because of aliasing. I'm sure you can find some code or a library to rotate the image(2D array). It's something that is quite common. If you want to rotate about a point you first translate the image, rotate, then translate back. – AbstractDissonance Jan 22 '11 at 14:10
  • I'm really not sure were you are getting a 3D array from. All I have seen is density plots which are suppose to correspond to pressure maps. Mathematically a function P(x,y) which is a 2D function. If you really need to rotate a 3D array then you'll have 3 angles you can rotate. Essentially the function P(x,y,z). You can find a matrix transform from any game programming site. In this case you'll have to translate each point. Essentially, the point (x,y,z) in your matrix becomes (x',y',z') and (x',y',z') come from the matrix rotation – AbstractDissonance Jan 22 '11 at 14:15
  • http://www.siggraph.org/education/materials/HyperGraph/modeling/mod_tran/3drota.htm – AbstractDissonance Jan 22 '11 at 14:16
  • 1
    I simply show a slice of the 3D array, because it shows what the data looks like. But typically the paw is in contact with the ground for about 50 frames, so I would have a 13,10,50 shaped array and I want to compare the changes in the pressure distribution over time. Therefore, I would rotate each frame the same way. While you may know what library to use, doesn't mean I do, I'm merely a human movement scientist trying to figure things out :-) But I appreciate your input! – Ivo Flipse Jan 22 '11 at 14:27
2

Using the Python Imaging Library, you can rotate an array with for example:

array(Image.fromarray(<data>).rotate(<angle>, resample=Image.BICUBIC))

From there, you can just create a for loop over the different layers of your 3D array.

If you have your first dimension as the layers, then array[<layer>] would return a 2D layer, thus:

for x in range(<amount of layers>):
    layer = <array>[i]
    <array>[i] = (Image.fromarray(layer).rotate(<angle>, resample=Image.BICUBIC))

Results by @IvoFlipse, with a conversation suggesting:

  • Putting the array in a bigger array to remedy the darker background.
  • Look into resampling, perhaps scale the array first.
  • Moving the rear toe towards the middle allows you to rotate around that instead.
  • A smaller image can be determined by finding the borders and positioning them in a 15x15 again.

alt text

alt text

Community
  • 1
  • 1
Tamara Wijsman
  • 12,198
  • 8
  • 53
  • 82
  • 2
    I think that your solution is almost right. All it needs besides moving the rear toe to the center, is to make the yellow line (the angle) also be based on the rear toe. Thus, in the example given, the image should be rotated left (counterclokwise). Making the workspace larger and recroping would produce what Ivo wants, which, as I understand it, is a close up on the features of the paw with the rear toe pointing south. – Apalala Jan 22 '11 at 17:51