MantisBT - ITK |
View Issue Details |
|
ID | Project | Category | View Status | Date Submitted | Last Update |
0008275 | ITK | | public | 2008-12-09 23:15 | 2009-03-10 20:01 |
|
Reporter | Hans Johnson | |
Assigned To | Bill Lorensen | |
Priority | normal | Severity | major | Reproducibility | always |
Status | closed | Resolution | fixed | |
Platform | | OS | | OS Version | |
Product Version | ITK-3-10 | |
Target Version | | Fixed in Version | ITK-3-10 | |
Resolution Date | |
Sprint | |
Sprint Status | |
|
Summary | 0008275: itkShrinkImageFilter does not preserve object physical locations |
Description | I identified a bug that when using a itkMultiResolutionPyramidImageFilterTest that the center of mass of the images at the different levels was not the same.
The problem is actually in the itkShrinkImageFilter which is not preserving the center of mass of the image object.
I created a new test, ShrinkImagePreserveObjectPhysicalLocations, that tests that the center mass is preserved across all image scales. |
Steps To Reproduce | |
Additional Information | I've created two pictures that helped me identify what was going on.
This will cause some other tests to fail:
573 - itkShrinkImageTest (Failed)
782 - itkMultiResolutionPyramidImageFilterTest (Failed)
784 - itkRecursiveMultiResolutionPyramidImageFilterTest (Failed)
785 - itkMultiResolutionPDEDeformableRegistrationTest (SEGFAULT)
817 - itkDeformableTest (SEGFAULT)
1205 - MultiResImageRegistration1Test (Failed)
1206 - MultiResImageRegistration1Test2 (Failed)
1207 - MultiResImageRegistration2Test (Failed)
1208 - MultiResImageRegistration2Test2 (Failed)
I believe that these are actually "more correct" now, and may just need to have new reference images created.
|
Tags | No tags attached. |
Relationships | related to | 0008245 | closed | Bill Lorensen | ShrinkImageFilter does not stream | related to | 0008482 | closed | kentwilliams | RecursiveMultiResolutionPyramid needs to center of mass of original image |
|
Attached Files | itkShrinkImageFilter_Bug_Documents.zip (571,447) 2008-12-09 23:15 https://public.kitware.com/Bug/file/1910/itkShrinkImageFilter_Bug_Documents.zip |
|
Issue History |
Date Modified | Username | Field | Change |
2008-12-09 23:15 | Hans Johnson | New Issue | |
2008-12-09 23:15 | Hans Johnson | File Added: itkShrinkImageFilter_Bug_Documents.zip | |
2008-12-09 23:16 | Hans Johnson | Status | new => assigned |
2008-12-09 23:16 | Hans Johnson | Assigned To | => Luis Ibanez |
2008-12-09 23:23 | Hans Johnson | Note Added: 0014317 | |
2008-12-10 11:22 | Hans Johnson | Note Added: 0014318 | |
2008-12-10 11:26 | Hans Johnson | Relationship added | related to 0008245 |
2008-12-10 11:27 | Hans Johnson | Note Added: 0014319 | |
2008-12-11 23:38 | Bill Lorensen | Assigned To | Luis Ibanez => Bill Lorensen |
2008-12-16 23:28 | Hans Johnson | Note Added: 0014377 | |
2008-12-19 23:50 | Bill Lorensen | Note Added: 0014412 | |
2008-12-19 23:50 | Bill Lorensen | Status | assigned => resolved |
2008-12-19 23:50 | Bill Lorensen | Resolution | open => fixed |
2009-02-07 16:58 | Hans Johnson | Relationship added | related to 0008482 |
2009-03-10 20:01 | Hans Johnson | Note Added: 0015630 | |
2009-03-10 20:01 | Hans Johnson | Status | resolved => closed |
2009-03-10 20:01 | Hans Johnson | Fixed in Version | => ITK-3-10 |
Notes |
|
(0014317)
|
Hans Johnson
|
2008-12-09 23:23
|
|
PATCH THAT FIXES BUGS:
Index: Code/BasicFilters/itkShrinkImageFilter.txx
===================================================================
RCS file: /cvsroot/Insight/Insight/Code/BasicFilters/itkShrinkImageFilter.txx,v
retrieving revision 1.54
diff -b -r1.54 itkShrinkImageFilter.txx
26a27
> #include "itkLinearInterpolateImageFunction.h"
145c146,147
< typename TInputImage::IndexType inputIndex;
---
> typedef ContinuousIndex<double, TInputImage::ImageDimension> ContinuousIndexType;
> ContinuousIndexType inputIndex;
146a149,153
> typename TOutputImage::PointType PhysicalPoint;
>
> typedef LinearInterpolateImageFunction< TInputImage, double > LinearInterpolatorType;
> typename LinearInterpolatorType::Pointer inputInterp=LinearInterpolatorType::New();
> inputInterp->SetInputImage(inputPtr);
161c168
<
---
> outputPtr->TransformIndexToPhysicalPoint(outputIndex,PhysicalPoint);
163c170
< inputIndex = outputIndex * factorSize;
---
> inputPtr->TransformPhysicalPointToContinuousIndex(PhysicalPoint,inputIndex);
166c173
< outIt.Set( inputPtr->GetPixel(inputIndex) );
---
> outIt.Set( inputInterp->EvaluateAtContinuousIndex(inputIndex) );
168d174
<
257a264,265
> const typename TInputImage::PointType&
> inputOrigin = inputPtr->GetOrigin();
263a272
> typename TOutputImage::PointType outputOrigin;
266a276,277
> typename TOutputImage::PointType::VectorType outputOriginOffset
> =outputPtr->GetDirection()*(outputSpacing-inputSpacing)*0.5;
269d279
<
277d286
<
280d288
< }
281a290,291
> outputOrigin[i]=inputOrigin[i]+outputOriginOffset[i];
> }
282a293
> outputPtr->SetOrigin ( outputOrigin );
|
|
|
(0014318)
|
Hans Johnson
|
2008-12-10 11:22
|
|
I feel quite strongly that an 8x8 white square in the middle of a 32x32 space should retain it's center of mass after the shrink image is applied with a shrink factor of 2,4, or 8. This is one of the test cases in the new failing test I added last night. In the current implementation, the center of mass is not preserved.
In the case of shrinking a 64x64 image to an 8x8 image, the index locations map as follows
Fill Current Proposed Object Space Preserving
Output Input Input Input ContinuousIndex
[0,0] [0,0] [4,4] [3.5,3.5]
[1,1] [8,8] [12,12] [11.5,11.5]
...
...
[7,7] [56,56] [60,60] [59.5,59.5]
By reading from the current input there is a bias towards shifting the objects towards the origin in the current implementation. Perhaps the best way to deal with this would be to add the difference between columns 3 and 4 in the table above to the origin.
* My proposed solution will need to better checking of boundary conditions (seg fault would occur on images of size 60x60 being sub-sampled to and image space of 8x8). |
|
|
(0014319)
|
Hans Johnson
|
2008-12-10 11:27
|
|
On 12/10/08 9:36 AM, "Bradley Lowekamp" <blowekamp@mail.nih.gov> wrote:
Hello,
Another thing to consider is the bug I recent found: http://public.kitware.com/Bug/view.php?id=8245 [^] I believe the EnlargeOutputRequestedRegion method implemented in ShrinkImageFilter is wrong, not needed and prevents this filter from streaming. I have not had a chance to write a couple of tests though.
I have been needing a box filter shrinking image filter. I am planning on writing it shortly. The one thing I have pondered is if there is a good way to use different types of kernels when doing the resampling. I am not sure how this relates to how Hans is using the original filter, but may be useful.
The proposed patched does two thing. First it changes the filter to use a linear interpolator. I agree that this should not be added. Second it improves the calculation of the origin so that the center of the image remains the same. I think that this makes sense and should seriously be considered. For Hans' calculations it would give improved accuracy on the center of the image. I am wondering if for multi-scale registration methods if it would give additional accuracy too...
Brad
========================================================
Bradley Lowekamp
Lockheed Martin Contractor for
Office of High Performance Computing and Communications
National Library of Medicine
blowekamp@mail.nih.gov |
|
|
(0014377)
|
Hans Johnson
|
2008-12-16 23:28
|
|
Part of this bug was addressed with changes submitted:
/cvsroot/Insight/Insight/Code/Algorithms/itkMultiResolutionPyramidImageFilter.txx,v <-- Code/Algorithms/itkMultiResolutionPyramidImageFilter.txx
new revision: 1.26; |
|
|
(0014412)
|
Bill Lorensen
|
2008-12-19 23:50
|
|
|
|
(0015630)
|
Hans Johnson
|
2009-03-10 20:01
|
|
Shrink image filter has been fixed By Bill Lorensen |
|