使用matplotlib帮助突出显示图像部分的小程序包
pyhighlight的Python项目详细描述
高亮度
一个小小的python 3包装器,使突出显示图像的部分变得更加容易
安装
安装最好使用pip
:
python3 -m pip install pyhighlight
另一个选项是克隆repo并将pyhighlight
模块文件夹(包含__init__.py
)复制到项目目录中。
用法
包装器使用三个功能:
Name | Description |
---|---|
^{ | The constructor, takes in the base image's file path |
^{ | Highlights a portion of the image.
|
^{ | Saves the generated image to the file path specified |
示例
假设您有一些要突出显示的建筑物的图像:
假设您知道要突出显示的图像上的点,可以编写一个小脚本来轻松生成突出显示这些建筑物的新图像:
importpyhighlightasph# Assuming we want to highlight buildings A, B, and C# from the example imagepoints={'A':[[45,156],[155,50],[156,160]],'B':[[37,253],[206,253],[206,276],[90,276],[90,297],[206,297],[206,330],[90,330],[90,352],[210,352],[210,386],[37,386]],'C':[[352,57],[518,57],[518,128],[410,128],[410,190],[352,190]]}test=ph.pyhighlight('example_buildings.png')test.highlight(points['A'])test.highlight(points['B'],color='red',transparency=0.5)test.highlight(points['C'],color='green')test.save('example.png')
最终结果:
许可证
麻省理工学院许可证
版权所有(c)2018 Tyler Burdsall
兹免费准许任何人取得副本 本软件和相关文档文件(“软件”)的 在软件中不受限制,包括但不限于 使用、复制、修改、合并、发布、分发、再授权和/或出售 软件的副本,并允许软件的用户 在满足以下条件的情况下,可以这样做:
上述版权公告及本许可公告须包括在 软件的拷贝或大部分。
本软件按“原样”提供,无任何形式的保证,明示或 默示的,包括但不限于适销性保证, 适合特定目的和不侵权。在任何情况下 作者或版权所有者应对任何索赔、损害或其他 责任,无论是在合同诉讼、侵权诉讼或其他诉讼中, 不属于或与本软件有关,或使用或与本软件的其他交易有关。 软件。