[Insight-users] TileFilterType
Bill Lorensen
bill.lorensen at gmail.com
Tue Jun 17 13:43:42 EDT 2008
Bert,
Move the
ExtractFilterType::Pointer extractFilter = ExtractFilterType::New ();
inside the for loop. Currently you are reusing the output of the same
instance. By moving the New inside the loop, you will get a new
extract filter for each iteration. The magic of smart pointers should
delete memory when it should.
Bill
On Tue, Jun 17, 2008 at 12:45 PM, Alberto <albermnz at gmail.com> wrote:
> Dear all,
> 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?
>
>
>
>
> typedef unsigned char InputPixelType;
> typedef unsigned char MiddlePixelType;
> typedef unsigned char OutputPixelType;
>
> typedef itk::Image< InputPixelType, 3 > InputImageType;
> typedef itk::Image< MiddlePixelType, 2 > MiddleImageType;
> typedef itk::Image< OutputPixelType, 3 > OutputImageType;
>
> typedef itk::ImageFileReader< InputImageType > ReaderType;
> typedef itk::ImageFileWriter< OutputImageType > WriterType;
>
> typedef itk::ExtractImageFilter< InputImageType, MiddleImageType >
> ExtractFilterType;
> typedef itk::TileImageFilter<MiddleImageType, OutputImageType >
> TileFilterType;
>
> const char * inputFilename = argv[1];
> const char * outputFilename = argv[2];
>
> ReaderType::Pointer reader = ReaderType::New();
> WriterType::Pointer writer = WriterType::New();
> reader->SetFileName( inputFilename );
> writer->SetFileName( outputFilename );
>
> reader->Update();
>
> InputImageType::RegionType inputRegion =
> reader->GetOutput()->GetLargestPossibleRegion();
> ExtractFilterType::Pointer extractFilter = ExtractFilterType::New ();
>
> InputImageType::SizeType size = inputRegion.GetSize();
> size[2] = 0;
>
> InputImageType::IndexType start = inputRegion.GetIndex();
> InputImageType::RegionType desiredRegion;
>
> TileFilterType::Pointer tileFilter = TileFilterType::New();
>
> for (int sliceNumber=0; sliceNumber<5; sliceNumber++)
> {
> start[2] = sliceNumber;
>
> desiredRegion.SetSize( size );
> desiredRegion.SetIndex( start );
>
> extractFilter->SetExtractionRegion( desiredRegion );
> extractFilter->SetInput( reader->GetOutput() );
> extractFilter->Update();
>
> TileFilterType::LayoutArrayType layout;
> layout[0] = 1;
> layout[1] = 1;
> layout[2] = 0;
> tileFilter->SetLayout( layout );
>
> // Set up pipeline
> tileFilter->SetInput( extractFilter->GetOutput() );
>
> // Vector of pointers to the many 2D extracted images
> std::vector< MiddleImageType::Pointer > extracts;
> desiredRegion.SetIndex( start );
>
> extracts.push_back( extractFilter->GetOutput() );
>
> if (sliceNumber != 0)
> {
> tileFilter->PushBackInput( extracts.back() );
> }
> extracts.back()->DisconnectPipeline();
> }
> tileFilter->Update();
>
>
> Thanks a lot
> Best regards
> Bert
>
>
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
>
>
More information about the Insight-users
mailing list