Home > Net >  Performing a polar transformation on an image in reverse clock direction using scikit-image
Performing a polar transformation on an image in reverse clock direction using scikit-image

Time:10-25

As the following experiment shows, the warp_polar function of the enter image description here

CodePudding user response:

Thanks to the comment, I found out that the solution was much simpler than I thought. Flipping the result of warp_polar vertically is equivalent to applying the polar transformation in the reverse clock direction.

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

enter image description here

CodePudding user response:

you could flip the image on axis prior to input, then run your current polar warp to get the result like this:

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)
horizontal_flip = testImg[:, ::-1]
pol = warp_polar(horizontal_flip, radius=min(horizontal_flip.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(horizontal_flip)
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()  

output

  • Related