[Insight-users] pipeline:ITK to VTK
Beck
y_h_young at hotmail.com
Thu, 18 Mar 2004 11:24:40 +0800
This is a multi-part message in MIME format.
------=_NextPart_000_003B_01C40CDB.9AA80410
Content-Type: text/plain;
charset="big5"
Content-Transfer-Encoding: quoted-printable
Dear all:
I try the example "SegmenterViewer2" (attached below).It can compile =
and link ,but it will fail at run time.
(I replace'VXLNumerics.lib' with 'ITKNumerics.lib' because I can't =
find VXLNumerics.lib in IVK directory.)
I can't find what happen in it,hope somebody can help,thank you very =
much.
Best regards
Beck
//----------- SegmenterViewer2 .cxx ------------------------
#include "itkImageFileReader.h"
#include "itkImageToVTKImageFilter.h"
#include "itkImage.h"
#include "itkCastImageFilter.h"
#include "itkConfidenceConnectedImageFilter.h"
#include "itkCurvatureFlowImageFilter.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkContourFilter.h"
#include "vtkPolyDataMapper.h"
#include "vtkActor.h"
#include "vtkProperty.h"
int main( int argc, char ** argv )
{
if( argc < 6 )
{
std::cerr << "Usage: viewer1 imagefilename xseed yseed zseed =
neighborhoodsize" << std::endl;
return -1;
}
typedef signed short InputPixelType;
typedef float 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::ImageFileReader< InputImageType > ReaderType;
typedef itk::CastImageFilter<=20
InputImageType,=20
InternalImageType > CastImageFilterType;
typedef itk::CurvatureFlowImageFilter<=20
InternalImageType,=20
InternalImageType > CurvatureFlowImageFilterType;
typedef itk::ConfidenceConnectedImageFilter<=20
InternalImageType,=20
SegmentedImageType > =
ConfidenceConnectedImageFilterType;
typedef itk::ImageToVTKImageFilter< SegmentedImageType > =
ConnectorFilterType;
//----------------------------------
// ITK Pipeline
//----------------------------------
ReaderType::Pointer reader =3D ReaderType::New();
CastImageFilterType::Pointer cast =3D CastImageFilterType::New();
CurvatureFlowImageFilterType::Pointer smoothing =3D =
CurvatureFlowImageFilterType::New();
ConfidenceConnectedImageFilterType::Pointer confidence =3D =
ConfidenceConnectedImageFilterType::New();
ConnectorFilterType::Pointer connector =3D ConnectorFilterType::New();
reader->SetFileName( argv[1] );
cast->SetInput( reader->GetOutput() );
smoothing->SetInput( cast->GetOutput() );
confidence->SetInput( smoothing->GetOutput() );
smoothing->SetTimeStep( 0.125 );
smoothing->SetNumberOfIterations( 2 );
=20
confidence->SetMultiplier( 5.0 );
confidence->SetNumberOfIterations( 2 );
confidence->SetReplaceValue( 250 );
=20
typedef ConfidenceConnectedImageFilterType::IndexType IndexType;
IndexType seed;
seed[0] =3D atoi( argv[2] );
seed[1] =3D atoi( argv[3] );
seed[2] =3D atoi( argv[4] );
std::cout << "Using seed =3D " << seed << std::endl;
confidence->SetSeed( seed );
confidence->SetInitialNeighborhoodRadius( atoi( argv[5] ) );
connector->SetInput( confidence->GetOutput() );
connector->GetImporter()->SetDataScalarTypeToUnsignedChar();
//----------------------------------
// VTK Pipeline
//----------------------------------
vtkRenderer * renderer =3D =
vtkRenderer::New();
vtkRenderWindow * renderWindow =3D =
vtkRenderWindow::New();
vtkRenderWindowInteractor * renderWindowInteractor =3D =
vtkRenderWindowInteractor::New();
renderWindow->AddRenderer( renderer );
renderWindow->SetInteractor( renderWindowInteractor );
vtkContourFilter * contour =3D vtkContourFilter::New();
=20
contour->SetInput( connector->GetOutput() );
contour->SetValue( 0, 127.0 );
vtkPolyDataMapper * polyDataMapper =3D vtkPolyDataMapper::New();
polyDataMapper->SetInput( contour->GetOutput() );
polyDataMapper->SetScalarRange( 0.0, 250.0 );
vtkActor * actor =3D vtkActor::New();
actor->SetMapper( polyDataMapper );
actor->GetProperty()->SetColor( 0.8, 0.8, 1.0 );
=20
renderer->AddActor( actor );
renderer->SetBackground( 0.1, 0.2, 0.4 );
renderWindow->Render();
renderWindowInteractor->Start();
=20
return 0;
}
//------ CMakeLists.txt --------------------------
PROJECT( SegmenterViewer2 )
INCLUDE (${CMAKE_ROOT}/Modules/FindITK.cmake)
IF (USE_ITK_FILE)
INCLUDE (${USE_ITK_FILE})
ENDIF (USE_ITK_FILE)
INCLUDE (${CMAKE_ROOT}/Modules/FindVTK.cmake)
IF (USE_VTK_FILE)
INCLUDE (${USE_VTK_FILE})
ENDIF (USE_VTK_FILE)
ADD_EXECUTABLE( SegmenterViewer2 SegmenterViewer2.cxx )
TARGET_LINK_LIBRARIES( SegmenterViewer2
ITKIO ITKCommon ITKBasicFilters ITKNumerics ITKNumerics
vtkCommon vtkGraphics vtkRendering vtkImaging vtkIO vtkHybrid )
------=_NextPart_000_003B_01C40CDB.9AA80410
Content-Type: text/html;
charset="big5"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; charset=3Dbig5">
<META content=3D"MSHTML 6.00.2800.1226" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT size=3D2>
<DIV><FONT size=3D4>Dear all:</FONT></DIV>
<DIV><FONT size=3D4> I try the example =
"SegmenterViewer2"=20
(attached below).It can compile and link ,but it will fail at run=20
time.</FONT></DIV>
<DIV><FONT size=3D4></FONT> </DIV>
<DIV><FONT size=3D4> (I replace'VXLNumerics.lib' with=20
'ITKNumerics.lib' because I can't find VXLNumerics.lib in IVK=20
directory.)</FONT></DIV>
<DIV><FONT size=3D4></FONT> </DIV>
<DIV><FONT size=3D4> I can't find what happen in =
it,hope=20
somebody can help,thank you very much.</FONT></DIV>
<DIV><FONT size=3D4></FONT> </DIV>
<DIV><FONT size=3D4></FONT> </DIV>
<DIV><FONT size=3D4> Best regards</FONT></DIV>
<DIV><FONT size=3D4></FONT> </DIV>
<DIV><FONT size=3D4> Beck</FONT></DIV>
<DIV><FONT size=3D4></FONT> </DIV>
<DIV><FONT size=3D4>//----------- SegmenterViewer2 .cxx =
------------------------</FONT></DIV>
<DIV><FONT size=3D2>#include "itkImageFileReader.h"<BR>#include=20
"itkImageToVTKImageFilter.h"<BR>#include "itkImage.h"</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3D2>#include "itkCastImageFilter.h"<BR>#include=20
"itkConfidenceConnectedImageFilter.h"<BR>#include=20
"itkCurvatureFlowImageFilter.h"</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3D2>#include "vtkRenderer.h"<BR>#include=20
"vtkRenderWindow.h"<BR>#include =
"vtkRenderWindowInteractor.h"<BR>#include=20
"vtkContourFilter.h"<BR>#include "vtkPolyDataMapper.h"<BR>#include=20
"vtkActor.h"<BR>#include "vtkProperty.h"</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3D2>int main( int argc, char ** argv )<BR>{</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3D2> if( argc < 6 )<BR> =20
{<BR> std::cerr << "Usage: viewer1 =
imagefilename =20
xseed yseed zseed neighborhoodsize" << =
std::endl;<BR> =20
return -1;<BR> }</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3D2> typedef signed short =20
InputPixelType;<BR> typedef=20
float =20
InternalPixelType;<BR> typedef unsigned char =20
SegmentedPixelType;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3D2> typedef itk::Image< InputPixelType, 3=20
> =20
InputImageType;<BR> typedef itk::Image< InternalPixelType, 3=20
> InternalImageType;<BR> =
typedef=20
itk::Image< SegmentedPixelType, 3 > =20
SegmentedImageType;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3D2> typedef itk::ImageFileReader< =
InputImageType=20
> ReaderType;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3D2> typedef itk::CastImageFilter<=20
<BR> &nb=
sp; =20
InputImageType,=20
<BR> &nb=
sp; =20
InternalImageType > =
CastImageFilterType;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3D2> typedef =
itk::CurvatureFlowImageFilter<=20
<BR> &nb=
sp; =20
InternalImageType,=20
<BR> &nb=
sp; =20
InternalImageType > =20
CurvatureFlowImageFilterType;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3D2> typedef =20
itk::ConfidenceConnectedImageFilter<=20
<BR> &nb=
sp; &nbs=
p;=20
InternalImageType,=20
<BR> &nb=
sp; &nbs=
p;=20
SegmentedImageType > =20
ConfidenceConnectedImageFilterType;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3D2> typedef itk::ImageToVTKImageFilter<=20
SegmentedImageType > ConnectorFilterType;</FONT></DIV>
<DIV> </DIV><FONT size=3D2>
<DIV><BR> //----------------------------------<BR> =20
// ITK=20
Pipeline<BR> //----------------------------------</DIV>
<DIV> </DIV>
<DIV> ReaderType::Pointer reader =3D =
ReaderType::New();</DIV>
<DIV> </DIV>
<DIV> CastImageFilterType::Pointer cast =3D=20
CastImageFilterType::New();</DIV>
<DIV> </DIV>
<DIV> CurvatureFlowImageFilterType::Pointer smoothing =3D=20
CurvatureFlowImageFilterType::New();</DIV>
<DIV> </DIV>
<DIV> ConfidenceConnectedImageFilterType::Pointer confidence =3D=20
ConfidenceConnectedImageFilterType::New();</DIV>
<DIV> </DIV>
<DIV> ConnectorFilterType::Pointer connector =3D=20
ConnectorFilterType::New();</DIV>
<DIV> </DIV>
<DIV> reader->SetFileName( argv[1] );</DIV>
<DIV> </DIV>
<DIV> cast->SetInput( =20
reader->GetOutput() );<BR> smoothing->SetInput( =20
cast->GetOutput() );<BR> confidence->SetInput(=20
smoothing->GetOutput() );</DIV>
<DIV> </DIV>
<DIV> smoothing->SetTimeStep( 0.125 );<BR> =20
smoothing->SetNumberOfIterations( 2 );<BR> =
<BR> =20
confidence->SetMultiplier( 5.0 );<BR> =20
confidence->SetNumberOfIterations( 2 );<BR> =20
confidence->SetReplaceValue( 250 );<BR> <BR> typedef=20
ConfidenceConnectedImageFilterType::IndexType IndexType;<BR> =
IndexType=20
seed;<BR> seed[0] =3D atoi( argv[2] );<BR> seed[1] =3D atoi( =
argv[3]=20
);<BR> seed[2] =3D atoi( argv[4] );</DIV>
<DIV> </DIV>
<DIV> std::cout << "Using seed =3D " << seed <<=20
std::endl;<BR> confidence->SetSeed( seed );</DIV>
<DIV> </DIV>
<DIV> confidence->SetInitialNeighborhoodRadius( atoi( argv[5] ) =
);</DIV>
<DIV> </DIV>
<DIV> connector->SetInput( confidence->GetOutput() =
);<BR> =20
connector->GetImporter()->SetDataScalarTypeToUnsignedChar();</DIV>
<DIV> </DIV>
<DIV> //----------------------------------<BR> =20
// VTK=20
Pipeline<BR> //----------------------------------</DIV>
<DIV> </DIV>
<DIV> =20
vtkRenderer &n=
bsp; =20
*=20
renderer  =
; =20
=3D vtkRenderer::New();<BR> =20
vtkRenderWindow &nbs=
p; *=20
renderWindow =
=3D=20
vtkRenderWindow::New();<BR> vtkRenderWindowInteractor *=20
renderWindowInteractor =3D vtkRenderWindowInteractor::New();</DIV>
<DIV> </DIV>
<DIV> renderWindow->AddRenderer( renderer );<BR> =20
renderWindow->SetInteractor( renderWindowInteractor );</DIV>
<DIV> </DIV>
<DIV> vtkContourFilter * contour =3D =
vtkContourFilter::New();<BR> =20
<BR> contour->SetInput( connector->GetOutput() );<BR> =20
contour->SetValue( 0, 127.0 );</DIV>
<DIV> </DIV>
<DIV> vtkPolyDataMapper * polyDataMapper =3D =
vtkPolyDataMapper::New();</DIV>
<DIV> </DIV>
<DIV> polyDataMapper->SetInput( contour->GetOutput() =
);<BR> =20
polyDataMapper->SetScalarRange( 0.0, 250.0 );</DIV>
<DIV> </DIV>
<DIV> vtkActor * actor =3D vtkActor::New();<BR> =
actor->SetMapper(=20
polyDataMapper );<BR> actor->GetProperty()->SetColor( 0.8, =
0.8, 1.0=20
);<BR> <BR> renderer->AddActor( actor );<BR> =20
renderer->SetBackground( 0.1, 0.2, 0.4 );</DIV>
<DIV> </DIV>
<DIV> renderWindow->Render();<BR> =20
renderWindowInteractor->Start();<BR> <BR> return 0;</DIV>
<DIV> </DIV>
<DIV>}<BR></FONT><FONT size=3D4>//------ =
CMakeLists.txt =20
--------------------------</FONT></DIV>
<DIV><FONT size=3D2>PROJECT( SegmenterViewer2 )</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3D2>INCLUDE (${CMAKE_ROOT}/Modules/FindITK.cmake)<BR>IF=20
(USE_ITK_FILE)<BR> INCLUDE (${USE_ITK_FILE})<BR>ENDIF=20
(USE_ITK_FILE)</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3D2>INCLUDE (${CMAKE_ROOT}/Modules/FindVTK.cmake)<BR>IF=20
(USE_VTK_FILE)<BR> INCLUDE (${USE_VTK_FILE})<BR>ENDIF=20
(USE_VTK_FILE)</FONT></DIV>
<DIV> </DIV><FONT size=3D2>
<DIV><BR>ADD_EXECUTABLE( SegmenterViewer2 SegmenterViewer2.cxx )</DIV>
<DIV> </DIV>
<DIV>TARGET_LINK_LIBRARIES( SegmenterViewer2<BR> ITKIO =
ITKCommon ITKBasicFilters ITKNumerics ITKNumerics<BR> =20
vtkCommon vtkGraphics vtkRendering vtkImaging vtkIO vtkHybrid )</DIV>
<DIV> </DIV>
<DIV></FONT> </DIV></FONT></DIV></BODY></HTML>
------=_NextPart_000_003B_01C40CDB.9AA80410--