<div dir="ltr">Hi Massi,<div><br></div><div>You may want to verify the content of the ITK image, </div><div>before it is passed to convert to a vtkImageData.</div><div><br></div><div>For example, save it into a file, and review its content</div>
<div>with an image viewer.</div><div><br></div><div><br></div><div>    Regards,</div><div><br></div><div>         Luis</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Dec 15, 2013 at 2:53 AM, Massinissa Bandou <span dir="ltr"><<a href="mailto:Massinissa.Bandou@usherbrooke.ca" target="_blank">Massinissa.Bandou@usherbrooke.ca</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Luis,<br>
I modified my code for two 3D vtkImagaData (float). The code is compiling<br>
and I tried to read the output as a vtkImageData but the problem is the<br>
image is empty. (the output has 1 1 1 for the spacing and 0 for number of<br>
cells.)<br>
<br>
<br>
        typedef itk::Image<float, 3> ImageType;<br>
<br>
        typedef itk::VTKImageToImageFilter<ImageType> VTKToITKConnector;<br>
        VTKToITKConnector::Pointer vtk2itksource = VTKToITKConnector::New();<br>
        VTKToITKConnector::Pointer vtk2itktarget = VTKToITKConnector::New();<br>
        vtk2itksource->SetInput(source);    //vtkImageData source<br>
        vtk2itktarget->SetInput(target); //vtkImageData target<br>
<br>
        ImageType::Pointer  fixed = vtk2itksource->GetOutput();<br>
        ImageType::Pointer  moving = vtk2itktarget->GetOutput();<br>
<br>
        fixed->Update();<br>
        moving->Update();<br>
<br>
        typedef float VectorComponentType;<br>
        typedef itk::Vector<VectorComponentType,3> VectorType;<br>
        typedef itk::Image<VectorType, 3> DeformationFieldType;<br>
<br>
        typedef itk::VersorRigid3DTransform<double> Rigid3DTransformType;<br>
        typedef<br>
itk::LandmarkBasedTransformInitializer<Rigid3DTransformType,ImageType,ImageType><br>
LandmarkBasedTransformInitializerType;<br>
<br>
        LandmarkBasedTransformInitializerType::Pointer<br>
landmarkBasedTransformInitializer =<br>
LandmarkBasedTransformInitializerType::New();<br>
        //Create source and target landmarks.<br>
        typedef LandmarkBasedTransformInitializerType::LandmarkPointContainer<br>
LandmarkContainerType;<br>
        typedef LandmarkBasedTransformInitializerType::LandmarkPointType<br>
LandmarkPointType;<br>
<br>
        LandmarkContainerType fixedLandmarks;<br>
        LandmarkContainerType movingLandmarks;<br>
        LandmarkPointType fixedPoint;<br>
        LandmarkPointType movingPoint;<br>
<br>
        fixedPoint[0] = 10;<br>
        fixedPoint[1] = 10;<br>
        movingPoint[0] = 50;<br>
        movingPoint[1] = 50;<br>
        fixedLandmarks.push_back( fixedPoint );<br>
        movingLandmarks.push_back( movingPoint );<br>
<br>
       fixedPoint[0] = 10;<br>
       fixedPoint[1] = 20;<br>
       movingPoint[0] = 50;<br>
       movingPoint[1] = 60;<br>
       fixedLandmarks.push_back( fixedPoint );<br>
       movingLandmarks.push_back( movingPoint );<br>
<br>
       fixedPoint[0] = 20;<br>
       fixedPoint[1] = 10;<br>
       movingPoint[0] = 60;<br>
       movingPoint[1] = 50;<br>
       fixedLandmarks.push_back( fixedPoint );<br>
       movingLandmarks.push_back( movingPoint );<br>
<br>
       fixedPoint[0] = 20;<br>
       fixedPoint[1] = 20;<br>
       movingPoint[0] = 60;<br>
       movingPoint[1] = 60;<br>
       fixedLandmarks.push_back( fixedPoint );<br>
       movingLandmarks.push_back( movingPoint );<br>
<br>
<br>
<br>
<br>
landmarkBasedTransformInitializer->SetFixedLandmarks(fixedLandmarks);<br>
        landmarkBasedTransformInitializer->SetMovingLandmarks(movingLandmarks);<br>
<br>
        Rigid3DTransformType::Pointer transform = Rigid3DTransformType::New();<br>
<br>
        transform->SetIdentity();<br>
        landmarkBasedTransformInitializer->SetTransform(transform.GetPointer());<br>
<div class="im">        landmarkBasedTransformInitializer->InitializeTransform();<br>
<br>
        typedef itk::ResampleImageFilter<ImageType, ImageType, double><br>
ResampleFilterType;<br>
        ResampleFilterType::Pointer resampleFilter = ResampleFilterType::New();<br>
</div>        resampleFilter->SetInput(moving);<br>
        resampleFilter->SetTransform(transform);<br>
        resampleFilter->SetSize(fixed->GetLargestPossibleRegion().GetSize());<br>
        resampleFilter->SetOutputOrigin(fixed->GetOrigin());<br>
        resampleFilter->SetOutputSpacing(fixed->GetSpacing());<br>
        resampleFilter->SetOutputDirection(fixed->GetDirection());<br>
        resampleFilter->SetDefaultPixelValue(200);<br>
        resampleFilter->GetOutput();<br>
<br>
        //connect to VTK<br>
        typedef itk::ImageToVTKImageFilter<ImageType> ConnectType;<br>
        ConnectType::Pointer connector = ConnectType::New();<br>
        connector->SetInput(fixed);<br>
<br>
        vtkImageData *imageData = vtkImageData::New();<br>
        imageData->DeepCopy(connector->GetOutput());<br>
<br>
        double a[3];<br>
        imageData->GetSpacing(a);<br>
        cout<<"spacing: "<<a[0]&lt;&lt;&quot; &quot;&lt;&lt;a[1]&lt;&lt;&quot;<br>
&quot;&lt;&lt;a[2]&lt;&lt;endl;<br>
        cout&lt;&lt;imageData->GetNumberOfCells()<<endl;<br>
&lt;/h4><br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://itk-users.7.n7.nabble.com/LandmarkBasedTransformInitializer-tp32954p32996.html" target="_blank">http://itk-users.7.n7.nabble.com/LandmarkBasedTransformInitializer-tp32954p32996.html</a><br>

<div class="im HOEnZb">Sent from the ITK - Users mailing list archive at Nabble.com.<br>
_____________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.php" target="_blank">http://www.kitware.com/products/protraining.php</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
</div><div class="HOEnZb"><div class="h5">_______________________________________________<br>
Community mailing list<br>
<a href="mailto:Community@itk.org">Community@itk.org</a><br>
<a href="http://public.kitware.com/cgi-bin/mailman/listinfo/community" target="_blank">http://public.kitware.com/cgi-bin/mailman/listinfo/community</a><br>
</div></div></blockquote></div><br></div>