Skip to content Skip to sidebar Skip to footer

How Can I Rotate A 3D Array?

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 under

Solution 1:

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.


Solution 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


Post a Comment for "How Can I Rotate A 3D Array?"