[Insight-users] Problems updating when reading new images
Iván Macía
imacia at vicomtech . es
Thu, 18 Sep 2003 14:23:32 +0200
Dear all,
I'm using VTK together with ITK in a MFC dialog-based app. I read an
image stack with a single vtkJPEGReader, pass it through several VTK and ITK
filters and show the results in the screen using an vtkImageActor. To
connect both pipelines i'm using the functions ConnectPipelines() in
VTK2ITK2VTK.h. So my pipeline basically consists of :
vtkJPEGReader -> ... some VTK filters ... -> vtkImageExport ->
itk::VTKImageImport -> .... some ITK filters ... -> itk::VTKImageExport ->
vtkImageImport -> ... some VTK filters ... -> vtkImageActor
The whole thing works fine the first time. Now I try to load another
JPEG stack and the new images don't appear in the screen. When I load the
new images, what I do is basically what follows
m_pwndVTKRenderArea->m_vtkImageReader->SetReleaseDataFlag(1); // should
this be here???
m_pwndVTKRenderArea->m_vtkImageReader->SetFilePattern(strFilePattern);
m_pwndVTKRenderArea->m_vtkImageReader->SetFilePrefix(strPath+strPrefix);
m_pwndVTKRenderArea->m_vtkImageReader->SetFileNameSliceOffset(nFirstSliceOff
set);
m_pwndVTKRenderArea->m_vtkImageReader->UpdateInformation();
// I have to do this to set the number of slices to the number of files
selected
// I ignore if I can do it in a better way
m_pwndVTKRenderArea->m_vtkImageReader->GetDataExtent(pDataExtent); //
pDataExtent is int[6]
// the extent of images is obtained correctly but I have to set the Z
extent manually to the // number of jpeg files selected
m_pwndVTKRenderArea->m_vtkImageReader->SetDataExtent(pDataExtent[0],pDataExt
ent[1],
pDataExtent[2],pDataExtent[3],0,nCount-1);
m_pwndVTKRenderArea->m_vtkImageReader->SetDataSpacing(0.18,0.18,0.8);
m_pwndVTKRenderArea->m_vtkImageReader->UpdateInformation();
// tried also Update() and Modified() here but receive error messages
m_pwndVTKRenderArea->m_vtkImageReader->GetOutput()->SetUpdateExtentToWholeEx
tent();
m_pwndVTKRenderArea->Invalidate(); // redraw window
where m_pwndVTKRenderArea is the render window (a Windows window) and
m_vtkImageReader is of type vtkJPEGReader.
After this, an OnPaint message handler is called which calls to
UpdateWholeExtent() for the last filter in the pipeline. The rest of the
pipeline remains unchanged.
I catch an exception of type "VTKImageImport : Import and buffer sizes
do not match"
Seems like the whole pipeline is not aware that the source data is new
and has a different extent.
I have tried many combinations of methods for updating. I have also
deleted the vtkJPEGReader and reallocated it but it doesn't work. If
possible I would like to know what series of steps I should follow to ensure
that data is updated through the whole pipeline, having in mind that new
data extent is different.
Thank you in advance for your help
Regards
Ivan
--------------------------------
Iván Macía
Ing. Industrial
Ing. en Automática y Electrónica
Asociación VICOMTech
http://www . vicomtech . es
Paseo Mikeletegi 57, bajo
20.009 Donostia-San Sebastián
(Gipuzkoa) SPAIN
Tlfno: (00 34) 943 30 92 30
Fax: (00 34) 943 30 93 93
e-mail: imacia at vicomtech . es <mailto:imacia at vicomtech . es>
***Member of INI-GraphicsNet***
http://www . inigraphics . net
-------------------------------