三维立体图像中椭球体的绘制与分析。

pyellipsoid的Python项目详细描述


https://travis-ci.org/ashkarin/pyellipsoid.svg?branch=master

py椭球是用于绘制和分析三维体积图像(3d数组)中椭球的软件包。

安装

安装最新版本的最简单方法是使用pip:

$ pip install pyellipsoid

您还可以使用git克隆存储库并手动安装:

$ git clone https://github.com/ashkarin/pyellipsoid.git
$ cd pyellipsoid
$ python setup.py install

如何使用

绘制椭球体:

importnumpyasnpfrompyellipsoidimportdrawing# Define an image shape, axis order is: Z, Y, Ximage_shape=(128,128,128)# Define an ellipsoid, axis order is: X, Y, Zell_center=(64,64,64)ell_radii=(5,50,30)ell_angles=np.deg2rad([80,30,20])# Order of rotations is X, Y, Z# Draw a 3D binary image containing the ellipsoidimage=drawing.make_ellipsoid_image(image_shape,ell_center,ell_radii,ell_angles)

计算给定椭球图像的惯性椭球:

importnumpyasnpfrompyellipsoidimportdrawing,analysis# Draw a 3D binary image containing an ellipsoidimage_shape=(128,128,128)ell_center=(64,64,64)ell_radii=(5,50,30)ell_angles=np.deg2rad([80,30,20])image=drawing.make_ellipsoid_image(image_shape,ell_center,ell_radii,ell_angles)# Compute inertia ellipsoidpoints=analysis.sample_random_points(image)inertia_ellipsoid=analysis.compute_inertia_ellipsoid(points)

要旋转轴并查找原始轴和旋转轴之间的相对旋转:

importnumpyasnpfrompyellipsoidimportgeometryoriginal_axes=np.array([[1,0,0],[0,1,0],[0,0,1]])rot_angles=np.deg2rad([0,0,45])# Rotate around Z-axis by 45 deg# Build rotation matrix and rotate the axesrotm=geometry.build_rotation_matrix(*rot_angles)rotated_axes=np.dot(rotm,np.transpose(original_axes)).T# Find relative rotationrel_rotm=geometry.find_relative_axes_rotation(original_axes,rotated_axes)# Validate relative rotation matrixrel_rotated_axes=np.dot(rel_rotm,np.transpose(original_axes)).Tassert(np.all(rotated_axes==rel_rotated_axes))# Compute rotation angles# Please note, that these angles might differ from rot_angles!rel_rot_angles=geometry.rotation_matrix_to_angles(rel_rotm)print(np.rad2deg(rel_rot_angles))

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java Android使用两个后台服务错误   解压缩HTTPInputStream时,java GZIPInputStream过早关闭   javax和javax的区别是什么。网ssl。密钥库和服务器。ssl。为SpringBoot应用程序指定密钥库时的密钥库属性   java生成两个JPanel,而我只需要一个   java深度链接从play store安装应用程序时获取数据   java 安卓应用程序在退出时未正确释放蓝牙   java正确使用setCellValueFactory   java开放JdbcTemplate连接处于只读模式?   使用Spring MVC创建服务时发生java错误   JavaFX获取安装在计算机中的特定应用程序的版本   SecureRandom的安全问题:PRNG在java 1.5中不一致   windows我可以创建一个独立的。带Inno设置的Java应用程序的exe安装程序?   如何使用JavaServlet下载csv文件?   java从生成的缓冲图像中添加图像作为jasper中的数据记录?   java日期和时间解析