[Insight-users] using ImageToVTKImageFilter for multiple WindowRenderer

Luis Ibanez luis.ibanez at kitware.com
Sun Aug 5 11:14:54 EDT 2007


Hi Flo,


You may want to take a look at the following paper that
Andinet Enquobahrie posted to the Insight Journal:


"Seamless VTK-ITK pipeline connection for image data handling"
http://www.insight-journal.org/InsightJournalManager/view_reviews.php?back=search.php%3Ftexte%3Dandinet&journalid=7&pubid=146
http://insight-journal.org/dspace/handle/1926/495

As will all papers to the Insight Journal, you will
find attached the source code of the work that is
described in the paper.


    Regards,



        Luis




-------------------------
Flo wrote:
> An update on my case.
> I did succeed to have everything working, I think, the way I want.
> 
> For that, I basically have  a table of structure that stores table of  
> casters with regards to the RendererID.
> Thus, for each of my windowRenderer, I have an associated Casted  Output 
> - This is HEAVY but it works.
> 
> However, and due to the memory thus needed while displaying multiple  3D 
> Rendering at the same time, I wonder if my approach is the good  one or 
> if there is a smarter approach to this problem that would not  allocate 
> to much memory, i.e. keep the actor/volume but free the  associated 
> casting pipeline !
> 
> Thanks for any suggestions.
> Flo.
> 
> 
> On 1-Aug-07, at 9:16 AM, snrf at no-log.org wrote:
> 
>> Hello Luis (and already thanks for the previous tip on  
>> vtkImagePlaneWidget:
>>
>> All my code is in c++/VTK5.0/ITK3.2/Linux fedora 7.
>>
>> What I want to achieve is to create one caster (casted image) per  reader
>> (loaded dataset), and then be able to use them in any ITK/VTK  pipeline.
>> Where my reader is a table of pointer right now, my caster is not  and I
>> feel this is the problem. However, I tried to change my caster  
>> pipeline to
>> have a table of caster but each time I try to display 2 casted input
>> images in two different renderers I have a crash.
>>
>> Originally, I used VTK a lot and I think I have a lack of  
>> understanding of
>> ITK's pipeline with regards to memory allocation and pointers  specially.
>>
>> Getting to my code:
>>
>> My function that actually casts the ITK inputs is as follows -
>> void File::CastMIP(int DataID)
>> {
>>
>>     //create cast filter to cast inputImage into output image data
>>     typedef itk::MinimumMaximumImageCalculator< ImageType >
>> MinMaxCalculatorType;
>> MinMaxCalculatorType::Pointer calculator = MinMaxCalculatorType::New ( );
>>     calculator -> SetImage( reader[DataID]->GetOutput() );
>>     calculator->ComputeMaximum();
>>     calculator->ComputeMinimm();
>>     ImageType::PixelType minIntensity = calculator->GetMinimum();
>>     ImageType::PixelType maxIntensity = calculator->GetMaximum();
>>
>>     Original_Min_Intensity = minIntensity;
>>     Original_Max_Intensity = maxIntensity;
>>     typedef itk::RescaleIntensityImageFilter< ImageType, MIPImageType >
>> RescaleFilterType1;
>>     RescaleFilterType1::Pointer caster1 = RescaleFilterType1::New();
>>     caster1->SetInput( reader[DataID]->GetOutput() );
>>     caster1->SetOutputMinimum(   0 );
>>     caster1->SetOutputMaximum( (int) maxIntensity + abs(minIntensity) );
>>     caster1->Update();
>>     //caster1->SetReleaseDataBeforeUpdateFlag(TRUE);
>>     ///////////// ITK - VTK Connection //////////////
>>     connector = ConnectorType::New();
>>     connector->SetInput(caster1->GetOutput());
>>     connector->Update();
>> }
>>
>> Here reader refers to a function that just read (who'd guess) data  - 
>> each
>> new set of data being loaded in a table of reader indexed by  DataID, and
>> as follows -
>>
>> void File::Load3D(QWidget* Window)
>> {
>>
>>     /*            ITK pipeline to load images            */
>>
>>
>>     typedef itk::GDCMSeriesFileNames                NamesGeneratorType;
>>     typedef std::vector< std::string > SeriesIdContainer;
>>     typedef std::vector< unsigned int> NumSeriesFilesContainer;
>>     typedef std::vector< std::string > FileNamesContainer;
>> .............. usual ITK code to read dicom files ..........
>> try
>>     {
>>
>>     reader[DataLoaded.NbDataLoaded] = ReaderType::New();
>>     reader[DataLoaded.NbDataLoaded]->SetImageIO( gdcmIO );
>>     reader[DataLoaded.NbDataLoaded]->SetFileNames( fileNames );
>>     reader[DataLoaded.NbDataLoaded]->Update();
>>
>>     }
>> }
>>
>> - here DataLoaded is a global structure that keeps tracks of every  input
>> and output information.
>>
>> Finally, my call to the caster is done, for example, in the MIP  
>> rendering
>> function as follows -
>>  void ThreeDRendering::DisplayMIP(int TabID)
>>  {
>>
>> ........... usual VTK code here .........
>> volumeMapper->SetInput( FileAction->connector->GetImporter()- 
>> >GetOutput()  );
>>        volume->SetMapper( volumeMapper );
>>        volume->SetProperty( mipProperty );
>>         ren3DMain->AddVolume(volume);
>>        ren3DMain->ResetCamera ();
>>        ren3DMain->ResetCameraClippingRange ();
>>        renWin3DMain->Render();
>> }
>>
>> Here, FileAction is the object of type FILE that handles, amongst  
>> others,
>> the reader and caster., The renderers are not directly set within this
>> context, but set in the core program (the main one) and each time a  new
>> object is created it has an internal function that does set the  pointers
>> toward the renderers created in the main program, - as follows -
>>
>> void SetPrt(vtkRenderer *ren3DMainptr, vtkRenderWindow  *renWin3DMainptr,
>> vtkRenderWindowInteractor *iren3DMainptr,
>>     File    *FileActionptr)
>>     {
>>         ren3DMain = ren3DMainptr;
>>         renWin3DMain = renWin3DMainptr;
>>         iren3DMain = iren3DMainptr;
>>         FileAction = FileActionptr;
>>     };
>>
>>
>> Thanks for your help.
>> Flo.
>>
>>>>
>>>> Hi Flo,
>>>>
>>>> Please post the the list the following:
>>>>
>>>> 1) The declaration of your void function
>>>> 2) The lines where you call the function
>>>> 3) The declaration of your ITK image and vtkImageData
>>>>    outside of the function.
>>>>
>>>> BTW: Are you programing in C++ ?
>>>>
>>>> Are you instantiating the RenderWindow outside of the void  function ?
>>>> or inside ?
>>>>
>>>>
>>>>   Please let us know,
>>>>
>>>>
>>>>      Thanks
>>>>
>>>>
>>>>        Luis
>>>>
>>>>
>>>> ---------------
>>>> Flo wrote:
>>>>
>>>>> Dear all:
>>>>> I'm using a void function containing ImageToVTKImageFilter in
>>>>> conjunction with a Caster to pass images from ITK to VTK.
>>>>> Everything works fine in the case where I use a single
>>>>> WindowRender/ Renderer.
>>>>> However, If I have 2 or more WindowRenders, and if each has a
>>>>> different call to my function (with different input images) then
>>>>> I  have a segmentation fault.
>>>>> To my understanding, this is a memory access violation due to the
>>>>> "pointer" strategy of ITK while creating the Casting/Exporting
>>>>> pipeline.
>>>>> Thus, I tried different update(), updatewholeextent() calls but
>>>>> in  vain (I thought it would have force the ITK pipeline to create
>>>>> a new  pointer - now I understand why this was a bad guess !!!).
>>>>> So here is my question, is creating such a function but returning
>>>>> a  pointer to the casted data the best way to do things ? But
>>>>> then, how  to make sure I really have a new pointer towards my new
>>>>> casted data ?  I tried to declare a table of connector
>>>>> (ImageToVTKImageFilter  connectors) but it failed as well !
>>>>> any suggestions would be of great help.
>>>>> Flo.
>>>>> _______________________________________________
>>>>> 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