[Insight-users] From Vtk To Itk Run Time Error!
yasser salman
yass71 at yahoo.com
Tue, 10 Feb 2004 09:51:25 -0800 (PST)
hi Luis..,
the same Runtime Error Message Appeared,, the first
part working good (displayed the dicom files found in
../../Nesma1)
at the second part the vtk Renderwindow initialized
to display the output files after volume processed by
itk filters but the run
time error message occured,, what i did..,
1- update my itk to ver 1.6.0 . run Cmake and complie
a new itk.dsw (no problem)
2- update my itkApplication to ver1.6.0 ..
3- minimize my code to avoid itk filters in order to
Detect where the problem is ,I found that the same
run time Error message occured , i excepect that the
error in VTK2ITKconnector->SetInput( Reader
->GetOutput() );
so i check out the itkVTKImageToImageFilter.h and
found that
void SetInput( vtkImageData * );
and also itkVTKImageToImageFilter.txx found that
VTKImageToImageFilter<TOutputImage>
::SetInput( vtkImageData * inputImage )
does it mean any thing about the error.., here is the
mini code that i did..,
thanx Luis and waiting ur suggestion about that ..,
yasser ..,
int main( int argc, char ** argv )
{
typedef unsigned char InputPixelType;
typedef unsigned char InternalPixelType;
typedef unsigned char SegmentedPixelType;
typedef itk::Image< InputPixelType, 3 >
InputImageType;
typedef itk::Image< InternalPixelType, 3>
InternalImageType;
typedef itk::Image< SegmentedPixelType, 3 >
SegmentedImageType;
typedef itk::CastImageFilter<
InputImageType,
InternalImageType >
CastImageFilterType;
typedef itk::ImageToVTKImageFilter<
SegmentedImageType >
ITK2VTKConnectorFilterType;
typedef itk::VTKImageToImageFilter< InputImageType
>
VTK2ITKConnectorFilterType;
vtkDICOMImageReader
*Reader=vtkDICOMImageReader::New();
vtkImageViewer2 *viewer = vtkImageViewer2::New();
argv[1]="E:/imagedata/Dicom/1Nesma";
Reader->SetDirectoryName(argv[1]);
Reader->Update();
vtkImageFlip *flipY = vtkImageFlip::New();
flipY->SetInput (Reader->GetOutput());
flipY->SetFilteredAxis (1);
viewer->SetInput(flipY->GetOutput());
int VolData_Images = viewer->GetWholeZMax ();
for (int i=1;i<VolData_Images;i++)
{
viewer->SetZSlice(i);
viewer->SetSize(512,512);
viewer->SetPosition(500,0);
viewer->SetColorWindow(512);
viewer->SetColorLevel(256);
viewer->Render();
// TODO: Add your command handler code here
}
//----------------------------------
// ITK Pipeline
//----------------------------------
CastImageFilterType::Pointer cast =
CastImageFilterType::New();
VTK2ITKConnectorFilterType::Pointer VTK2ITKconnector
=
VTK2ITKConnectorFilterType::New();
VTK2ITKconnector->SetInput( Reader ->GetOutput() );
cast->SetInput( VTK2ITKconnector->GetOutput() );
ITK2VTKConnectorFilterType::Pointer ITK2VTKconnector
=
ITK2VTKConnectorFilterType::New();
ITK2VTKconnector->SetInput(cast ->GetOutput());
ITK2VTKconnector->GetImporter()->SetDataScalarTypeToUnsignedChar();
//----------------------------------
// VTK Pipeline
//----------------------------------
vtkRenderer * renderer =
vtkRenderer::New();
vtkRenderWindow * renderWindow =
vtkRenderWindow::New();
vtkRenderWindowInteractor * renderWindowInteractor =
vtkRenderWindowInteractor::New();
vtkImageActor* imageactor = vtkImageActor::New();
renderWindow->AddRenderer( renderer );
renderWindow->SetInteractor( renderWindowInteractor
);
vtkMarchingCubes *mc = vtkMarchingCubes::New();
mc->SetInput( ITK2VTKconnector->GetOutput() );
mc->SetValue(0,127);
vtkPolyDataMapper* mcmap=vtkPolyDataMapper::New();
mcmap->SetInput(mc->GetOutput());
mcmap->ScalarVisibilityOff();
vtkActor* mcactor=vtkActor::New();
mcactor->SetMapper(mcmap);
renderer->AddActor(mcactor);
renderer->SetBackground( 0.1, 0.2, 0.4 );
renderWindow->Render();
renderWindowInteractor->Start();
return 0;
}
__________________________________
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html