[Insight-users] Bug in ExtractImageFilter?

Elena Pavlovskaia Elena.Pavlovskaia at otismed.com
Wed Dec 10 15:56:33 EST 2008


Dear ITK developers,

I think that a bug was introduced to ExtractImageFilter in ITK 3.10

I was using ExtractImageFilter with ITK 3.6, and it worked fine. Since I switched to ITK 3.10 the same call to ExtractImageFilter thorows an exception "Bad direction, determinant is 0..." from ComputeIndexToPhysicalPointMatrices.

Here is the part of the code that leads to the exception:

        typedef  itk::Image<short, 2>                                                           Image2DType;
        typedef  itk::Image<short, 3>                                                           Image3DType;
        typedef ExtractImageFilter<Image3DType, Image2DType>             ExtractSliceFilter;

void ExtractSlice( const Image3DType* grayImage, int iSlice, ... )
{
...
        Image3DType::RegionType region = grayImage->GetBufferedRegion();
        Image3DType::RegionType::IndexType index = region.GetIndex();
        Image3DType::RegionType::SizeType size = region.GetSize();

                ExtractSliceFilter::Pointer sliceExtractor = ExtractSliceFilter::New();
                sliceExtractor->SetInput( grayImage );

                Image3DType::RegionType extractRegion;
                Image3DType::RegionType::IndexType extractIndex = index;
                Image3DType::RegionType::SizeType extractSize = size;

                extractIndex[0] = iSlice;
                extractSize[0] = 0;

                extractRegion.SetIndex( extractIndex );
                extractRegion.SetSize( extractSize );

                sliceExtractor->SetExtractionRegion( extractRegion );
                sliceExtractor->Update();
...
}

The values by the moment of the last call (  sliceExtractor->Update() ) are:

index = (0, 0, 0)
size = (50, 512, 512)
iSlice = 25, and hence
extractIndex = (25, 0, 0),
extractSize = (0, 512, 512)

I put the following fix into
ExtractImageFilter<TInputImage,TOutputImage>
::GenerateOutputInformation()
and it works for me:

Right after the line

          int nonZeroCount2 = 0;

// BUGFIX  ======================== BEGIN =======================
// BUGFIX I replaced this:
/*
          for (unsigned int dim = 0; dim < OutputImageDimension; ++dim)
            {
            if (m_ExtractionRegion.GetSize()[dim])
              {
              outputDirection[nonZeroCount][nonZeroCount2] =
                inputDirection[nonZeroCount][dim];
              ++nonZeroCount2;
              }
            }
*/
// BUGFIX with this:

           for (unsigned int dim = 0; dim < InputImageDimension; ++dim)
            {
            if (m_ExtractionRegion.GetSize()[dim])
              {
              outputDirection[nonZeroCount][nonZeroCount2] =
                inputDirection[i][dim];
              ++nonZeroCount2;
              }
            }
// BUGFIX ========================= END ========================


(Actually I replaced two words:
OutputImageDimension --> InputImageDimension and
nonZeroCount --> i
)

Thanks,

Elena



CONFIDENTIAL COMMUNICATION: This email (and accompanying
documents) transmitted is intended only for the person or entity
to which it is addressed and may contain confidential and/or
privileged material. Any review, retransmission, dissemination or
other use of, or taking of any action in reliance upon, this
information by persons or entities other than the intended
recipient is prohibited, and may be a violation of law. If you
believe that you received this e-mail in error, please do not
read this e-mail or any attached items. Please delete the e-mail
and all attachments, including any copies thereof, and inform the
sender that you have deleted the e-mail, all attachments and any
copies thereof.

PRIVACY/CONFIDENTIALITY NOTICE REGARDING PROTECTED HEALTH
INFORMATION: This email (and accompanying documents) may contain
protected health information that is privileged, confidential
and/or otherwise exempt from and protected from disclosure under
applicable laws, including the Health Insurance Portability and
Accountability Act. The information contained in this email (and
any accompanying documents) is intended only for the personal and
the confidential use of the intended recipient. If the reader of
this message is not the intended recipient or the employee or
agent responsible for delivering it to the intended recipient,
you are hereby notified that you have received this information
in error and that any review, dissemination, distribution,
copying or action taken in reliance on the contents of this
communication is strictly prohibited. If you have received this
communication in error, please destroy it immediately and notify
the sender.



More information about the Insight-users mailing list