[Insight-users] TileFilterType

Alberto albermnz at gmail.com
Tue Jun 17 12:45:55 EDT 2008


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20080617/fd5c4b4a/attachment.htm>


More information about the Insight-users mailing list