ITK、VTK混合编译

CannyEdgeDetectionImageFilter.cxx为例


#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "itkCastImageFilter.h"
#include "itkRescaleIntensityImageFilter.h"


// Software Guide : BeginLatex
//
// The first step required for using this filter is to include its header file.
//
// \index{itk::CannyEdgeDetectionImageFilter!header}
//
// Software Guide : EndLatex


// Software Guide : BeginCodeSnippet
#include "itkCannyEdgeDetectionImageFilter.h"
// Software Guide : EndCodeSnippet

//#include "itkImage.h"
#include "itkImageToVTKImageFilter.h"
#include "vtkImageViewer.h"
#include "vtkWin32RenderWindowInteractor.h"

int main(int argc, char* argv[])
{
if( argc < 3 )
{
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0] << " inputImage outputImage [variance upperThreshold lowerThreshold]" << std::endl;
return EXIT_FAILURE;
}

const char * inputFilename = argv[1];
const char * outputFilename = argv[2];
float variance = 2.0;
float upperThreshold = 0.0;
float lowerThreshold = 0.0;

if( argc > 3 )
{
variance = atof( argv[3] );
}

if( argc > 4 )
{
upperThreshold = atof( argv[4] );
}

if( argc > 5 )
{
lowerThreshold = atof( argv[5] );
}

std::cout << "Variance = " << variance << std::endl;
std::cout << "UpperThreshold = " << upperThreshold << std::endl;
std::cout << "LowerThreshold = " << lowerThreshold << std::endl;

typedef unsigned char CharPixelType; // IO
typedef double RealPixelType; // Operations
const unsigned int Dimension = 2;

typedef itk::Image<CharPixelType, Dimension> CharImageType;
typedef itk::Image<RealPixelType, Dimension> RealImageType;

typedef itk::ImageFileReader< CharImageType > ReaderType;
typedef itk::ImageFileWriter< CharImageType > WriterType;

// Software Guide : BeginLatex
//
// This filter operates on images of pixel type \code{float}. It is then
// necessary to cast the type of the input images which are usually of
// integer type. The \doxygen{CastImageFilter} is used here for this purpose.
// Its image template parameters are defined for casting from the input type
// to the \code{float} type used for processing.
//
// Software Guide : EndLatex

// Software Guide : BeginCodeSnippet
typedef itk::CastImageFilter< CharImageType, RealImageType>
CastToRealFilterType;
// Software Guide : EndCodeSnippet

typedef itk::RescaleIntensityImageFilter<RealImageType, CharImageType > RescaleFilter;


// Software Guide : BeginLatex
//
// The \doxygen{CannyEdgeDetectionImageFilter} is instantiated using the
// \code{float} image type.
//
// \index{itk::CannyEdgeDetectionImageFilter|textbf}
//
// Software Guide : EndLatex


typedef itk::CannyEdgeDetectionImageFilter<RealImageType, RealImageType> CannyFilter;

//Setting the IO

ReaderType::Pointer reader = ReaderType::New();
// WriterType::Pointer writer = WriterType::New();

CastToRealFilterType::Pointer toReal = CastToRealFilterType::New();
RescaleFilter::Pointer rescale = RescaleFilter::New();

//Setting the ITK pipeline filter

CannyFilter::Pointer cannyFilter = CannyFilter::New();

reader->SetFileName( inputFilename );
// writer->SetFileName( outputFilename );

//The output of an edge filter is 0 or 1
rescale->SetOutputMinimum( 0 );
rescale->SetOutputMaximum( 255 );

toReal->SetInput( reader->GetOutput() );

cannyFilter->SetInput( toReal->GetOutput() );
cannyFilter->SetVariance( variance );
cannyFilter->SetUpperThreshold( upperThreshold );
cannyFilter->SetLowerThreshold( lowerThreshold );

rescale->SetInput( cannyFilter->GetOutput() );

//////////////////////////////////////////////////////////////////////////
//VTK
/////////////////////////////////////////////////////////////////////////

typedef itk::ImageToVTKImageFilter<CharImageType> ConnectorType;
ConnectorType::Pointer connector= ConnectorType::New();
connector->SetInput( rescale->GetOutput() );
vtkImageViewer* viewer= vtkImageViewer::New();
vtkWin32RenderWindowInteractor* renderWindowInteractor=
vtkWin32RenderWindowInteractor::New();
viewer->SetupInteractor( renderWindowInteractor);
viewer->SetInput( connector->GetOutput() );
viewer->Render();
viewer->SetColorWindow( 255);
viewer->SetColorLevel( 128);
renderWindowInteractor->Start();

// writer->SetInput( rescale->GetOutput() );
//
// try
// {
// writer->Update();
// }
// catch( itk::ExceptionObject & err )
// {
// std::cout << "ExceptionObject caught !" << std::endl;
// std::cout << err << std::endl;
// return EXIT_FAILURE;
// }


return EXIT_SUCCESS;

}

 

=================

lib库(vtk编译在F:\vtkdevelop\VTK\VTKbin\bin\Debug文件夹)

kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib;..\..\lib\Debug\itkdouble-conversion-4.7.lib;..\..\lib\Debug\itksys-4.7.lib;..\..\lib\Debug\itkvnl_algo-4.7.lib;..\..\lib\Debug\itkvnl-4.7.lib;..\..\lib\Debug\itkv3p_netlib-4.7.lib;..\..\lib\Debug\ITKCommon-4.7.lib;..\..\lib\Debug\itkNetlibSlatec-4.7.lib;..\..\lib\Debug\ITKStatistics-4.7.lib;..\..\lib\Debug\ITKIOImageBase-4.7.lib;..\..\lib\Debug\ITKIOBMP-4.7.lib;..\..\lib\Debug\ITKIOBioRad-4.7.lib;..\..\lib\Debug\ITKEXPAT-4.7.lib;..\..\lib\Debug\itkopenjpeg-4.7.lib;..\..\lib\Debug\itkzlib-4.7.lib;..\..\lib\Debug\itkgdcmDICT-4.7.lib;..\..\lib\Debug\itkgdcmMSFF-4.7.lib;..\..\lib\Debug\ITKIOGDCM-4.7.lib;..\..\lib\Debug\ITKIOGIPL-4.7.lib;..\..\lib\Debug\itkjpeg-4.7.lib;..\..\lib\Debug\ITKIOJPEG-4.7.lib;..\..\lib\Debug\itktiff-4.7.lib;..\..\lib\Debug\ITKIOTIFF-4.7.lib;..\..\lib\Debug\ITKIOLSM-4.7.lib;..\..\lib\Debug\ITKMetaIO-4.7.lib;..\..\lib\Debug\ITKIOMeta-4.7.lib;..\..\lib\Debug\ITKznz-4.7.lib;..\..\lib\Debug\ITKniftiio-4.7.lib;..\..\lib\Debug\ITKIONIFTI-4.7.lib;..\..\lib\Debug\ITKNrrdIO-4.7.lib;..\..\lib\Debug\ITKIONRRD-4.7.lib;..\..\lib\Debug\itkpng-4.7.lib;..\..\lib\Debug\ITKIOPNG-4.7.lib;..\..\lib\Debug\ITKIOStimulate-4.7.lib;..\..\lib\Debug\ITKIOVTK-4.7.lib;..\..\lib\Debug\ITKMesh-4.7.lib;..\..\lib\Debug\ITKSpatialObjects-4.7.lib;..\..\lib\Debug\ITKPath-4.7.lib;..\..\lib\Debug\ITKLabelMap-4.7.lib;..\..\lib\Debug\ITKQuadEdgeMesh-4.7.lib;..\..\lib\Debug\ITKOptimizers-4.7.lib;..\..\lib\Debug\ITKPolynomials-4.7.lib;..\..\lib\Debug\ITKBiasCorrection-4.7.lib;..\..\lib\Debug\ITKBioCell-4.7.lib;..\..\lib\Debug\ITKDICOMParser-4.7.lib;..\..\lib\Debug\ITKIOXML-4.7.lib;..\..\lib\Debug\ITKIOSpatialObjects-4.7.lib;..\..\lib\Debug\ITKFEM-4.7.lib;..\..\lib\Debug\ITKgiftiio-4.7.lib;..\..\lib\Debug\ITKIOMesh-4.7.lib;..\..\lib\Debug\itkhdf5_cpp-4.7.lib;..\..\lib\Debug\itkhdf5-4.7.lib;..\..\lib\Debug\ITKIOCSV-4.7.lib;..\..\lib\Debug\ITKIOIPL-4.7.lib;..\..\lib\Debug\ITKIOGE-4.7.lib;..\..\lib\Debug\ITKIOSiemens-4.7.lib;..\..\lib\Debug\ITKIOHDF5-4.7.lib;..\..\lib\Debug\ITKIOMRC-4.7.lib;..\..\lib\Debug\ITKIOTransformBase-4.7.lib;..\..\lib\Debug\ITKIOTransformHDF5-4.7.lib;..\..\lib\Debug\ITKIOTransformInsightLegacy-4.7.lib;..\..\lib\Debug\ITKIOTransformMatlab-4.7.lib;..\..\lib\Debug\ITKKLMRegionGrowing-4.7.lib;..\..\lib\Debug\ITKVTK-4.7.lib;..\..\lib\Debug\ITKWatersheds-4.7.lib;..\..\lib\Debug\ITKOptimizersv4-4.7.lib;..\..\lib\Debug\ITKVideoCore-4.7.lib;..\..\lib\Debug\ITKVideoIO-4.7.lib;..\..\lib\Debug\itkgdcmIOD-4.7.lib;..\..\lib\Debug\itkgdcmDSED-4.7.lib;..\..\lib\Debug\itkgdcmCommon-4.7.lib;..\..\lib\Debug\itkgdcmjpeg8-4.7.lib;..\..\lib\Debug\itkgdcmjpeg12-4.7.lib;..\..\lib\Debug\itkgdcmjpeg16-4.7.lib;rpcrt4.lib;comctl32.lib;wsock32.lib;ws2_32.lib;Psapi.lib;..\..\lib\Debug\ITKVNLInstantiation-4.7.lib;..\..\lib\Debug\itkv3p_lsqr-4.7.lib;..\..\lib\Debug\itkvcl-4.7.lib;F:\vtkdevelop\VTK\VTKbin\bin\Debug\vtkRendering.lib;F:\vtkdevelop\VTK\VTKbin\bin\Debug\vtkIO.lib;F:\vtkdevelop\VTK\VTKbin\bin\Debug\vtkDICOMParser.lib;F:\vtkdevelop\VTK\VTKbin\bin\Debug\vtkNetCDF_cxx.lib;F:\vtkdevelop\VTK\VTKbin\bin\Debug\vtkNetCDF.lib;F:\vtkdevelop\VTK\VTKbin\bin\Debug\vtkhdf5_hl.lib;F:\vtkdevelop\VTK\VTKbin\bin\Debug\vtkhdf5.lib;F:\vtkdevelop\VTK\VTKbin\bin\Debug\LSDyna.lib;F:\vtkdevelop\VTK\VTKbin\bin\Debug\vtkmetaio.lib;F:\vtkdevelop\VTK\VTKbin\bin\Debug\vtksqlite.lib;F:\vtkdevelop\VTK\VTKbin\bin\Debug\vtkpng.lib;F:\vtkdevelop\VTK\VTKbin\bin\Debug\vtktiff.lib;F:\vtkdevelop\VTK\VTKbin\bin\Debug\vtkzlib.lib;F:\vtkdevelop\VTK\VTKbin\bin\Debug\vtkjpeg.lib;F:\vtkdevelop\VTK\VTKbin\bin\Debug\vtkexpat.lib;vfw32.lib;F:\vtkdevelop\VTK\VTKbin\bin\Debug\vtkGraphics.lib;F:\vtkdevelop\VTK\VTKbin\bin\Debug\vtkverdict.lib;F:\vtkdevelop\VTK\VTKbin\bin\Debug\vtkImaging.lib;F:\vtkdevelop\VTK\VTKbin\bin\Debug\vtkFiltering.lib;F:\vtkdevelop\VTK\VTKbin\bin\Debug\vtkCommon.lib;F:\vtkdevelop\VTK\VTKbin\bin\Debug\vtksys.lib;F:\vtkdevelop\VTK\VTKbin\bin\Debug\vtkftgl.lib;F:\vtkdevelop\VTK\VTKbin\bin\Debug\vtkfreetype.lib;opengl32.lib

posted @ 2015-05-07 22:20  jines  阅读(1070)  评论(0编辑  收藏  举报