[Insight-users] Re: Using ImageToVTKImageFilter with SetRequestedRegion

Mathieu Malaterre mathieu.malaterre at gmail.com
Fri Oct 5 08:14:42 EDT 2007


Ok I am tracking the issue down and I am stuck in:

int vtkImageImport::RequestUpdateExtent(
...
{
...
    vtkInformation* outInfo = outputVector->GetInformationObject(0);
    outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_EXTENT(),uExt);
...
  }

What I do not understand is who was in charge of setting the correct
update extent on the output of vtkImageImport (knowing that
itk::VTKImageExport does not even have any output).

thanks for any help,
-Mathieu


On 10/5/07, Mathieu Malaterre <mathieu.malaterre at gmail.com> wrote:
> Hi there,
>
>   I must be missing something trivial here. I am using the
> ImageToVTKImageFilter to convert my ITK data to VTK data (*). Even if
> I explicitely set a specific update/requested extent, the filter seems
> to discard it and decide to recompute everything on the
> whole/largestpossible extent instead.
>
> Any suggestion ?
>
> Thanks,
>
> --
> Mathieu
>
> itk2vtk.cxx:
> #include "itkImage.h"
> #include "itkImageFileReader.h"
> #include "itkCastImageFilter.h"
> #include "itkImageToVTKImageFilter.h"
>
> int main(int argc, char *argv[])
> {
>   if( argc < 2 ) return 1;
>   typedef   unsigned char    InputPixelType;
>   typedef   float            OutputPixelType;
>   typedef itk::Image< InputPixelType,  3 >   InputImageType;
>   typedef itk::Image< OutputPixelType, 3 >   OutputImageType;
>
>   typedef itk::ImageFileReader< InputImageType >  ReaderType;
>
>   typedef itk::CastImageFilter<
>                InputImageType, OutputImageType >  CastFilterType;
>
>   typedef itk::ImageToVTKImageFilter<OutputImageType> ITK2VTKFilter;
>
>
>   ReaderType::Pointer reader = ReaderType::New();
>   reader->SetFileName( argv[1] );
>
>   CastFilterType::Pointer       castFilter       = CastFilterType::New();
>   castFilter->SetInput(       reader->GetOutput() );
>
>   CastFilterType::OutputImageRegionType request;
>   request.SetIndex(0,0);
>   request.SetIndex(1,0);
>   request.SetIndex(2,0);
>   request.SetSize(0,10);
>   request.SetSize(1,10);
>   request.SetSize(2,10);
>   //castFilter->DebugOn();
>   castFilter->GetOutput()->SetRequestedRegion( request );
>   castFilter->Update(); // Keep me
>
>   std::cout << "After Cast Update" << std::endl;
>   //castFilter->GetOutput()->Print( std::cout );
>   castFilter->GetOutput()->GetRequestedRegion().Print( std::cout );
>
>   // Now pass the Output to the itk2vtk filter:
>   ITK2VTKFilter::Pointer itk2vtk = ITK2VTKFilter::New();
>   itk2vtk->SetInput( castFilter->GetOutput() );
>   itk2vtk->Update(); // Keep me
>
>   std::cout << std::endl << std::endl;
>   std::cout << "After itk2vtk Update" << std::endl;
>   castFilter->GetOutput()->GetRequestedRegion().Print( std::cout );
>
>   return 0;
> }
>
>
> CMakeLists.txt:
> FIND_PACKAGE(VTK REQUIRED)
> FIND_PACKAGE(ITK REQUIRED)
>
> INCLUDE(${VTK_USE_FILE})
> INCLUDE(${ITK_USE_FILE})
>
> INCLUDE_DIRECTORIES(
>   # Unfortunately ITK does not export it's source path anymore:
>   /home/mathieu/Projects/Insight/Wrapping/WrapITK/ExternalProjects/ItkVtkGlue/src/
> )
>
> ADD_EXECUTABLE(itk2vtk itk2vtk.cxx)
> TARGET_LINK_LIBRARIES(itk2vtk
>   ITKCommon
>   ITKIO
>   ITKBasicFilters
>   vtkIO
>   vtkImaging
> )
>


More information about the Insight-users mailing list