用于图像分析的感兴趣区域绘制工具(Python)

发布于 2024-10-18 06:31:23 字数 260 浏览 2 评论 0原文

为了摆脱 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

寒江雪… 2024-10-25 06:31:23

看来 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.

偏闹i 2024-10-25 06:31:23

现在 matplotlib 有一个名为“LassoSelector”的漂亮小部件,它使免费多边形绘制变得非常容易。

示例代码在这里:

我的简约版本

from pylab import *
from matplotlib.widgets import LassoSelector

fig, ax = plt.subplots()
ax.imshow(np.random.randint(0,255,(255,255)), cmap='gray')

def onselect(verts):
    print verts

lasso = LassoSelector(ax, onselect)

subplots_adjust(left=0.1, bottom=0.1) 

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:

from pylab import *
from matplotlib.widgets import LassoSelector

fig, ax = plt.subplots()
ax.imshow(np.random.randint(0,255,(255,255)), cmap='gray')

def onselect(verts):
    print verts

lasso = LassoSelector(ax, onselect)

subplots_adjust(left=0.1, bottom=0.1) 
潇烟暮雨 2024-10-25 06:31:23

我认为您可以使用 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.

复古式 2024-10-25 06:31:23

2023 年:您当然应该查看 mpl_interactions

您想要的是 这里。它也适用于 jupyter-notebooks。

官网示例:

图像分割GIF

参考:
https://mpl-interactions.readthedocs.io(最后访问时间:2023 年 2 月 28 日)

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:

Image Segmentation GIF

Reference:
https://mpl-interactions.readthedocs.io (last accessed: 28th of Feb 2023)

哆兒滾 2024-10-25 06:31:23

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文