在Python中快速笛卡尔到Polar到笛卡儿 [英] fast Cartesian to Polar to Cartesian in Python

查看:292
本文介绍了在Python中快速笛卡尔到Polar到笛卡儿的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将Python 2d数组/图像转换为极性,然后处理,然后将它们转换回笛卡尔。以下是ImajeJ Polar Transformer 插件的结果(用于同心)示例代码的圆圈):

I want to transform in Python 2d arrays/images to polar, process then, and subsequently transform them back to cartesian. The following is the result from ImajeJ Polar Transformer plugin (used on the concentric circles of the sample code):

图像的数量和暗淡非常大,所以我在检查openCV是否有快速简单的方法来执行此操作。

The number and dims of the images is quite large so I was checking whether openCV has a fast and simple way to do this.

我读过cv。 CartToPolar PolarToCart 但我未能使用它。我更了解 LogPolar 其中输入和输出是数组,你可以在哪里设置中心,插值和反转(即 CV_WARP_INVERSE_MAP )。有没有办法以类似的方式使用CartToPolar / PolarToCart?

I read about cv. CartToPolar and PolarToCart but I failed to use it. I understand better the LogPolar where the input and output are arrays, and where you can set the center, interpolation,and inversion (i.e CV_WARP_INVERSE_MAP). Is there a way to use CartToPolar/PolarToCart in an similar fashion?

    import numpy as np
    import cv

    #sample 2D array that featues concentric circles
    circlesArr = np.ndarray((512,512),dtype=np.float32)
    for i in range(10,600,10): cv.Circle(circlesArr,(256,256),i-10,np.random.randint(60,500),thickness=4)

    #logpolar
    lp = np.ndarray((512,512),dtype=np.float32)
    cv.LogPolar(circlesArr,lp,(256,256),100,cv.CV_WARP_FILL_OUTLIERS)

    #logpolar Inverse
    lpinv = np.ndarray((512,512),dtype=np.float32)
    cv.LogPolar(lp,lpinv,(256,256),100, cv.CV_WARP_INVERSE_MAP + cv.CV_WARP_FILL_OUTLIERS)

    #display images
    from scipy.misc import toimage
    toimage(lp, mode="L").show()
    toimage(lpinv, mode="L").show()

这是一个断层扫描(CT)工作流程,如果出现环形工件,可以更容易地将其过滤掉s行。

This is for a tomography (CT) workflow where rings artifacts can be filtered out easier if they appear as lines.

推荐答案

CV源代码提到 LinearPolar 。它似乎没有记录,但似乎类似于 LogPolar 。你试过吗?

the CV source code mentions a LinearPolar. it doesn't seem to be documented, but appears to be similar to LogPolar. have you tried that?

这篇关于在Python中快速笛卡尔到Polar到笛卡儿的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆