[Insight-users] help needed please!

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


--0-1612891888-1040224082=:91036
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit


Could anyone tell what's wrong with these lines. I'm stagnating since yesterday and no solution is suggested to my problem. Please it is urgent
 /*** 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. 



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

<P>Could anyone tell what's wrong with these lines. I'm stagnating since yesterday and no solution is suggested to my problem. Please it is urgent
<P>&nbsp;/*** this is for importing pixel values from an unsigned char type pointer&nbsp;&nbsp;&nbsp;**/
<BLOCKQUOTE style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid">
<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></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-1612891888-1040224082=:91036--