[ITK Community] [Insight-users] LandmarkBasedTransformInitializer

Luis Ibanez luis.ibanez at kitware.com
Sun Dec 29 12:19:52 EST 2013


Hi Massi,

You may want to verify the content of the ITK image,
before it is passed to convert to a vtkImageData.

For example, save it into a file, and review its content
with an image viewer.


    Regards,

         Luis




On Sun, Dec 15, 2013 at 2:53 AM, Massinissa Bandou <
Massinissa.Bandou at usherbrooke.ca> wrote:

> Hi Luis,
> I modified my code for two 3D vtkImagaData (float). The code is compiling
> and I tried to read the output as a vtkImageData but the problem is the
> image is empty. (the output has 1 1 1 for the spacing and 0 for number of
> cells.)
>
>
>         typedef itk::Image<float, 3> ImageType;
>
>         typedef itk::VTKImageToImageFilter<ImageType> VTKToITKConnector;
>         VTKToITKConnector::Pointer vtk2itksource =
> VTKToITKConnector::New();
>         VTKToITKConnector::Pointer vtk2itktarget =
> VTKToITKConnector::New();
>         vtk2itksource->SetInput(source);    //vtkImageData source
>         vtk2itktarget->SetInput(target); //vtkImageData target
>
>         ImageType::Pointer  fixed = vtk2itksource->GetOutput();
>         ImageType::Pointer  moving = vtk2itktarget->GetOutput();
>
>         fixed->Update();
>         moving->Update();
>
>         typedef float VectorComponentType;
>         typedef itk::Vector<VectorComponentType,3> VectorType;
>         typedef itk::Image<VectorType, 3> DeformationFieldType;
>
>         typedef itk::VersorRigid3DTransform<double> Rigid3DTransformType;
>         typedef
>
> itk::LandmarkBasedTransformInitializer<Rigid3DTransformType,ImageType,ImageType>
> LandmarkBasedTransformInitializerType;
>
>         LandmarkBasedTransformInitializerType::Pointer
> landmarkBasedTransformInitializer =
> LandmarkBasedTransformInitializerType::New();
>         //Create source and target landmarks.
>         typedef
> LandmarkBasedTransformInitializerType::LandmarkPointContainer
> LandmarkContainerType;
>         typedef LandmarkBasedTransformInitializerType::LandmarkPointType
> LandmarkPointType;
>
>         LandmarkContainerType fixedLandmarks;
>         LandmarkContainerType movingLandmarks;
>         LandmarkPointType fixedPoint;
>         LandmarkPointType movingPoint;
>
>         fixedPoint[0] = 10;
>         fixedPoint[1] = 10;
>         movingPoint[0] = 50;
>         movingPoint[1] = 50;
>         fixedLandmarks.push_back( fixedPoint );
>         movingLandmarks.push_back( movingPoint );
>
>        fixedPoint[0] = 10;
>        fixedPoint[1] = 20;
>        movingPoint[0] = 50;
>        movingPoint[1] = 60;
>        fixedLandmarks.push_back( fixedPoint );
>        movingLandmarks.push_back( movingPoint );
>
>        fixedPoint[0] = 20;
>        fixedPoint[1] = 10;
>        movingPoint[0] = 60;
>        movingPoint[1] = 50;
>        fixedLandmarks.push_back( fixedPoint );
>        movingLandmarks.push_back( movingPoint );
>
>        fixedPoint[0] = 20;
>        fixedPoint[1] = 20;
>        movingPoint[0] = 60;
>        movingPoint[1] = 60;
>        fixedLandmarks.push_back( fixedPoint );
>        movingLandmarks.push_back( movingPoint );
>
>
>
>
> landmarkBasedTransformInitializer->SetFixedLandmarks(fixedLandmarks);
>
> landmarkBasedTransformInitializer->SetMovingLandmarks(movingLandmarks);
>
>         Rigid3DTransformType::Pointer transform =
> Rigid3DTransformType::New();
>
>         transform->SetIdentity();
>
> landmarkBasedTransformInitializer->SetTransform(transform.GetPointer());
>         landmarkBasedTransformInitializer->InitializeTransform();
>
>         typedef itk::ResampleImageFilter<ImageType, ImageType, double>
> ResampleFilterType;
>         ResampleFilterType::Pointer resampleFilter =
> ResampleFilterType::New();
>         resampleFilter->SetInput(moving);
>         resampleFilter->SetTransform(transform);
>
> resampleFilter->SetSize(fixed->GetLargestPossibleRegion().GetSize());
>         resampleFilter->SetOutputOrigin(fixed->GetOrigin());
>         resampleFilter->SetOutputSpacing(fixed->GetSpacing());
>         resampleFilter->SetOutputDirection(fixed->GetDirection());
>         resampleFilter->SetDefaultPixelValue(200);
>         resampleFilter->GetOutput();
>
>         //connect to VTK
>         typedef itk::ImageToVTKImageFilter<ImageType> ConnectType;
>         ConnectType::Pointer connector = ConnectType::New();
>         connector->SetInput(fixed);
>
>         vtkImageData *imageData = vtkImageData::New();
>         imageData->DeepCopy(connector->GetOutput());
>
>         double a[3];
>         imageData->GetSpacing(a);
>         cout<<"spacing: "<<a[0]<<"
> "<<a[1]<<"
> "<<a[2]<<endl;
>         cout<<imageData->GetNumberOfCells()<<endl;
> </h4>
>
>
>
> --
> View this message in context:
> http://itk-users.7.n7.nabble.com/LandmarkBasedTransformInitializer-tp32954p32996.html
> Sent from the ITK - Users mailing list archive at Nabble.com.
> _____________________________________
> 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.php
>
> 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
> _______________________________________________
> Community mailing list
> Community at itk.org
> http://public.kitware.com/cgi-bin/mailman/listinfo/community
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20131229/87c47bd7/attachment.html>
-------------- next part --------------
_____________________________________
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.php

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 Community mailing list