首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用Vispy将可视化图像转换为极坐标

如何使用Vispy将可视化图像转换为极坐标
EN

Stack Overflow用户
提问于 2021-06-29 11:23:53
回答 1查看 132关注 0票数 1

我正在尝试使用Vispy将我的视觉图像转换成极坐标形式。

类似于下面的图片..。

使用下面的Vispy代码生成的原始图像

代码语言:javascript
复制
scene.visuals.Image(self.img_data,interpolation=interpolation,parent = self.viewbox.scene, cmap=self.cmap, method='subdivide', clim=(-65,40)) 

所需极坐标图像:

我确实尝试过使用polarTransform实现来自Vispy的PolarTransform示例,但没有成功。

请任何人指导我如何做以上图像的polarTransform到极地使用Vispy。

谢谢

回复@djhoese:图像由Vispy在PolarTransform之前生成

图像在PolarTransform后由Vispy生成

PolarTransform代码:

代码语言:javascript
复制
self.img.transform = PolarTransform()
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-07-15 08:35:54

ImageVisualPolarTransform在一起打得不太好。

VisPy有两种绘图方法,subdivideimpostor。我将在这里集中讨论subdivide。这将不适用于impostor

首先,像这样创建ImageVisual

代码语言:javascript
复制
img = visuals.ImageVisual(image, 
                          grid=(1, N),           
                          method='subdivide')

对于N使用一个合理的高数字(如360)。使用这个数字,您将立即看到极地分辨率如何受到影响。

此外,还需要设置一些特定的转换链:

代码语言:javascript
复制
transform = (
             # move to final location and scale to your liking
             STTransform(scale=(scx,scy), translate=(xoff,yoff))

             # 0
             # just plain simple polar transform
             *PolarTransform()

             # 1
             # pre scale image to work with polar transform
             # PolarTransform does not work without this
             # scale vertex coordinates to 2*pi
             * STTransform(scale=(2 * np.pi / img.size[0], 1.0))

             # 2
             # origin switch via translate.y, fix translate.x
             * STTransform(translate=(img.size[0] * (ori0 % 2) * 0.5,                                                                   
                                      -img.size[1] * (ori0 % 2)))

             # 3
             # location change via translate.x
             * STTransform(translate=(img.size[0] * (-loc0 - 0.25), 0.0))

             # 4
             # direction switch via inverting scale.x
             * STTransform(scale=(-dir0, 1.0))

            )
# set transform
img.transform = transform
  • dir0 -方向cw/ccw (取值-1/1 )
  • loc0 -零的位置(值在0到2* np.pi之间,逆时针方向)
  • 将被转换为极坐标图像中心的ori0端( topbottom的值为0,1)。

下面的四个STTransform当然可以简化。它们被分割开来,以显示不同的更改以及它们必须如何应用。

稍后将向VisPy示例部分添加一个示例。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68177737

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档