这是一个读写.tps文件的简单库,由f.james rohlf创建的tpsdig标记工具创建和使用。https://life.bio.sunysb.edu/morphi/

py-tps的Python项目详细描述


这是一个用于读写tpsdig标记工具创建和使用的.tps文件的简单库 由F.JamesRohlf创作。https://life.bio.sunysb.edu/morph/

安装

安装的主要方式是从pip:

pip install py_tps

源代码安装通过诗歌进行管理。https://pypi.org/project/poetry/ 来源可以从https://gitlab.com/ryan-feather/py_tps

要安装,首先安装诗歌。

conda用户的注释

要将conda环境与poetry一起使用,必须首先将poetry配置为使用conda环境和 不创建新的virtualenv环境。示例:

poetry config settings.virtualenvs.path $CONDA_ENV_PATH
poetry config settings.virtualenvs.create 0

然后运行:

poetry install
poetry build
cd dist
pip install *.whl

用法

from py_tps import TPSFile, TPSImage, TPSCurve, TPSPoints
import numpy as np

# construct and write
# numpy is used for numeric data
points = TPSPoints(np.asarray([[33,44],
                               [44,45]]))
curve = TPSCurve(points)
image = TPSImage('T1.JPG', curves=[curve], id_number=0, comment="This is a test", scale=0.0045)
tps_file = TPSFile([image]) # can have many images, but here we do just one
tps_file.write_to_file('TestFile.TPS')

创建包含以下内容的文件:

LM=0
CURVES=1
POINTS=2
33 44
44 45
IMAGE=T1.JPG
ID=0
COMMENT=This is a test
SCALE=0.0045

现在阅读:

tps_file_in =TPSFile.read_file('TestFile.TPS')
# now can access images list, and so on.  Attributes have the same names as they do in the objects above.
print(tps_file.images[0].image) # T1.JPG
print(tps_file.images[0].curves[0].tps_points.points) # [[33,44],[44,45]]

地标可以设置,而不是曲线。如果我们这样做:

image = TPSImage('T1.JPG', landmarks=points, id_number=0, comment="This is a test", scale=0.0045)

它创建包含以下内容的文件:

LM=2
33 44
44 45
IMAGE=T1.JPG
ID=0
COMMENT=This is a test
SCALE=0.0045

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

推荐PyPI第三方库


热门话题
java当我点击MainActivity中的按钮以显示其他活动时,它不起作用   java游戏!框架:在请求之间获取控制器的组件/字段/对象   JavaBlackBerry:调用计算器并检索值?   java Struts2 jQuery插件提交按钮   java无法将更新的画布绘制到活动   java如何将Gson值放入HashMap   使用截取时出现java错误:RecyclerView:未连接适配器;跳过布局   java组织。冬眠HibernateException:在Hibernate搜索中编制索引时出错(在事务完成之前)   java Swagger服务器存根生成工作流   java JInternalFrame底部阴影问题   java nio缓冲区类中limit()的用法是什么   java水平回收器视图内部选项卡布局   java Maven无法找到依赖项   java如何管理不同应用程序实例的权限文件?