[Insight-developers] Follow up on bug #8470

Luis Ibanez luis.ibanez at kitware.com
Thu Mar 12 08:37:01 EDT 2009


Hi Mathieu,

The recent change was addressing the following situation:


     a) Having an image of Dimension N in a file
     b) Instantiating an itk::Image of Dimension M (where M < N)
     c) Using the itk::ImageFileReader instantiated over the
        itk::Image from (b) in order to read the file from (a).

Before the fix, the ImageFileReader was taking the N x N direction
matrix from (a), and simply grabbing its M x M upper-left sub-matrix
in order to construct the directions for the M-Dimensional image.

This resulted in exceptions being thrown when reading a 3D image
with direction cosines:


                 0  1   0
                 0  0  -1
                 1  0   0

since the upper-left 2x2 matrix end up being

                 0 1
                 0 0

The discussion in the mailing list led us to conclude that
there was no meaningful 2x2 matrix can could carry the 3D
position of the original image, and therefore any 2x2 matrix
would be an arbitrary choice.

Along those lines, the most innocuous arbitrary choice was
an identity matrix.

So, the current code, when it finds that you are reading an image
file of dimension 4, into an itk::Image<> of dimension 3, it simply
set the 3x3 direction cosines to an identity.


---

All that bein said, the case that your report looks strange,
since the exception is reported on an image of 4 dimensions.

Could you please describe in more detail what you were doing ?

Were you:

    A) Reading an image file of 5D into an itkImage of 4D ?
    B) Reading an image file of 4D into an itkImage of 4D ?
    C) Reading an image file of 3D into an itkImage of 4D ?




 From your code snippet it seems that your filter is not considering
the cases of:


       InputImageDimension > OutputImageDimension
       InputImageDimension < OutputImageDimension




      Luis



--------------------------
Mathieu Malaterre wrote:
> I am not sure I understand what was the internal change in ITK
> recently but I am getting an error since my ITK 3.12 upgrade:
> 
> ...
> Test timeout computed to be: 1500
> terminate called after throwing an instance of 'itk::ExceptionObject'
>   what():  /home/mmalaterre/Projects/Insight/Code/Common/itkImage.txx:165:
> itk::ERROR: Image(0x2aaab0006340): Bad direction, determinant is 0.
> Direction is 1 0 0 0
> 0 1 0 0
> 0 0 1 1
> 0 0 0 0
> 
> -- Process completed
> 
> *** Exception executing: Child aborted
> ...
> 
> 
> apparently a fix has been commited to ITK 3.12, but it seems my case
> is not handled properly.
> 
> My custom filter is doing this in the GenerateOutputInformation()
> 
> ...
>   for (unsigned int i=0; i < InputImageDimension; ++i)
>     {
>     for (unsigned int dim = 0; dim < OutputImageDimension; ++dim)
>       {
>       outputDirection[i][dim] = inputDirection[i][dim];
>       }
>     }
> ...
> 
> I do not see anything obviously wrong :(
> 
> thanks for comments,


More information about the Insight-developers mailing list