Robustly estimate Polynomial geometric transformation with scikit-image and RANSAC

1.8k Views Asked by At

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

There are 1 best solutions below

5
On BEST ANSWER

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.