Comparing Vector Images?

Hello, I have two vector images of type itk::Image<itk::Vector<double, 3>> that I am trying to compare for similarity. My first two approaches failed and I’m not sure why…

First, I found the itk::Testing::ComparisonImageFilter, which appears to be for comparing two images. The templated implementation didn’t appear to be able to handle images with a vector pixel type though. Is this correct, or did I just implement it wrong?

The next method I tried was to subtract one of the images from the other one. This didn’t work either! I thought that the subtraction operator would have been implemented for vector images. Do I have to use a filter for this instead?

I ended up just using two ImageRegionIterators and comparing each pixel value, which works well. However, I would like to understand why my first efforts didn’t! Does anyone have any Insight on this issue to share?

Thanks,
Andrew

Hi @crocodoyle,
I would say that your first hypothesis/question is the correct one:

The commit history of the itk::Testing::ComparisonImageFilter shows no related change since the above post, so I assume this is still to be done.

Not sure if the itk::SubtractImageFilter is adapted to work on vector component images. Maybe others can elaborate on this.

Opening issues, as well as providing testing data, would help bringing attention to these aspects, and folks in the community may be able to consider the feasibility of addressing them.

1 Like

Hello @crocodoyle,

Looking at the ComparisonImageFilter code it appears to assume scalar pixel types, so your observation that it doesn’t work for vector images is correct.

Another approach to doing what you want without having to explicitly iterate is to use the VectorIndexSelectionCast filter to separate the channels and then use the standard filters on a per channel basis, for example square the difference images, add them up and take the square root.

1 Like