[vtkusers] vtkImageReslice question

Andi2008 mail-andi at web.de
Fri Dec 18 06:29:28 EST 2009


Hi,

thank you for the answer. I use one vtkImageReslice for one single view and
i extract always a single slice. I agree with you that the output extent of
axial/sagittal and coronal views is always the same and I checked my code
for this and found out my program doesnt crashes when I just display the
three orthogonal views. 
But I implemented also the ablility to reslice in any possible direction and
angles. In this case it happens what you descibe. In every time Render is
called the outputextent is recalculated because it is always different. I
implemented the pipeline like:

	m_vtkShiftscale = vtkImageShiftScale::New();
	m_vtkShiftscale->SetInput(volumedata->getImageData()); //<-- vtkImageData
with the volume
	m_vtkShiftscale->SetShift(0.5*m_nWindow - m_nLevel);
	m_vtkShiftscale->SetScale(255.0/m_nWindow);
	m_vtkShiftscale->ClampOverflowOn();
	m_vtkShiftscale->SetOutputScalarTypeToUnsignedChar();

	m_vtkImageReslicer = vtkImageReslice::New();
	m_vtkImageReslicer->SetInput(m_vtkShiftscale->GetOutput());
	m_vtkImageReslicer->SetOutputDimensionality(2);
	m_vtkImageReslicer->SetInterpolationModeToCubic();
	m_vtkImageReslicer->SetOutputSpacing(spacing);
	m_vtkImageReslicer->AutoCropOutputOn();
	m_vtkImageReslicer->Update();

I perform the reslicing by calculating a new transformationmatrix by given
centerpoint and angles around x,y and z axis. I call the SetResliceAxis
method to set the new transformationmatrix the call Update to perform the
reslice. During the update it crashes if there is not enough memory. The
amount of needed memory is not that much(usually around 10mb) but it can
happend that it can't be allocated. I know that the outpuextent is not
exact. Therefore I call the imageshiftscale before the reslice. Otherwise i
get gray areas in the resultimage in cause of the window/level calculation. 

How can I prevent this crash?
Kind regards
Andi 
   
 



David Gobbi-3 wrote:
> 
> Check the WholeExtent of the output from reslice.  By default, the
> size of the OutputExtent is set to be large enough to fully contain
> the transformed input Extent.  Try to imagine a rotated cube inside of
> larger enclosing cube.  The volume of the outer cube can be many times
> larger than that of the inner cube, especially for rotations of 45
> degrees.
> 
> You need to set the OutputExtent of reslice to something reasonable
> for your application.  Don't rely on the default output extent.  If
> you are doing the reslicing so that you can view individual slices,
> then set the output extent to just a single slice.
> 
> I'm not sure whether you are guilty of this, but I've seen several
> people who use ImageReslice to rotate the whole volume, and then use
> VOI or ImageClip or ImageActor to extract slices in the three
> directions (axial, sagittal, coronal).  This is bad design, because
> one of two things will happen: 1) on each render, each view requests a
> different update extent, which forces reslice to re-execute on each
> and every render. 2) if reslice.UpdateWholeExtent() is called, the
> unnecessary re-executions don't occur, but a lot of memory is used.
> The proper way to use reslice is to use one reslice per view
> orientation.
> 
>    David
> 
> 
> On Thu, Dec 17, 2009 at 9:00 AM, Andreas Brüning <mail-andi at web.de> wrote:
>> Hello,
>>
>> ich have a problem when i use vtkImageReslice on a very large volume.
>> Sometimes when i don't have enough memory for the reslice operation the
>> global warningwindow appears. In there is written that vtk is unable to
>> allocate an amount of memory. After this my program crashes immediately
>> and i would like to catch this before it crashes. Is there a way get a
>> notification when there is not enough memory? (maybe a callback function)
>>
>> Thanks in advance
>> Andi
> _______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
> 
> 

-- 
View this message in context: http://old.nabble.com/vtkImageReslice-question-tp26830317p26842156.html
Sent from the VTK - Users mailing list archive at Nabble.com.




More information about the vtkusers mailing list