Search code examples
matlabtransformation

Fit images using rigid transformation


I have two binary images with some small tracks on them (black and magenta lines), and I'm currently trying to make them match by computing the distance between the pairs in each image (cyan lines). I know that the transformation needed is rigid, i.e. a translation and a rotation from the center of the image.

The problem is that MATLAB's built-in functions that I've tried (fitgeotrans and estimateGeometricTransform) use algorithms that include translations, rotations and scaling (geometric transformation) to fit those images. At this point, I have two main questions:

  • Is there any built-in function to fit a rigid transformation instead a geometric one?
  • Is there a way to specify the center of the rotation to any of those functions?

enter image description here


Solution

  • Since you're working with images, the most straightforward option would be to use the imregister function from the Image Processing Toolbox. Your code would look something like this:

    [optimizer, metric] = imregconfig('monomodal');
    image1Registered = imregister(image1, image2, 'rigid', optimizer, metric);
    

    If the images are binary (i.e. type logical), you may need to convert them to another type first, like uint8.