[Insight-users] Comparing images only with same size + tolerance?

Luis Ibanez luis.ibanez at kitware.com
Fri, 16 Jan 2004 10:18:52 -0500


Hi Reinhold,

I'm not sure I understand your description
of the flipping effect.

Are you comparing the images after flippping
one of them ?

Why are you doing this flipping ?

are the 0,1,2,3 entries in your email the
results of the four possible flips of a 2D
image over axis X and Y ?

What is the normal range of intensities in
your images ?
0:255 ?
or are they having pixel types float ?

The mean differences that you get may be
actually very high is the dynamic range
of the pixels is  [0:1].

You can always normalize the mean difference
by the mean of one of the images in order to
remove the dependency on the pixel intensity
range.

Can you post your images in MyPacs ?

      http://www.mypacs.net

(you can open an account for free)


----

You can check the algorithm used by the
DifferenceImageFilter by looking at

  Insight/Code/Common/itkDifferenceImageFilter.txx

on lines 146 - 197.

It goes like this

  totalDifference = 0

  FOR ALL PIXELS DO

    - in a neighborhood find the pixel
      with the value closest to this one

    - compute the absolute value of the
      difference between the value of this
      pixel and the value of its neighbor
      with closest value:

      difference = Abs( pixel - closestValue)

    - totalDifference += difference

  ENDFOR
  totalDifference =/ number of pixels


The idea of this neighborhood is to give some
tolerance to translational shifts on the images.


It will be interesting to look at your images,
there maybe something in their geometrical
structure that is allowing the flipped versions
to produce lower differences than the straight
versions.

---

NormalizedCorrelation is a good metric for
evaluation since it has a very pointy center.
That is, the value decreases rapidly when
the images are not aligned correctly.



Regards,


    Luis


-----------------------
Reinhold Füreder wrote:
> Dear Luis,
> 
> Thank you very much indeed for your extensive response.
> 
> Your suggested option 2 was exactly what I needed (coincident coordinate
> system). When using the DifferenceImageFilter on the extracted ROIs of
> the two images I get "interesting"/confusing results, because I
> regularly get a lower deviation (i.e. GetMeanDifference () method) if
> the structure described by pixel values != 0 is flipped around an axis
> than in the correct "alignment" case. Moreover, each of the possible
> flipped images gives very similar calculation results, e.g.
> 
>   0: 0.687906
>   1: 0.525622
>   2: 0.585111
>   3: 0.662708
> Difference filter does not comply!!!
>   Expected: 2
>   Found:    1
> 
> 
> How is the difference calculated by DifferenceImageFilter?
> 
> 
> The registration is not computed by means of ITK, however, I have the
> final transformation matrix available. Is the NormalizedCorrelation
> image metric mentioned by you in option 3 now the preferred option as it
> does not require anything else?
> 
> Thanks,
> 	Reinhold
> 
> 
>>-----Original Message-----
>>From: Luis Ibanez [mailto:luis.ibanez at kitware.com] 
>>Sent: Thursday, January 15, 2004 7:52 PM
>>To: Reinhold Füreder
>>Cc: insight-users at itk.org
>>Subject: Re: [Insight-users] Comparing images only with same 
>>size + tolerance?
>>
>>
>>
>>Hi Reinhold,
>>
>>
>>The DifferenceImageFilter expects the
>>two input images to have the same size. 
>>http://www.itk.org/Insight/Doxygen/html/classitk_1_1Difference
>>ImageFilter.html
>>
>>In this filter the tolerance is controlled
>>by setting the maximum allowed difference
>>between pixel values and by setting the
>>radius of the region to select the more
>>similar pixel.
>>
>>The SquareDifferenceImageFilter is only
>>useful as a visual aid. It doesn't compute
>>a measure of the difference. Instead it
>>shows you where the images are having
>>differences. 
>>http://www.itk.org/Insight/Doxygen/html/classitk_1_1SquaredDif
>>ferenceImageFilter.html
>>
>>If you have images of two difference sizes
>>you may want to consider the following options:
>>
>>
>>1) Resample one of the images onto the
>>    resolution and coordinate system of
>>    the other. Then use the DifferenceImageFilter
>>    between the resampled image and the one
>>    used as reference.
>>
>>Or
>>
>>2) If the coordinate systems are already
>>    coincident, you can use the
>>    RegionOfInterestImageFilter 
>>http://www.itk.org/Insight/Doxygen/html/classitk_1_1RegionOfIn
>>terestImageFilter.html
>>    in order to extract the common region between
>>    the images, and then compare these two common
>>    regions using the DifferenceImageFilter
>>
>>Or
>>
>>3) Use any ImageMetric different from the
>>    one you used for computing the registration. 
>>http://www.itk.org/Insight/Doxygen/html/classitk_1_1ImageToIma
>>geMetric.html
>>    feed the metric with the interpolator of your
>>    choice and the appropriate transform that
>>    will overlap the common regions between the
>>    two images. Then, simply trigger the computation
>>    of the metric and take the metric value as...
>>    what it is after all : an evaluation of how
>>    similar the two images are.
>>
>>    For example, if you performed the registration
>>    using MeanSquare, you can evaluate the result
>>    using NormalizedCorrelation.
>>
>>
>>Note that if the final goal is to do regression
>>testing of a registration algorithm, you can
>>simply take the last metric value of the registration
>>and use it as baseline value for the future executions
>>of the test.
>>
>>
>>
>>Regards,
>>
>>
>>   Luis
>>
>>
>>
>>-------------------------
>>Reinhold Füreder wrote:
>>
>>
>>>Dear Luis et al,
>>>
>>>In 
>>>
>>
>>http://public.kitware.com/pipermail/insight->
> 
> users/2003-June/004034.htm
> 
>>>l
>>>Luis pointed out that there are 2 filters to compare 2 
>>
>>images, namely
>>
>>>the DifferenceImageFilter and the 
>>
>>SquaredDifferenceImageFilter. In order
>>
>>>to perform a basic regression testing I therefore use, as 
>>
>>suggested, the
>>
>>>DifferenceImageFilter, as it returns some similarity metrics.
>>>
>>>And here is my problem: the 2 images to compare may have very 
>>>different sizes, while the structure described by pixel 
>>
>>values != 0, 
>>
>>>should be similar. Is the assumption right, that the 
>>>DifferenceImageFilter only deals with equally sized images plus the 
>>>optional tolerance configured by SetToleranceRadius?
>>>
>>>Thus, I can not apply this filter but have to carry out a slow 
>>>pixel-index based comparison of the greatest common region 
>>
>>between the 
>>
>>>2 images?
>>>
>>>Thanks,
>>>	Reinhold
>>>
>>>--------------------
>>>Reinhold Füreder
>>>MPhil Student
>>>School of Eng., CS and Maths
>>>University of Exeter, UK
>>> 
>>>
>>>_______________________________________________
>>>Insight-users mailing list
>>>Insight-users at itk.org 
>>>http://www.itk.org/mailman/listinfo/insight-users
>>>
>>
>>
>>
>>
> 
>