Correcting image distortion by warping a set of distorted points to a corresponding set of undistorted points

I was hoping someone might be able to help me undistort an image in Mathematica. The distortion doesn't follow any specific pattern, but there are several points on the distorted image that I am able to extract. I also have the corresponding set of corrected, undistorted points. My question is how to warp the distorted image in such a way as to match the distorted points with the undistorted set of points, therefore correcting the distortion. I tried using an old warp matrix command from Mathematica 6, but it was not as faithful as I would like. Any ideas? Thanks in advance!

This is my current code, but it isn't as faithful as I would like:

Wf = WarpMatrix[Reverse /@ dpoints, Reverse /@ ppoints, 3];
MatrixForm[Wf];
newimg = ImageWarp[img, Wf, InterpolationOrder -> 3]

• Hi ! If you have any relevant code, please, add it. – Sektor Feb 25 '15 at 21:43
• ImageTransformation[image,function]. – David G. Stork Feb 25 '15 at 21:51
• This is my current code, but it isn't as faithful as I would like: Wf = WarpMatrix[Reverse /@ dpoints, Reverse /@ ppoints, 3]; MatrixForm[Wf]; newimg = ImageWarp[img, Wf, InterpolationOrder -> 3] – dimitrij2510 Feb 25 '15 at 21:57
• I tried the ImageTransformation command, but I'm not sure how to create a function relating my distorted set of points to my undistorted set. Any suggestions? – dimitrij2510 Feb 25 '15 at 21:58
• In order to construct a transformation function, you'll need to know what form the transformation takes. Maybe you can post examples of a distorted and undistorted image, or at least the pairs of points in the two images. – 2012rcampion Feb 25 '15 at 23:21

1 Answer

There's a really nice paper on this subject by Bennink et al. (2007) titled "Warping a Neuro-Anatomy Atlas on 3D MRI Data with Radial Basis Functions". The Appendix to the paper includes a Mathematica code. See:

• Thanks, this looks great! Do you know how I might be able to use the RadialBasisInterpolation and RadialBasisNorm commands? They don't seem to work with Mathematica 10...any suggestions? Thanks again! – dimitrij2510 Feb 27 '15 at 0:11
• Actually, I only toyed with Bennink et al.'s code, and I worked from another version of their paper that included a slightly different code (I can send you the pdf if you'd like.) Also, I haven't upgraded yet to version 10. I also toyed with a different RBF code by Dahl and that author's RBF MMA code package (called Obtuse.m). You can easily find it via a Google search. I can send you a number of references, in the form of PDF files. My email address is "fschwab" at "nrao.edu". – user15994 Feb 27 '15 at 21:20