[vtkusers] Volume subtraction : vtkImageData connection problem.

Amy Squillacote amy.squillacote at kitware.com
Fri Jul 6 08:20:53 EDT 2007


Hi Gourbish,

For doing image subtraction, try vtkImageMathematics. It allows you to 
do several basic mathematical operations on vtkImageData.

- Amy

Alfredo Gourbish wrote:
> Hi all,
>  
> I have connection problem using vtkImageData.
> First I will present you what I want to do. I work on a projet which 
> constructs a 4-D volume from a MRI sequence. One of my goals is to 
> substract 2 volumes. As I don't find an implemented function to do 
> that in VTK, I try to access to the voxels of a volume. So I find that 
> the vtkImageData class allows to access the data.
> So I just tried to write this line "imageData = 
> imageCast->GetOutput();" in my code and I have this error while 
> executing the program :
> "ERROR: In .\vtkDemandDrivenPipeline.cxx, line 799
> vtkStreamingDemandDrivenPipeline (04FE70A8): Input for connection 
> index 0 on input port index 0 for algorithm 
> vtkVolumeRayCastMapper(04FD14B8) is NULL, but a vtkImageData is required."
>  
>
> Here an abstract of the code :
>  
>  vtkImageData * imageData = vtkImageData::New(); // with or without 
> "New" the problem appears
>  
> ...
>  
>  /// read a vtkVolume file ///
>  structuredPointReader->ReleaseDataFlagOn();
>  structuredPointReader->SetReleaseDataFlag( true );
>  structuredPointReader->SetFileName( fileName );
>  structuredPointReader->Update();
>  
>  imageCast->SetNumberOfThreads( 4 );
>  imageCast->SetInputConnection( structuredPointReader->GetOutputPort() );
>  imageCast->SetOutputScalarTypeToUnsignedChar();
>  
>  imageData = imageCast->GetOutput();
>  /////////////////////////////
>  
> ...
>  
>  /// MIP raycast ///
>  volumeRayCastMapper->SetVolumeRayCastFunction( MIPfunction );
>  volumeRayCastMapper->ReleaseDataFlagOn();
>  
>  volumeRayCastMapper->SetInput( this->imageCast->GetOutput() );
>  //volumeRayCastMapper->SetInput( this->imageData ); // this line is 
> commented in order to find the error when using imageData
>  
>  m_lastVolumeCreated->SetMapper( volumeRayCastMapper );
>  m_lastVolumeCreated->SetProperty( this->volumeProperty );
>  /////////////////////////////
> ...
>  
>  
> So finally I have two questions :
> - Why is there a connection problem in this code ?
> - Is it the goo way to substract 2 volumes ?
>  
>
> Does somebody has any idea ?
>  
>  
> Thank's in advance. ;-)
>  
>
> Gourbish.
> ------------------------------------------------------------------------
>
> _______________________________________________
> This is the private VTK discussion list. 
> Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>   



More information about the vtkusers mailing list