How to perform image registration on non-rectangular image

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.

3 Kommentare

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?
That would not work because the black pixels would still affect registration. My images do not have a black background.
raym
raym am 8 Nov. 2024
Bearbeitet: Walter Roberson am 8 Nov. 2024
Dear Jeremy D. Eekhoff,
I'm sorry to trouble you on on the forum here.
I read your article "Three-dimensional computation of fibre orientation, diameter and branching in segmented image stacks of fibrous networks" by Jeremy D. Eekhoff and Spencer P. Lake.This is a really great application on detection of fibers in 3D space. I want to have a try and download the code from github: https://github.com/jeremyeekhoff/Fiber-Analysis-Algorithm .
I used a demo 3D stack fiber stainning image to run the function fiberAnalysisAlgorithm.m on R1026a, with MinGW64 compiler on win8.1.
However, it shows the error on the two mexw64 files:
Invalid MEX-file 'mexfilename': The specified module could not be found.
I have tried using dependencywalker to find which dlls are missing. It first says that several dlls in C:\Program Files\MATLAB\R2016a\bin\win64 is missing. Thus I add this folder to env and restart computer and re-run, then it says the following dlls are missing, although most of them exist in folders below, except API-MS-WIN-CORE-SHUTDOWN-L1-1-1.DLL.
API-MS-WIN-CORE-KERNEL32-PRIVATE-L1-1-1.DLL
API-MS-WIN-CORE-PRIVATEPROFILE-L1-1-1.DLL
API-MS-WIN-CORE-SHUTDOWN-L1-1-1.DLL
API-MS-WIN-SERVICE-PRIVATE-L1-1-1.DLL
I searched and find that API-MS-WIN-CORE-SHUTDOWN-L1-1-1.DLL is obselete in Win8.1
After I download API-MS-WIN-CORE-SHUTDOWN-L1-1-1.DLL and place in the same folder of m code, the error still persist, and
dependencywalker shows more complicated errors. I guess it is a problem of mexw64 compiling environment differs too much with my environment. Could you give me some instructions on this?
Thank you.
----the path to most of dlls above:
C:\Windows\System32\downlevel\API-MS-Win-Core-Kernel32-Private-L1-1-1.dll
C:\Windows\SysWOW64\downlevel\API-MS-Win-Core-Kernel32-Private-L1-1-1.dll
C:\Windows\WinSxS\amd64_microsoft-windows-m..namespace-downlevel_31bf3856ad364e35_6.3.9600.16384_none_2c5177c069a919dd\API-MS-Win-Core-Kernel32-Private-L1-1-1.dll
C:\Windows\WinSxS\x86_microsoft-windows-m..namespace-downlevel_31bf3856ad364e35_6.3.9600.16384_none_d032dc3cb14ba8a7\API-MS-Win-Core-Kernel32-Private-L1-1-1.dll
C:\Users\rmd\AppData\Local\GeoGebra_6\app-6.0.583\API-MS-Win-Core-Kernel32-Private-L1-1-1.dll
-----
C:\Windows\System32\downlevel\api-ms-win-core-privateprofile-l1-1-1.dll
C:\Windows\SysWOW64\downlevel\api-ms-win-core-privateprofile-l1-1-1.dll
C:\Windows\WinSxS\amd64_microsoft-windows-m..namespace-downlevel_31bf3856ad364e35_6.3.9600.16384_none_2c5177c069a919dd\api-ms-win-core-privateprofile-l1-1-1.dll
C:\Windows\WinSxS\x86_microsoft-windows-m..namespace-downlevel_31bf3856ad364e35_6.3.9600.16384_none_d032dc3cb14ba8a7\api-ms-win-core-privateprofile-l1-1-1.dll
C:\Users\rmd\AppData\Local\GeoGebra_6\app-6.0.583\api-ms-win-core-privateprofile-l1-1-1.dll
-----this one may be missing, I will copy it and have a try
C:\Users\rmd\AppData\Local\GeoGebra_6\app-6.0.583\api-ms-win-core-shutdown-l1-1-1.dll
-----
C:\Users\rmd\AppData\Local\GeoGebra_6\app-6.0.583\api-ms-win-service-private-l1-1-1.dll
C:\Windows\System32\downlevel\api-ms-win-service-private-l1-1-1.dll
C:\Windows\SysWOW64\downlevel\api-ms-win-service-private-l1-1-1.dll
C:\Windows\WinSxS\amd64_microsoft-windows-m..namespace-downlevel_31bf3856ad364e35_6.3.9600.16384_none_b8233abb5511544f\api-ms-win-service-private-l1-1-1.dll
C:\Windows\WinSxS\x86_microsoft-windows-m..namespace-downlevel_31bf3856ad364e35_6.3.9600.16384_none_5c049f379cb3e319\api-ms-win-service-private-l1-1-1.dll

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Matt J
Matt J am 6 Jun. 2022
Bearbeitet: Matt J am 6 Jun. 2022

0 Stimmen

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 Kommentare

Thanks for your comment. I've been trying to implement something along these lines, with the goal of maximizing the mutual information between images similar to imregtform behaves. I've been trying to use fmincon and globalsearch with different settings but so far it's been failing to consistently find the global solution to the problem. Any advice on how to set up an algorithm that will behave similarly to the imregtform regular step gradient descent? I'm not sure how to implement this.
Are you implementing a multi-resolution pyramid?
No, nor am I familiar with what that is.
Matt J
Matt J am 1 Aug. 2022
Bearbeitet: Matt J am 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.
Ok thanks, I'll try that out.

Melden Sie sich an, um zu kommentieren.

Image Analyst
Image Analyst am 1 Aug. 2022

0 Stimmen

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 Kommentare

Is it rotating and scaling while it translates?
For that matter, is the registration rigid or deformable?
Right, sorry, I should have included that in the initial question. The registration includes any sort of affine deformation, so correlation isn't an option. My application is registering a region of the initial frame to each successive frame of a video to track deformation and calculate mechanical strain in a material during a tensile test. I haven't had any success using feature-based registration with my images in the past - the best results I've had were using imregtform to maximize the mutual information between images. It works great when I have a rectangular region of the image to track, but when the region of the material I want to track is a different shape then I can't use imregtform.
You might try SIFT or SURF
and point set matching on the results.
I think the Computer Vision Toolbox has some points set matching functions with the LIDAR capability.
Good luck - it's not an easy problem.
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?
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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Produkte

Version

R2021a

Gefragt:

am 31 Mai 2022

Bearbeitet:

am 8 Nov. 2024

Community Treasure Hunt

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

Start Hunting!

Translated by