[Insight-users] dynamic_cast

lydia coin lydia_coin3d@yahoo.fr
Wed, 18 Dec 2002 14:42:16 +0100 (CET)


--0-1668902072-1040218936=:63349
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit


/*** this is for importing pixel values from an unsigned char type pointer   **/

itk::ImportImageContainer<long unsigned int, unsigned char>::Pointer import;
   import = itk::ImportImageContainer<long unsigned int,   unsigned char>::New();
   import->Initialize();
   import->Reserve(size[0]*size[1]);
   import->SetImportPointer(labeled_image2,size[0]*size[1],false);

/****setting the pixel values in the itkimage****/ 
typedef itk::Image<unsigned char, 2> ImageType;
   ImageType:: Pointer img = ImageType::New();
   double values[]={2,2};
   double origin_x= 0;
   double origin_y=0;
   double origin[] = {origin_x, origin_y};
   ImageType::IndexType  index;
    img->SetOrigin(origin);
   img->SetSpacing(values); // here I have already a problem at RebuildTransform() method
   ImageType::SizeType         imagesize;
   imagesize[0] = 256;
   imagesize[1] = 256;
   
   ImageType::RegionType region;
   region.SetSize( imagesize );
   
   img->SetLargestPossibleRegion( region );
   img->SetBufferedRegion( region );
   img->SetRequestedRegion(region);
   img->Allocate();
    img->SetPixelContainer(import);
   img->Update();
/******** connectedThresholdImageFilter***********/
typedef itk::ConnectedThresholdImageFilter<ImageType,ImageType> FilterType;
 FilterType::Pointer filter = FilterType::New();
    filter->SetInput(img);
    FilterType::IndexType seed; seed[0] = 165; seed[1] = 90;
    filter->SetSeed(seed);
    filter->SetLower(0);
    filter->SetUpper(255);
    filter->SetReplaceValue(255);
 filter-> Update();// here iot doesn't work because of the dynamic-cast of copyInformation method.
thanks for your help 
 "Lorensen, William E (Research)" <lorensen@crd.ge.com> wrote:lydia,What is your ImageType? Could you report your typedef? Bill-----Original Message-----
From: lydia coin [mailto:lydia_coin3d@yahoo.fr]
Sent: Wednesday, December 18, 2002 6:27 AM
To: insight-users@public.kitware.com
Subject: [Insight-users] dynamic_cast


Hi folks

I'm a newbie at itk, I'm having many problems in using the filters, I already posted a message about setspacing and setorigin methods of an itkimage class. It doesn't work because it says that the transfroms associated to this image are not affine knowing that I associated no transform, it was created by the class itself during the instanciation.

Second, I'm using a connectedthresholdImageFilter , it takes as input an image of unsigned char type of pixels, but doesn't give any output. While using update() method of the filter it stops with an error at this point of the itkImagebase.txx

ImageBase<VImageDimension>
::CopyInformation(const DataObject *data)
{

imgData = dynamic_cast<const ImageBase<VImageDimension>*>(data);

}

and doesn't cast back the pointer.  

I really need to know what I'm doing wrong and hope I will get some help

regards    

 

typedef itk::ConnectedThresholdImageFilter<ImageType,ImageType> FilterType;

 FilterType::Pointer filter = FilterType::New();
    filter->SetInput(img);
    FilterType::IndexType seed; seed[0] = 165; seed[1] = 90;
    filter->SetSeed(seed);
    filter->SetLower(0);
    filter->SetUpper(255);
    filter->SetReplaceValue(255);
   filter-> Update();



---------------------------------
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
Testez le nouveau Yahoo! Mail


---------------------------------
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
Testez le nouveau Yahoo! Mail
--0-1668902072-1040218936=:63349
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

<P>/*** this is for importing pixel values from an unsigned char type pointer&nbsp;&nbsp;&nbsp;**/</P>
<P>itk::ImportImageContainer&lt;long unsigned int, unsigned char&gt;::Pointer import;<BR>&nbsp;&nbsp;&nbsp;import = itk::ImportImageContainer&lt;long unsigned int,&nbsp;&nbsp;&nbsp;unsigned char&gt;::New();<BR>&nbsp;&nbsp;&nbsp;import-&gt;Initialize();<BR>&nbsp;&nbsp;&nbsp;import-&gt;Reserve(size[0]*size[1]);<BR>&nbsp;&nbsp;&nbsp;import-&gt;SetImportPointer(labeled_image2,size[0]*size[1],false);</P>
<P>/****setting the pixel values in the itkimage****/&nbsp;
<P>typedef itk::Image&lt;unsigned char, 2&gt; ImageType;<BR>&nbsp;&nbsp;&nbsp;ImageType::&nbsp;Pointer img = ImageType::New();
<P>&nbsp;&nbsp;&nbsp;double values[]={2,2};<BR>&nbsp;&nbsp;&nbsp;double origin_x= 0;<BR>&nbsp;&nbsp;&nbsp;double origin_y=0;<BR>&nbsp;&nbsp;&nbsp;double origin[] = {origin_x, origin_y};<BR>&nbsp;&nbsp;&nbsp;ImageType::IndexType&nbsp; index;<BR>&nbsp;&nbsp;&nbsp;&nbsp;img-&gt;SetOrigin(origin);<BR>&nbsp;&nbsp;&nbsp;img-&gt;SetSpacing(values); // here I have already a problem at RebuildTransform() method
<P>&nbsp;&nbsp;&nbsp;ImageType::SizeType&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; imagesize;<BR>&nbsp;&nbsp;&nbsp;imagesize[0] = 256;<BR>&nbsp;&nbsp;&nbsp;imagesize[1] = 256;<BR>&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;ImageType::RegionType region;<BR>&nbsp;&nbsp;&nbsp;region.SetSize( imagesize );<BR>&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;img-&gt;SetLargestPossibleRegion( region );<BR>&nbsp;&nbsp;&nbsp;img-&gt;SetBufferedRegion( region );<BR>&nbsp;&nbsp;&nbsp;img-&gt;SetRequestedRegion(region);<BR>&nbsp;&nbsp;&nbsp;img-&gt;Allocate();<BR>&nbsp;&nbsp;&nbsp;&nbsp;img-&gt;SetPixelContainer(import);<BR>&nbsp;&nbsp;&nbsp;img-&gt;Update();
<P>/******** connectedThresholdImageFilter***********/
<P>typedef itk::ConnectedThresholdImageFilter&lt;ImageType,ImageType&gt; FilterType;
<P>&nbsp;FilterType::Pointer filter = FilterType::New();<BR>&nbsp;&nbsp;&nbsp; filter-&gt;SetInput(img);<BR>&nbsp;&nbsp;&nbsp; FilterType::IndexType seed; seed[0] = 165; seed[1] = 90;<BR>&nbsp;&nbsp;&nbsp; filter-&gt;SetSeed(seed);<BR>&nbsp;&nbsp;&nbsp; filter-&gt;SetLower(0);<BR>&nbsp;&nbsp;&nbsp; filter-&gt;SetUpper(255);<BR>&nbsp;&nbsp;&nbsp; filter-&gt;SetReplaceValue(255);<BR>&nbsp;filter-&gt; Update();// here iot doesn't work because of the dynamic-cast of copyInformation method.
<P>thanks for your help 
<P>&nbsp;<B><I>"Lorensen, William E (Research)" &lt;lorensen@crd.ge.com&gt;</I></B> wrote:
<BLOCKQUOTE style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid">
<META content="MSHTML 5.50.4919.2200" name=GENERATOR>
<DIV><SPAN class=656485912-18122002><FONT face=Arial color=#0000ff size=2>lydia,</FONT></SPAN></DIV>
<DIV><SPAN class=656485912-18122002><FONT face=Arial color=#0000ff size=2>What is your ImageType? Could you report your typedef?</FONT></SPAN></DIV>
<DIV><SPAN class=656485912-18122002><FONT face=Arial color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=656485912-18122002><FONT face=Arial color=#0000ff size=2>Bill</FONT></SPAN></DIV>
<BLOCKQUOTE>
<DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma size=2>-----Original Message-----<BR><B>From:</B> lydia coin [mailto:lydia_coin3d@yahoo.fr]<BR><B>Sent:</B> Wednesday, December 18, 2002 6:27 AM<BR><B>To:</B> insight-users@public.kitware.com<BR><B>Subject:</B> [Insight-users] dynamic_cast<BR><BR></FONT></DIV>
<P>Hi folks</P>
<P>I'm a newbie at itk, I'm having many problems in using the filters, I already posted a message about setspacing and setorigin methods of an itkimage class. It doesn't work because it says that the transfroms associated to this image are not affine knowing that I associated no transform, it was created by the class itself during the instanciation.</P>
<P>Second, I'm using a connectedthresholdImageFilter , it takes as input an image of unsigned char type of pixels, but doesn't give any output. While using update() method of the filter it stops with an error at this point of the itkImagebase.txx</P>
<P>ImageBase&lt;VImageDimension&gt;<BR>::CopyInformation(const DataObject *data)<BR>{</P>
<P>imgData = dynamic_cast&lt;const ImageBase&lt;VImageDimension&gt;*&gt;(data);</P>
<P>}</P>
<P>and&nbsp;doesn't cast back the pointer.&nbsp;&nbsp;</P>
<P>I really need to know&nbsp;what I'm doing wrong&nbsp;and hope I will get some help</P>
<P>regards&nbsp;&nbsp;&nbsp;&nbsp;</P>
<P>&nbsp;</P>
<P>typedef itk::ConnectedThresholdImageFilter&lt;ImageType,ImageType&gt; FilterType;</P>
<P>&nbsp;FilterType::Pointer filter = FilterType::New();<BR>&nbsp;&nbsp;&nbsp; filter-&gt;SetInput(img);<BR>&nbsp;&nbsp;&nbsp; FilterType::IndexType seed; seed[0] = 165; seed[1] = 90;<BR>&nbsp;&nbsp;&nbsp; filter-&gt;SetSeed(seed);<BR>&nbsp;&nbsp;&nbsp; filter-&gt;SetLower(0);<BR>&nbsp;&nbsp;&nbsp; filter-&gt;SetUpper(255);<BR>&nbsp;&nbsp;&nbsp; filter-&gt;SetReplaceValue(255);<BR>&nbsp;&nbsp; filter-&gt; Update();</P>
<P><BR>
<HR SIZE=1>
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !<BR><A href="http://fr.mail.yahoo.com/">Testez le nouveau Yahoo! Mail</A></BLOCKQUOTE></BLOCKQUOTE><p><br><hr size=1>Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !<br>
<a href=http://fr.mail.yahoo.com>Testez le nouveau Yahoo! Mail</a>
--0-1668902072-1040218936=:63349--