Dear all,<br>I am trying to test that I know how to use the tileFIlter. What I am doing is to extract 5 2D slices and then, withot any processing, recover the 3D image. The problem is that all slices are OK, except the first one which is equal to the las one. I cannot see the mistake, could yo help me?<br>
<br><br><br><br>typedef unsigned char&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; InputPixelType;<br>&nbsp;&nbsp;&nbsp; typedef unsigned char&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MiddlePixelType;<br>&nbsp;&nbsp;&nbsp; typedef unsigned char&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OutputPixelType;<br><br>&nbsp;&nbsp;&nbsp; typedef itk::Image&lt; InputPixelType,&nbsp; 3 &gt;&nbsp;&nbsp;&nbsp; InputImageType;<br>
&nbsp;&nbsp;&nbsp; typedef itk::Image&lt; MiddlePixelType, 2 &gt;&nbsp;&nbsp;&nbsp; MiddleImageType;<br>&nbsp;&nbsp;&nbsp; typedef itk::Image&lt; OutputPixelType, 3 &gt;&nbsp;&nbsp;&nbsp; OutputImageType;<br><br>&nbsp;&nbsp;&nbsp; typedef itk::ImageFileReader&lt; InputImageType&nbsp; &gt;&nbsp; ReaderType;<br>
&nbsp;&nbsp;&nbsp; typedef itk::ImageFileWriter&lt; OutputImageType&nbsp; &gt;&nbsp; WriterType;<br><br>&nbsp;&nbsp;&nbsp; typedef itk::ExtractImageFilter&lt; InputImageType, MiddleImageType&nbsp; &gt;&nbsp; ExtractFilterType;<br>&nbsp;&nbsp;&nbsp; typedef itk::TileImageFilter&lt;MiddleImageType, OutputImageType &gt;&nbsp; TileFilterType;<br>
<br>&nbsp;&nbsp;&nbsp; const char * inputFilename&nbsp; = argv[1];<br>&nbsp;&nbsp;&nbsp; const char * outputFilename = argv[2];<br><br>&nbsp;&nbsp;&nbsp; ReaderType::Pointer reader = ReaderType::New();<br>&nbsp;&nbsp;&nbsp; WriterType::Pointer writer = WriterType::New();<br>&nbsp;&nbsp;&nbsp; reader-&gt;SetFileName( inputFilename&nbsp; );<br>
&nbsp;&nbsp;&nbsp; writer-&gt;SetFileName( outputFilename );<br><br>&nbsp;&nbsp;&nbsp; reader-&gt;Update();<br><br>&nbsp;&nbsp;&nbsp; InputImageType::RegionType inputRegion = reader-&gt;GetOutput()-&gt;GetLargestPossibleRegion();<br>&nbsp;&nbsp;&nbsp; ExtractFilterType::Pointer extractFilter = ExtractFilterType::New ();<br>
<br>&nbsp;&nbsp;&nbsp; InputImageType::SizeType size = inputRegion.GetSize();<br>&nbsp;&nbsp;&nbsp; size[2] = 0;<br><br>&nbsp;&nbsp;&nbsp; InputImageType::IndexType start = inputRegion.GetIndex();<br>&nbsp;&nbsp;&nbsp; InputImageType::RegionType desiredRegion;<br><br>&nbsp;&nbsp;&nbsp; TileFilterType::Pointer tileFilter = TileFilterType::New();<br>
<br>&nbsp;&nbsp;&nbsp; for (int sliceNumber=0; sliceNumber&lt;5; sliceNumber++)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; start[2] = sliceNumber;<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; desiredRegion.SetSize(&nbsp; size&nbsp; );<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; desiredRegion.SetIndex( start );<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; extractFilter-&gt;SetExtractionRegion( desiredRegion );<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; extractFilter-&gt;SetInput( reader-&gt;GetOutput() );<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; extractFilter-&gt;Update();<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; TileFilterType::LayoutArrayType layout;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; layout[0] = 1;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; layout[1] = 1;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; layout[2] = 0;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; tileFilter-&gt;SetLayout( layout );<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //&nbsp; Set up pipeline<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; tileFilter-&gt;SetInput( extractFilter-&gt;GetOutput() );<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //&nbsp; Vector of pointers to the many 2D extracted images<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; std::vector&lt; MiddleImageType::Pointer &gt; extracts;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; desiredRegion.SetIndex( start );<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; extracts.push_back( extractFilter-&gt;GetOutput() );<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (sliceNumber != 0)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; tileFilter-&gt;PushBackInput( extracts.back() );<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; extracts.back()-&gt;DisconnectPipeline();<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; tileFilter-&gt;Update();<br><br><br>Thanks a lot<br>Best regards<br>Bert<br><br>