Images with bad starting conditions

Hi.
I’m new to ITK.

I have a set of template + image pairs.
The pairs are of a thermal template and visual photo image.
There is a significant translation between the images.
I need to solve other transformation parameters too (rotation scale shear) but the distance in these dimension is smaller.

I work whith the gradient images;
When I fix the translation manualy to be close to truth.
I get good result using gradient descent.
I figured that gradient descent wont work for me with the original starting conditions so I’m trying to do an initial phase with the exhaustive optimizer.

Can I limit the optimizer for specific range of scales, rotations, (and translations)?

are there any better suggestions?

Thanks.

Hello @avispi,

The gradient descent optimizer does not support bound constraints, so you cannot limit parameters to specific ranges. The exhaustive optimizer enables sampling of the parameter space using a grid, so it is very specific.

There are two SimpleITK notebooks illustrating the use of an exhaustive optimizer as an initialization step, possibly these are relevant, registration initialization, x-ray panorama.

Thanks a lot for the answer.
I’ll try using these examples.
I’m using c++.
does one of the c++ examples contain this?

Have you tried using CenteredTransformInitializer?

Hi and thanks.
the iniitializer either initializes with the vector between the iamges center or the vector between center of mass (using moments).
both approaches assume some dominant object which covers most of both images (and specifically- the larger image) .

I’m talking about template matching in a more complex case where some other metric is needed (i.e mutual information, which ITK has) and not only translation exists between images (altho other components of transformation are small).

For start- is there an ITK solution for a standad (only translation) template matching problem?

I tried translating the examples to c++ itk code.
Something is not working.
while I keep trying- Is there a similar c++ example?

Hello @avispi,

Template matching is related to registration but it is a different problem as there can be multiple instances of the template in the image where we are searching.

The only optimizer in ITK which can be readily used for template matching is the ExhaustiveOptimizer where we have direct control over the samples in the transformation parameter space. This allows you to place the template, possibly after rotation/scaling, over the other image and obtain the similarity value.

As the optimizer is not really set up for this use case, you will have to keep all the results from the optimizer (command-observer pattern) and using a threshold on the similarity metric select the transformations that match the template.