<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">&lt;<a href="mailto:Massinissa.Bandou@usherbrooke.ca" target="_blank">Massinissa.Bandou@usherbrooke.ca</a>&gt;</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&lt;float, 3&gt; ImageType;<br>
<br>
        typedef itk::VTKImageToImageFilter&lt;ImageType&gt; VTKToITKConnector;<br>
        VTKToITKConnector::Pointer vtk2itksource = VTKToITKConnector::New();<br>
        VTKToITKConnector::Pointer vtk2itktarget = VTKToITKConnector::New();<br>
        vtk2itksource-&gt;SetInput(source);    //vtkImageData source<br>
        vtk2itktarget-&gt;SetInput(target); //vtkImageData target<br>
<br>
        ImageType::Pointer  fixed = vtk2itksource-&gt;GetOutput();<br>
        ImageType::Pointer  moving = vtk2itktarget-&gt;GetOutput();<br>
<br>
        fixed-&gt;Update();<br>
        moving-&gt;Update();<br>
<br>
        typedef float VectorComponentType;<br>
        typedef itk::Vector&lt;VectorComponentType,3&gt; VectorType;<br>
        typedef itk::Image&lt;VectorType, 3&gt; DeformationFieldType;<br>
<br>
        typedef itk::VersorRigid3DTransform&lt;double&gt; Rigid3DTransformType;<br>
        typedef<br>
itk::LandmarkBasedTransformInitializer&lt;Rigid3DTransformType,ImageType,ImageType&gt;<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-&gt;SetFixedLandmarks(fixedLandmarks);<br>
        landmarkBasedTransformInitializer-&gt;SetMovingLandmarks(movingLandmarks);<br>
<br>
        Rigid3DTransformType::Pointer transform = Rigid3DTransformType::New();<br>
<br>
        transform-&gt;SetIdentity();<br>
        landmarkBasedTransformInitializer-&gt;SetTransform(transform.GetPointer());<br>
<div class="im">        landmarkBasedTransformInitializer-&gt;InitializeTransform();<br>
<br>
        typedef itk::ResampleImageFilter&lt;ImageType, ImageType, double&gt;<br>
ResampleFilterType;<br>
        ResampleFilterType::Pointer resampleFilter = ResampleFilterType::New();<br>
</div>        resampleFilter-&gt;SetInput(moving);<br>
        resampleFilter-&gt;SetTransform(transform);<br>
        resampleFilter-&gt;SetSize(fixed-&gt;GetLargestPossibleRegion().GetSize());<br>
        resampleFilter-&gt;SetOutputOrigin(fixed-&gt;GetOrigin());<br>
        resampleFilter-&gt;SetOutputSpacing(fixed-&gt;GetSpacing());<br>
        resampleFilter-&gt;SetOutputDirection(fixed-&gt;GetDirection());<br>
        resampleFilter-&gt;SetDefaultPixelValue(200);<br>
        resampleFilter-&gt;GetOutput();<br>
<br>
        //connect to VTK<br>
        typedef itk::ImageToVTKImageFilter&lt;ImageType&gt; ConnectType;<br>
        ConnectType::Pointer connector = ConnectType::New();<br>
        connector-&gt;SetInput(fixed);<br>
<br>
        vtkImageData *imageData = vtkImageData::New();<br>
        imageData-&gt;DeepCopy(connector-&gt;GetOutput());<br>
<br>
        double a[3];<br>
        imageData-&gt;GetSpacing(a);<br>
        cout&lt;&lt;&quot;spacing: &quot;&lt;&lt;a[0]&amp;lt;&amp;lt;&amp;quot; &amp;quot;&amp;lt;&amp;lt;a[1]&amp;lt;&amp;lt;&amp;quot;<br>
&amp;quot;&amp;lt;&amp;lt;a[2]&amp;lt;&amp;lt;endl;<br>
        cout&amp;lt;&amp;lt;imageData-&gt;GetNumberOfCells()&lt;&lt;endl;<br>
&amp;lt;/h4&gt;<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>