Robustly estimate Polynomial geometric transformation with scikit-image and RANSAC

六月ゝ 毕业季﹏ 提交于 2019-12-21 22:17:29

问题


I would like to robustly estimate a polynomial geometric transform with scikit-image skimage.transform and skimage.measure.ransac

The ransack documentation gives a very nice example of how to do exactly that but with a Similarity Transform. Here is how it goes:

from skimage.transform import SimilarityTransform
from skimage.measure import ransac
model, inliers = ransac((src, dst), SimilarityTransform, 2, 10)

I need to use skimage.transform.PolynomialTransform instead of SimilarityTransform, and I need to be able to specify the polynomial order.

But the RANSAC call takes as input the PolynomialTransform(), which does not take any input parameters. The desired polynomial order is indeed specified in the estimate attribute of PolynomialTransform()... So the RANSAC call uses the default value for the polynomial order, which is 2, while I would need a 3rd or 4th order polynomial.

I suspect it's a basic python problem? Thanks in advance!


回答1:


We could provide a mechanism in RANSAC to pass on arguments to the estimator (feel free to file a ticket). A quick workaround, however, would be:

from skimage.transform import PolynomialTransform

class PolyTF_4(PolynomialTransform):
    def estimate(*data):
        return PolynomialTransform.estimate(*data, order=4)

The PolyTF_4 class can then be passed directly to RANSAC.



来源:https://stackoverflow.com/questions/27011995/robustly-estimate-polynomial-geometric-transformation-with-scikit-image-and-rans

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!