Reprojecting polar to cartesian grid

前端 未结 5 1066
不思量自难忘°
不思量自难忘° 2020-12-24 14:22

I have a polar (r,theta) grid (which means that each cell is an annulus section) containing values of some physical quantity (e.g. temperature), and I would like to re-grid

5条回答
  •  星月不相逢
    2020-12-24 14:48

    OpenCV 3.4 can do this now pretty easily with warpPolar()

    Very simple to call:

    import numpy as np
    import cv2
    from matplotlib import pyplot as plt
    
    # Read in our image from disk
    image = cv2.imread('washington_quarter.png',0)
    plt.imshow(image),plt.show()
    

    margin = 0.9 # Cut off the outer 10% of the image
    # Do the polar rotation along 1024 angular steps with a radius of 256 pixels.
    polar_img = cv2.warpPolar(image, (256, 1024), (image.shape[0]/2,image.shape[1]/2), image.shape[1]*margin*0.5, cv2.WARP_POLAR_LINEAR)
    # Rotate it sideways to be more visually pleasing
    polar_img = cv2.rotate(polar_img, cv2.ROTATE_90_COUNTERCLOCKWISE)
    plt.imshow(polar_img),plt.show()
    

提交回复
热议问题