如何旋转3D阵列? [英] How can I rotate a 3D array?

查看:156
本文介绍了如何旋转3D阵列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,如果我想比较狗的每只爪子下的压力,我只比较每个脚趾下面的压力。但我想尝试比较整个爪子下面的压力。



但要这样做我必须旋转它们,所以脚趾重叠(更好)。因为大多数时候左右爪子都是外部略微旋转的,所以如果你不能简单地将一个爪子放在另一个上面。因此,我想旋转爪子,所以它们都以相同的方式对齐。





目前,我通过查找两个中间脚趾和后面一个来计算旋转角度。为了澄清:walk_sliced_data是一个包含['ser_3','ser_2','sel_1','sel_2','ser_1','sel_3']的字典,它们是测量的名称。每个测量包含另一个字典,[0,1,2,3,4,5,6,7,8,9,10](例如来自'sel_1'),表示提取的影响。

解决方案

使用 Python Imaging库,您可以旋转数组,例如:

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

从那里,你可以在3D数组的不同图层上创建一个for循环。



如果你的第一个维度是图层,那么数组[< layer> ;] 将返回一个2D图层,因此:

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

@IvoFlipse的结果,带<啊ref =http://chat.stackexchange.com/rooms/118/conversation/paw-rotation>一个对话暗示:




  • 将数组放在一个更大的数组中以补救更暗的背景。

  • 查看重新采样,或许首先缩放数组。

  • 移动中间的后脚趾允许你围绕中间旋转。

  • 可以通过找到边框并再次将它们放置在15x15中来确定较小的图像。






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.

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!

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.

解决方案

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.

这篇关于如何旋转3D阵列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆