首页 > 解决方案 > 使用 scikit-image 在反向时钟方向上对图像执行极坐标变换

问题描述

如以下实验所示,scikit-imagewarp_polar库的函数执行时钟方向的极坐标变换。但是,我想在反向时钟方向上执行极坐标变换。我可能应该以某种方式翻转或旋转图像以获得所需的最终结果。但是,我不知道该怎么做。我将不胜感激任何有效的解决方案。

在正确的解决方案中,转换后的图像将具有以下数字序列:3、2、1、12、11、10...。

from matplotlib import pyplot as plt
import matplotlib.image as mpimg
import matplotlib.gridspec as gridspec
from skimage.transform import warp_polar
import cv2

testImg = cv2.cvtColor(mpimg.imread('clock.png'), cv2.COLOR_BGR2GRAY)
pol = warp_polar(testImg, radius=min(testImg.shape)/2)

# Create 2x2 sub plots
gs = gridspec.GridSpec(1, 2)

fig = plt.figure()
ax1 = fig.add_subplot(gs[0, 0]) # row 0, col 0
ax1.imshow(testImg)
ax1.set_title("Original Image")

ax2 = fig.add_subplot(gs[0, 1]) # row 0, col 1
ax2.imshow(pol)
ax2.set_title("Polar Transformation")

plt.show()

在此处输入图像描述

标签: pythonimage-processingscikit-image

解决方案


感谢评论,我发现解决方案比我想象的要简单得多。垂直翻转结果warp_polar相当于在反向时钟方向上应用极坐标变换。

import numpy as np
pol = np.flip(pol,0)

在此处输入图像描述


推荐阅读