使用matplotlib帮助突出显示图像部分的小程序包

pyhighlight的Python项目详细描述


高亮度

一个小小的python 3包装器,使突出显示图像的部分变得更加容易

安装

安装最好使用pip

python3 -m pip install pyhighlight

另一个选项是克隆repo并将pyhighlight模块文件夹(包含__init__.py)复制到项目目录中。

用法

包装器使用三个功能:

NameDescription
^{}The constructor, takes in the base image's file path
^{}Highlights a portion of the image.
  • ^{} - An array of arrays containing the corresponding points (ie. ^{}). Note: the points must be in order or the highlighted image will look weird. Required.
  • ^{} - A string for the desired color of the highlighted portion. Defaults to ^{}. Optional.
  • ^{} - A float between 0 and 1 for how transparent the highlighting should be. Optional.
^{}Saves the generated image to the file path specified

示例

假设您有一些要突出显示的建筑物的图像:

Example buildings

假设您知道要突出显示的图像上的点,可以编写一个小脚本来轻松生成突出显示这些建筑物的新图像:

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')

最终结果:

Final result

许可证

麻省理工学院许可证

版权所有(c)2018 Tyler Burdsall

兹免费准许任何人取得副本 本软件和相关文档文件(“软件”)的 在软件中不受限制,包括但不限于 使用、复制、修改、合并、发布、分发、再授权和/或出售 软件的副本,并允许软件的用户 在满足以下条件的情况下,可以这样做:

上述版权公告及本许可公告须包括在 软件的拷贝或大部分。

本软件按“原样”提供,无任何形式的保证,明示或 默示的,包括但不限于适销性保证, 适合特定目的和不侵权。在任何情况下 作者或版权所有者应对任何索赔、损害或其他 责任,无论是在合同诉讼、侵权诉讼或其他诉讼中, 不属于或与本软件有关,或使用或与本软件的其他交易有关。 软件。

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

推荐PyPI第三方库


热门话题
并行处理java。util。同时发生的叉子在游泳池里。常见的并行性准则,用于选择正确的并行度大小   java如何将空白字符追加到指定长度?   安卓应用程序中出现错误,SSLHandshakeException,找不到证书路径的信任锚点   java如何使用JUnit Mockito验证检查方法是否未被调用   java如何使用不同的@RequestMapping解析多个控制器中的静态页面   Selenium中的javascript需要验证搜索结果   访问数据库SQLiteopenHelper方法时java应用程序崩溃(nullpointerexception)   在二叉树中验证最小堆时出现java空指针异常   Java 7的SSL连接失败   java用RestEasyWebTarget替换ProxyFactory不起作用   在Java应用程序中单击“否”按钮后,数组程序冻结(无响应)   数组中的前缀Java初学者前进和   Java HTML解析器,包括脚本标记和LineNumberReader   在java中为长类型数字加前导零   正则表达式无法映射正则表达式java。lang.IllegalArgumentException:模式段中捕获组的数量