How to perform image registration on non-rectangular image

10 views (last 30 days)
I'm interesting in peforming image registration using imregtform on a non-rectangular region of interest that would be the "moving" image. Is there any way to do this? I initially tried to turn all the pixels within the "moving" image matrix that I don't want to affect registration to NaNs, but the imregtform function won't accept that input.
  2 Comments
Biral Pradhan
Biral Pradhan on 3 Jun 2022
I understand, you have a non-rectangular region of interest in a rectangular image, and you want to use "imregtform" it. Could you try converting all the other pixels to "black" colour instead of NaN?
Jeremy Eekhoff
Jeremy Eekhoff on 6 Jun 2022
That would not work because the black pixels would still affect registration. My images do not have a black background.

Sign in to comment.

Answers (2)

Matt J
Matt J on 6 Jun 2022
Edited: Matt J on 6 Jun 2022
If you have the Optimization Toolbox, you could use lsqcurvefit (don't be misled by the name) to minimize your own reigstration cost function, one which accepts an ROI mask.
  5 Comments
Matt J
Matt J on 1 Aug 2022
Edited: Matt J on 1 Aug 2022
What is usually done to improve robustness is that you first smooth and downsample the images and perform an initial registration. Then you reduce the smoothing and repeat the registration with the previous registration result as your initial guess. This is repeated until the registration is done at full resolution.

Sign in to comment.


Image Analyst
Image Analyst on 1 Aug 2022
Is it rotating and scaling while it translates? If not, you could use normalized cross correlation. See attached demo.
Or try one of the panoramic stitching algorithms. They find matching regions, which is necessary to construct the overall image.
  5 Comments
Jeremy Eekhoff
Jeremy Eekhoff on 11 Aug 2022
Hey - quick following up on this. I was able to somewhat get this working using fmincon, but the results weren't quite as good as I get using imregtform and I would often have to change the optimizer options for different sets of images. I had the idea to try to go back and use imregtform and set the pixel intensities of all pixels outside of the polygonal region of interest to uniformly distributed random values, the idea being that the blocks of random pixels would have zero mutual information with the fixed image regardless of where it ended up and therefore wouldn't affect the registration. This ended up working better than my attemps to make my own registration optimizer. Does this seem like a reasonable solution or am I missing something that could be problematic?
Matt J
Matt J on 11 Aug 2022
Does this seem like a reasonable solution or am I missing something that could be problematic?
I can't argue with success, but I vaguely wonder why setting the background pixels to some constant wouldn't do the same thing. An atomic distribution is independent of every distribution as well.

Sign in to comment.

Products


Release

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!