用于图像分析的感兴趣区域绘制工具(Python)
为了摆脱 IDL 和 Matlab,我正在探索需要在 python/scipy 等中实现什么样的工具。一个常见的功能是显示医学图像和感兴趣区域的轮廓(例如 IDL 中的 defroi 或 GIU 版本的 xroi)。在 chaco 和 matplotlib 中,有一些 LassoSelection 工具的示例,该工具很接近,但不太适合我的需求(我想单击多边形而不是拖动光标)。
是否有现有的工具可以做到这一点,或者我需要扩展和自定义现有的类?无论哪种情况,指向正确方向的指针都会有所帮助。
In an effort to move away from IDL and Matlab, I'm exploring what kind of tools I need to implement in python/scipy et al. One common feature is to display medical images and outline regions of interest (e.g. defroi in IDL or, it's GIU version, xroi). In chaco and matplotlib there are examples of the LassoSelection tool that comes close but is not quite right for my needs (I would like to click-click-click a polygon rather than drag a cursor).
Are there existing tools that can do this or would I need to extend and customize existing classes? In either case, pointers in the right direction would be helpful.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
看来 matplotlib 不太适合拍摄包含感兴趣区域绘图等功能的交互式数据可视化。当然,它确实处理事件处理等。到目前为止
,我能想到的最好的结果是以 guiqwt。它基于PyQwt,并且还具有相当多的(相当容易满足的)依赖项列表。快速浏览一下他们的图像可视化测试示例,展示了一个方便的工具集建立在.安装和运行这些示例很容易。时间会证明融入我自己的工作是多么容易。
It appears the matplotlib is not that suitable when shooting for interactive data vsiualization that includes features like region-of-interest drawing. Although of course it does deal with event handling etc.
The best I could come up with so far is an impressive effort under the name of guiqwt. It is based on PyQwt and has in addition quite a list of (fairly easy-to-satisfy) dependencies. A quick glance at their test examples of image visualization shows a handy toolset to build upon. It was easy to install and run these examples. Time will tell how easy it is to integrate in my own work.
现在 matplotlib 有一个名为“LassoSelector”的漂亮小部件,它使免费多边形绘制变得非常容易。
示例代码在这里:
:
我的简约版本
Now matplotlib has a nice widget called "LassoSelector" which made free polygon drawing very easy.
Sample code here:
http://matplotlib.org/examples/widgets/lasso_selector_demo.html
My minimalistic version:
我认为您可以使用 PyQTGraph 来实现此目的,https://launchpad.net/pyqtgraph。我只是很少使用它,因为它比 matplotlib 具有更少的固有选项,但它非常快,并且它确实有一些内置小部件用于您感兴趣的 ROI 选择类型。您可能会发现自己正在构建自定义不过,将 matplotlib 与 PyQTGraph 合并的绘图例程,如果格式不同等可能会导致头痛。它可能会导致更多的簿记,但可能会解决您的问题。
I think you might be able to use PyQTGraph for this purpose, https://launchpad.net/pyqtgraph. I've used it only sparingly, as it has fewer innate options than matplotlib, but it's pretty quick and it does have some built-in widgets for the kind of ROI selection you're interested in. You'll probably find yourself building custom plotting routines that merge matplotlib with PyQTGraph, though, which can cause headaches if the formats are different, etc. It can lead to more bookkeeping, but might solve your problem.
2023 年:您当然应该查看
mpl_interactions
您想要的是 这里。它也适用于 jupyter-notebooks。
官网示例:
YEAR 2023: You should certainly check out
mpl_interactions
What you want is here. It works well with jupyter-notebooks, too.
Example from the official website:
github 上的 jdoepfert 有一个很好的工具可以完全满足您的需求。
我的机器上的性能有点慢,但如果你注释掉
motion_notify_event
它就会发挥作用。There's a nice tool that does exactly what you want by jdoepfert available on github.
Performance was a bit slow on my machine, but if you comment out the
motion_notify_event
it works like a charm.