[英]How to convert visuals image to polar using Vispy
我正在嘗試使用 Vispy 將我的視覺圖像轉換為 Polar 形式
類似於下圖的東西..
使用以下 Vispy 代碼生成的原始圖像
scene.visuals.Image(self.img_data,interpolation=interpolation,parent = self.viewbox.scene, cmap=self.cmap, method='subdivide', clim=(-65,40))
所需的極地圖像:
我確實嘗試使用 Vispy 的PolarTransform Example實現polarTransform但未能成功。
任何人都可以指導我如何使用 Vispy 將上述圖像的 polarTransform 轉換為 Polar。
謝謝
回復@djhoese: PolarTransform之前Vispy生成的圖片
PolarTransform 后 Vispy 生成的圖像
PolarTransform 的代碼:
self.img.transform = PolarTransform()
ImageVisual
沒有一些ImageVisual
, ImageVisual
和PolarTransform
不能很好地配合使用。
VisPy 有兩種繪圖方法, subdivide
和impostor
。 我將集中在這里subdivide
。 這不適用於impostor
。
首先,像這樣創建ImageVisual
:
img = visuals.ImageVisual(image,
grid=(1, N),
method='subdivide')
對於 N,請使用合理的高數(例如 360)。 使用該數字,您將立即看到極坐標分辨率是如何受到影響的。
此外,您需要設置一些特定的轉換鏈:
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
- 將轉換為極坐標圖像中心的一側( top
或bottom
取值 0、1后面四個STTransform肯定可以簡化。 它們被分開以顯示不同的更改以及如何應用它們。
稍后將在 VisPy 示例部分添加一個示例。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.