[Insight-users] using ImageToVTKImageFilter for
snrf at no-log.org
Wed Aug 1 10:21:16 EDT 2007
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.
On 1-Aug-07, at 9:16 AM, snrf at no-log.org wrote:
> Hello Luis (and already thanks for the previous tip on
> 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
> (loaded dataset), and then be able to use them in any ITK/VTK
> 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
> 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::Pointer calculator = MinMaxCalculatorType::New
> ( );
> calculator -> SetImage( reader[DataID]->GetOutput() );
> ImageType::PixelType minIntensity = calculator->GetMinimum();
> ImageType::PixelType maxIntensity = calculator->GetMaximum();
> Original_Min_Intensity = minIntensity;
> Original_Max_Intensity = maxIntensity;
> typedef itk::RescaleIntensityImageFilter< ImageType, MIPImageType >
> RescaleFilterType1::Pointer caster1 = RescaleFilterType1::New();
> caster1->SetInput( reader[DataID]->GetOutput() );
> caster1->SetOutputMinimum( 0 );
> caster1->SetOutputMaximum( (int) maxIntensity + abs(minIntensity) );
> ///////////// ITK - VTK Connection //////////////
> connector = ConnectorType::New();
> 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 ..........
> reader[DataLoaded.NbDataLoaded] = ReaderType::New();
> reader[DataLoaded.NbDataLoaded]->SetImageIO( gdcmIO );
> reader[DataLoaded.NbDataLoaded]->SetFileNames( fileNames );
> - here DataLoaded is a global structure that keeps tracks of every
> and output information.
> Finally, my call to the caster is done, for example, in the MIP
> 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->ResetCamera ();
> ren3DMain->ResetCameraClippingRange ();
> Here, FileAction is the object of type FILE that handles, amongst
> 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
> object is created it has an internal function that does set the
> toward the renderers created in the main program, - as follows -
> void SetPrt(vtkRenderer *ren3DMainptr, vtkRenderWindow
> vtkRenderWindowInteractor *iren3DMainptr,
> File *FileActionptr)
> ren3DMain = ren3DMainptr;
> renWin3DMain = renWin3DMainptr;
> iren3DMain = iren3DMainptr;
> FileAction = FileActionptr;
> Thanks for your help.
>>> 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,
>>> 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
>>>> 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.
>>>> Insight-users mailing list
>>>> Insight-users at itk.org
More information about the Insight-users