Thanks a ot BIll, although I just tried what you said and it still doesn't work. The output is exactly the same.<br>Has anybody another suggestion?<br><br>Regards<br>Bert<br><br><div class="gmail_quote">On Tue, Jun 17, 2008 at 7:43 PM, Bill Lorensen <<a href="mailto:bill.lorensen@gmail.com">bill.lorensen@gmail.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Bert,<br>
<br>
Move the<br>
<div class="Ih2E3d">ExtractFilterType::Pointer extractFilter = ExtractFilterType::New ();<br>
</div>inside the for loop. Currently you are reusing the output of the same<br>
instance. By moving the New inside the loop, you will get a new<br>
extract filter for each iteration. The magic of smart pointers should<br>
delete memory when it should.<br>
<br>
Bill<br>
<div><div></div><div class="Wj3C7c"><br>
On Tue, Jun 17, 2008 at 12:45 PM, Alberto <<a href="mailto:albermnz@gmail.com">albermnz@gmail.com</a>> wrote:<br>
> Dear all,<br>
> I am trying to test that I know how to use the tileFIlter. What I am doing<br>
> is to extract 5 2D slices and then, withot any processing, recover the 3D<br>
> image. The problem is that all slices are OK, except the first one which is<br>
> equal to the las one. I cannot see the mistake, could yo help me?<br>
><br>
><br>
><br>
><br>
> typedef unsigned char InputPixelType;<br>
> typedef unsigned char MiddlePixelType;<br>
> typedef unsigned char OutputPixelType;<br>
><br>
> typedef itk::Image< InputPixelType, 3 > InputImageType;<br>
> typedef itk::Image< MiddlePixelType, 2 > MiddleImageType;<br>
> typedef itk::Image< OutputPixelType, 3 > OutputImageType;<br>
><br>
> typedef itk::ImageFileReader< InputImageType > ReaderType;<br>
> typedef itk::ImageFileWriter< OutputImageType > WriterType;<br>
><br>
> typedef itk::ExtractImageFilter< InputImageType, MiddleImageType ><br>
> ExtractFilterType;<br>
> typedef itk::TileImageFilter<MiddleImageType, OutputImageType ><br>
> TileFilterType;<br>
><br>
> const char * inputFilename = argv[1];<br>
> const char * outputFilename = argv[2];<br>
><br>
> ReaderType::Pointer reader = ReaderType::New();<br>
> WriterType::Pointer writer = WriterType::New();<br>
> reader->SetFileName( inputFilename );<br>
> writer->SetFileName( outputFilename );<br>
><br>
> reader->Update();<br>
><br>
> InputImageType::RegionType inputRegion =<br>
> reader->GetOutput()->GetLargestPossibleRegion();<br>
> ExtractFilterType::Pointer extractFilter = ExtractFilterType::New ();<br>
><br>
> InputImageType::SizeType size = inputRegion.GetSize();<br>
> size[2] = 0;<br>
><br>
> InputImageType::IndexType start = inputRegion.GetIndex();<br>
> InputImageType::RegionType desiredRegion;<br>
><br>
> TileFilterType::Pointer tileFilter = TileFilterType::New();<br>
><br>
> for (int sliceNumber=0; sliceNumber<5; sliceNumber++)<br>
> {<br>
> start[2] = sliceNumber;<br>
><br>
> desiredRegion.SetSize( size );<br>
> desiredRegion.SetIndex( start );<br>
><br>
> extractFilter->SetExtractionRegion( desiredRegion );<br>
> extractFilter->SetInput( reader->GetOutput() );<br>
> extractFilter->Update();<br>
><br>
> TileFilterType::LayoutArrayType layout;<br>
> layout[0] = 1;<br>
> layout[1] = 1;<br>
> layout[2] = 0;<br>
> tileFilter->SetLayout( layout );<br>
><br>
> // Set up pipeline<br>
> tileFilter->SetInput( extractFilter->GetOutput() );<br>
><br>
> // Vector of pointers to the many 2D extracted images<br>
> std::vector< MiddleImageType::Pointer > extracts;<br>
> desiredRegion.SetIndex( start );<br>
><br>
> extracts.push_back( extractFilter->GetOutput() );<br>
><br>
> if (sliceNumber != 0)<br>
> {<br>
> tileFilter->PushBackInput( extracts.back() );<br>
> }<br>
> extracts.back()->DisconnectPipeline();<br>
> }<br>
> tileFilter->Update();<br>
><br>
><br>
> Thanks a lot<br>
> Best regards<br>
> Bert<br>
><br>
><br>
</div></div>> _______________________________________________<br>
> Insight-users mailing list<br>
> <a href="mailto:Insight-users@itk.org">Insight-users@itk.org</a><br>
> <a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
><br>
><br>
</blockquote></div><br>