[Insight-users] Converting itk::Image<float, 2> to itk::Image<VectorPixelType, 2>

Carlos Cardenas caedcasa at hotmail.com
Thu, 11 Mar 2004 16:01:52 +0000


<html><div style='background-color:'><DIV class=RTE>
<P>Hi James,<BR>&nbsp;&nbsp;&nbsp; Thank you for your help. Actually I want to use vector images because I want to apply some other filters like VectorGradientMagnitudeImageFilter. The part of source code you sent with your suggestion is the way I am trying to convert the image (see below), but the program crashes when it comes to convert the image. <BR>&gt; <BR>&gt;&nbsp; typedef itk::Image&lt;float, 2&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ImageTypeFloat2D;<BR>&gt;&nbsp; typedef itk::Vector&lt;float, 3&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; VectorPixelType;<BR>&gt;&nbsp; typedef itk::Image&lt;VectorPixelType, 2&gt;&nbsp; VectorImageType;<BR>&gt;&nbsp; typedef itk::ScalarToArrayCastImageFilter&lt;ImageTypeFloat2D, VectorImageType&gt; CastFilterTypeToVector;<BR>&gt;&nbsp; CastFilterTypeToVector::Pointer casterToVector = CastFilterTypeToVector::New();<BR>&gt;&nbsp; casterToVector-&gt;SetInput(imageFloat2D);<BR>&gt;&nbsp; casterToVector-&gt;Update();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // my program says good bye at this point!!!!!<BR><BR>Do you see anything different? Is it because the input image is &lt;float, 2&gt;?</P>
<P>Thank you again for your help,</P>
<P>Best regards,</P>
<P>Carlos</P>
<P><BR><BR>&nbsp;</P></DIV>
<DIV></DIV>&gt;From: "Miller, James V (Research)" <MILLERJV at CRD.GE.COM>
<DIV></DIV>&gt;To: "'Carlos Cardenas'" <CAEDCASA at HOTMAIL.COM>, insight-users at itk.org 
<DIV></DIV>&gt;Subject: RE: [Insight-users] Converting itk::Image<FLOAT, 2> to itk::Image<VECTORPIXELTYPE, 2> 
<DIV></DIV>&gt;Date: Thu, 11 Mar 2004 10:39:33 -0500 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;Carlos, 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;Can simply use the GradientAnisotropicDiffusionImageFilter on your original 
<DIV></DIV>&gt;scalar image? 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;I am not sure whether the VectorGradientAnisotropicDiffusionImageFilter will 
<DIV></DIV>&gt;like processing a vector image where the vector length is one. 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;If you still need to convert a scalar image to a vector, this is how I have 
<DIV></DIV>&gt;done it in the past 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;&nbsp;&nbsp; typedef itk::ScalarToArrayCastImageFilter<INPUTIMAGETYPE,VECTORIMAGETYPE> 
<DIV></DIV>&gt;ScalarToVectorFilterType; 
<DIV></DIV>&gt;&nbsp;&nbsp; ScalarToVectorFilterType::Pointer scalarToVector = 
<DIV></DIV>&gt;ScalarToVectorFilterType::New(); 
<DIV></DIV>&gt;&nbsp;&nbsp; scalarToVector-&gt;SetInput( reader-&gt;GetOutput() ); 
<DIV></DIV>&gt;&nbsp;&nbsp; scalarToVector-&gt;Update(); 
<DIV></DIV>&gt; 
<DIV></DIV>&gt; 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;-----Original Message----- 
<DIV></DIV>&gt;From: Carlos Cardenas [mailto:caedcasa at hotmail.com] 
<DIV></DIV>&gt;Sent: Wednesday, March 10, 2004 11:42 PM 
<DIV></DIV>&gt;To: insight-users at itk.org 
<DIV></DIV>&gt;Subject: [Insight-users] Converting itk::Image<FLOAT, 2> to 
<DIV></DIV>&gt;itk::Image<VECTORPIXELTYPE, 2> 
<DIV></DIV>&gt; 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;Hi everyone, 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;&nbsp;&nbsp;&nbsp;&nbsp; I was trying to find a solution for my problem looking into the old 
<DIV></DIV>&gt;emails sendet to the mailinglist but I did not find a solution. I am trying 
<DIV></DIV>&gt;to convert an itk::Image<FLOAT, 2> into a vector image. 
<DIV></DIV>&gt;I used the class ScalarToArrayCastImageFilter without success. I can compile 
<DIV></DIV>&gt;my program and also link it without problem. My program crashes when it 
<DIV></DIV>&gt;comes to the part where the image has to be converted.&nbsp;&nbsp;Could anybody tell 
<DIV></DIV>&gt;me what I am doing wrong and how I can convert my image into a vector image 
<DIV></DIV>&gt;so that I can use the VectorGradientAnisotropicDiffusionImageFilter. 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;&nbsp;&nbsp;&nbsp;&nbsp; Part of the source code below: 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;&nbsp;&nbsp;typedef itk::Image<FLOAT, 2>ImageTypeFloat2D; 
<DIV></DIV>&gt;&nbsp;&nbsp;typedef itk::Vector<FLOAT, 3> VectorPixelType; 
<DIV></DIV>&gt;&nbsp;&nbsp;typedef itk::Image<VECTORPIXELTYPE, 2> VectorImageType; 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;&nbsp;&nbsp;typedef itk::ScalarToArrayCastImageFilter<IMAGETYPEFLOAT2D, DIV <>&gt;VectorImageType&gt;&nbsp;&nbsp;CastFilterTypeToVector; 
<DIV></DIV>&gt;&nbsp;&nbsp; CastFilterTypeToVector::Pointer casterToVector = 
<DIV></DIV>&gt;CastFilterTypeToVector::New(); 
<DIV></DIV>&gt;&nbsp;&nbsp; casterToVector-&gt;SetInput(filterSlice-&gt;GetOutput()); 
<DIV></DIV>&gt;&nbsp;&nbsp; casterToVector-&gt;Update(); // my program says good bye at this point 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;&nbsp;&nbsp; typedef 
<DIV></DIV>&gt;itk::VectorGradientAnisotropicDiffusionImageFilter<VECTORIMAGETYPE, DIV <>&gt;VectorImageType&gt; FilterType; 
<DIV></DIV>&gt;&nbsp;&nbsp;&nbsp;&nbsp;FilterType::Pointer filter = FilterType::New(); 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;Thank you in advance for any help, 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;Carlos 
<DIV></DIV>&gt; 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;&nbsp;&nbsp; _____ 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;Lieblingssong auf's Handy laden oder Display aufpeppen - bei MSN gibt's 
<DIV></DIV>&gt;jetzt auch polyphone Klingeltöne &amp; farbige Logos! Hier klicken 
<DIV></DIV>&gt;<HTTP: 2740??PS="" 8HMBDEDE g.msn.com> 
<DIV></DIV>&gt;_______________________________________________ Insight-users mailing list 
<DIV></DIV>&gt;Insight-users at itk.org http://www.itk.org/mailman/listinfo/insight-users 
<DIV></DIV>&gt; 
<DIV></DIV></div><br clear=all><hr>Lieblingssong auf’s Handy laden oder Display aufpeppen – bei MSN gibt’s jetzt auch polyphone Klingeltöne & farbige Logos! <a href="http://g.msn.com/8HMBDEDE/2740??PS=">Hier klicken</a> </html>