MantisBT - ITK
View Issue Details
0008058ITKpublic2008-11-07 11:262009-03-25 09:07
Hans Johnson 
kentwilliams 
normalmajoralways
closedopen 
ITK-3-8 
 
0008058: Output Image directions are not set consistently from filters
This is not really a bug with ITK_IMAGE_BEHAVES_AS_ORIENTED_IMAGE, but applications that previously worked because the orientation was ignored may now start to fail when this flag is turned on.

I discovered several bugs when ITK_IMAGE_BEHAVES_AS_ORIENTED_IMAGE is turned on, and images with different directions are used.

I'm working on a patch right now, but it does touch many many files. So far my tests have shown that regression tests pass both with or without setting the output directions. The problem showed up when attempting to register images that have different orientations, spacing's, size, and origins. I think that our test data is too uniformly defined to catch these problems.

=======================================================
grep -A 2 -B 2 "Set.*Spacing.*Get.*Spacing" Insight/Code/*/* > ReviewList

From this I look for patterns like the following:

Code/Algorithms/itkBayesianClassifierImageFilter.txx- this->GetOutput()->SetRegions( membershipImage->GetBufferedRegion() );
Code/Algorithms/itkBayesianClassifierImageFilter.txx: this->GetOutput()->SetSpacing( membershipImage->GetSpacing() );
Code/Algorithms/itkBayesianClassifierImageFilter.txx- this->GetOutput()->SetOrigin( membershipImage->GetOrigin() );
Code/Algorithms/itkBayesianClassifierImageFilter.txx- this->GetOutput()->Allocate();

NOTICE: The output of this filter does not set the Direction!!!!
this->GetOutput()->SetDirection( membershipImage->GetDirection() );
=======================================================

Unfortunately this seems like a very common problem throughout ITK. It is my assumption that most filters that: a) take input image, b) do something to the intensity values, c) generate and output image; will behave in such a way that the output image has the same origin, spacing, size, AND direction as the input image. Filters that: a)take an input image, b) take parameters for desired output physical space defintion, c) generate the new output image; must have options for setting Spacing, Origin, AND Direction.

Experimental build: http://www.cdash.org/CDash/buildSummary.php?buildid=210257 [^]

I hope to have the code committed and bugs reported in about 1 hour.

Hans
Current list of affected files being addressed:

M Code/Algorithms/itkBayesianClassifierImageFilter.txx
M Code/Algorithms/itkCollidingFrontsImageFilter.txx
M Code/Algorithms/itkFEMRegistrationFilter.txx
M Code/Algorithms/itkFastMarchingImageFilter.h
M Code/Algorithms/itkFastMarchingImageFilter.txx
M Code/Algorithms/itkFastSymmetricForcesDemonsRegistrationFunction.txx
M Code/Algorithms/itkMultiResolutionPDEDeformableRegistration.txx
M Code/Algorithms/itkPDEDeformableRegistrationFilter.txx
M Code/BasicFilters/itkHoughTransform2DCirclesImageFilter.txx
M Code/BasicFilters/itkHoughTransform2DLinesImageFilter.txx
M Code/BasicFilters/itkIterativeInverseDeformationFieldImageFilter.txx
M Code/BasicFilters/itkPointSetToImageFilter.h
M Code/BasicFilters/itkPointSetToImageFilter.txx
M Code/BasicFilters/itkPolylineMask2DImageFilter.txx
M Code/BasicFilters/itkPolylineMaskImageFilter.txx
M Code/BasicFilters/itkResampleImageFilter.txx
M Code/Common/itkBSplineDeformableTransform.txx
M Code/Common/itkDenseFiniteDifferenceImageFilter.txx
M Code/Patented/itkVectorFuzzyConnectednessImageFilter.txx
M Code/Review/itkBSplineScatteredDataPointSetToImageFilter.txx
M Code/Review/itkDiffeomorphicDemonsRegistrationFilter.txx
M Code/Review/itkESMDemonsRegistrationFunction.h
M Code/Review/itkESMDemonsRegistrationFunction.txx
M Code/Review/itkExponentialDeformationFieldImageFilter.txx
M Code/Review/itkFastSymmetricForcesDemonsRegistrationFilter.txx
M Code/Review/itkOptResampleImageFilter.txx
No tags attached.
related to 0008680closed kentwilliams Output Spacing etc. is not set in ReinitializeLevelSetImageFilter 
Issue History
2008-11-07 11:26Hans JohnsonNew Issue
2009-03-10 20:06Hans JohnsonStatusnew => assigned
2009-03-10 20:06Hans JohnsonAssigned To => kentwilliams
2009-03-11 18:03kentwilliamsNote Added: 0015661
2009-03-12 16:44kentwilliamsNote Added: 0015676
2009-03-25 09:07Hans JohnsonStatusassigned => closed
2009-03-26 17:29kentwilliamsRelationship addedrelated to 0008680

Notes
(0015661)
kentwilliams   
2009-03-11 18:03   
Hans, you say you're working on a patch for this and have modified files, but I'm assigned the bug.

Do you want to send me your modified files and have me try to write tests for this or what?
(0015676)
kentwilliams   
2009-03-12 16:44   
I did another search, and every place that pattern occurs, SetSpacing (or SetOutputSpacing) is followed by SetDirection (or SetOutputDirection).

The only place it appears not to happen is in ImageFunction classes, and I don't think in that case it's relevant.