[Insight-users] Origin in shrink image filter wrong?

Luis Ibanez luis.ibanez at kitware.com
Mon Dec 21 19:30:15 EST 2009


Hi Lodron,

The computation of the origin for the ShrinkImageFilter
is not as trivial as one may expect at first sight.

We spent three or four Tcons discussing this issue,
See, for example:

           http://www.itk.org/Wiki/Minutes_032709


To summarize:

    NO, the origin of the Shrunk image is not the
    same as the origin of the input image.


They are related by the following code:

  typename TOutputImage::PointType outputOrigin = outputPtr->GetOrigin();
  outputOrigin = outputOrigin + (inputCenterPoint - outputCenterPoint);
  outputPtr->SetOrigin(outputOrigin);


that you can find in lines 355-357 of the file

     Insight/Code/BasicFilters
             itkShrinkImageFilter.txx


In order to make sense of these computation
you should consider that:

    1) ITK origin is given in physical coordinates

    2) Pixel coordinates in ITK are associated with
        the center of the pixel
        (not its corner, as it is done in VTK).


    Regards,


           Luis


-------------------------------------------------------------
On Tue, Dec 15, 2009 at 4:42 AM, Lodron, Gerald
<Gerald.Lodron at joanneum.at> wrote:
> Hi
>
> I try to downsample a DICOM image with shrink image filter and i come to no sollution. The problem is that the origin of the result is wrong:
>
> When i load the same DICOM 3D image with the same code and downsample one of them by factor two the images should be aligned, am i right? So when i use the checkerboard the only difference should be the ressolution, am i right? But the images are not aligned so what went wrong? I am really at the end of my vodoo.
>
> I use ITK 3.16.0 with following settings on:
> ITK_IMAGE_BEHAVES_AS_ORIENTED_IMAGE
> ITK_USE_CENTERED_PIXEL_COORDINATES_CONSISTENTLY
> ITK_USE_CONSOLATED_MORPHOLOGY
> ITK_USE_OPTIMIZED_REGISTRATION_METHODS
> ITK_USE_ORIENTED_IMAGE_DIRECTION
> ITK_USE_PATENTED
> ITK_USE_REGION_VALIDATION_IN_ITERATORS
> ITK_USE_REVIEW
> ITK_USE_SYSTEM_GDCM     (i installed and use gdcm 2.0.14)
> ITK_USE_TEMPLATE_META_PROGRAMMING_LOOP_UNROLLING
>
> The rest is off.
>
> Here my pseudocode
>
> vtkImageData    image1; //3D image of short
> vtkImageData    image2; //the same
>
> //Image1 is exactly the same as image 2, i use vtkCheckerboard to compare them and they are the same
>
> //first i convert both to ITK
> Itk::VTKImageToImageFilter<...>::Pointer connector1 = ...::New();
> Itk::VTKImageToImageFilter<...>::Pointer connector2 = ...::New();
>
> Connector1->SetInput(...)
> ...
> Itk::OrientedImage<...>::pointer image1ITK;
> Itk::OrientedImage<...>::pointer image2ITK;
>
> //now i use shrink image filter to downsample one of them
>
> itk::ShrinkImageFilter<>::Pointer filter = itk::ShrinkImageFilter<>::New();
> filter->SetInput(image2ITK);
> filter->SetShrinkFactor(2);
>
>
> Itk::OrientedImage<...>::pointer image2ITKSmall = filter->getOutput();
>
>
> //and back to vtk
> Itk::ImageToVTKImageFilter::Pointer c1 = ...::New();
> Itk::ImageToVTKImageFilter::Pointer c2 = ...::New();
>
> C1->setInput(image1ITK);
> //C2->setInput(image2ITK);              //with that the images are aligned
> C2->setInput(image2ITKSmall);           //with that not aligned
>
> //back to vtk and visualize with checkerboard
>
> vtkImageCheckerboard*   Checkerboard= vtkImageCheckerboard::New();
>
> Checkerboard->SetInput(0, C1->getOutput());
> Checkerboard->SetInput(1, C2->getOutput());
> Checkerboard->SetNumberOfDivisions(2, 2, 2);
>
> //visualize Checkerboard->getOutput()
> ...
>
>
>
>
>
>
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>


More information about the Insight-users mailing list