// -------------------------------------------------------------------------
const unsigned int Dim = 3;
typedef short TPixel;
-typedef double TScalar;
+typedef float TScalar;
typedef itk::Image< TPixel, Dim > TImage;
typedef itk::Image< TScalar, Dim > TDistanceMap;
typedef itk::ImageToVTKImageFilter< TImage > TVTKImage;
// -------------------------------------------------------------------------
int main( int argc, char* argv[] )
{
- if( argc < 7 )
+ if( argc < 8 )
{
std::cerr
<< "Usage: " << argv[ 0 ]
<< " input_image thr_0 thr_1 step"
- << " output_segmentation output_distancemap"
+ << " output_segmentation output_distancemap output_dijkstra"
<< " visual_debug"
<< std::endl;
return( 1 );
unsigned int step = std::atoi( argv[ 4 ] );
std::string output_segmentation_fn = argv[ 5 ];
std::string output_distancemap_fn = argv[ 6 ];
+ std::string output_dijkstra_fn = argv[ 7 ];
bool visual_debug = false;
- if( argc > 7 )
- visual_debug = ( std::atoi( argv[ 7 ] ) == 1 );
+ if( argc > 8 )
+ visual_debug = ( std::atoi( argv[ 8 ] ) == 1 );
// Read image
TImageReader::Pointer input_image_reader = TImageReader::New( );
view.Render( );
view.Start( );
- /* TODO
- TDistanceMapWriter::Pointer distancemap_writer =
- TDistanceMapWriter::New( );
- distancemap_writer->SetInput( distanceMap->GetOutput( ) );
- distancemap_writer->SetFileName( output_distancemap_fn );
- distancemap_writer->Update( );
-
- TImageWriter::Pointer segmentation_writer =
- TImageWriter::New( );
- segmentation_writer->SetInput( segmentor->GetOutput( ) );
- segmentation_writer->SetFileName( output_segmentation_fn );
- segmentation_writer->Update( );
- */
-
- // Show result
- /*
- TVTKImage::Pointer output_image_vtk = TVTKImage::New( );
- output_image_vtk->SetInput( segmentor->GetOutput( ) );
- output_image_vtk->Update( );
-
- vtkSmartPointer< vtkImageMarchingCubes > mc =
- vtkSmartPointer< vtkImageMarchingCubes >::New( );
- mc->SetInputData( output_image_vtk->GetOutput( ) );
- mc->SetValue(
- 0,
- double( segmentor->GetInsideValue( ) ) * double( 0.95 )
- );
- mc->Update( );
-
- // Let some interaction and close program
- view.AddPolyData( mc->GetOutput( ), 0.1, 0.6, 0.8, 0.5 );
- view.Start( );
+ itk::ImageFileWriter< TImage >::Pointer segmentation_writer =
+ itk::ImageFileWriter< TImage >::New( );
+ segmentation_writer->SetInput( segmentor->GetOutput( ) );
+ segmentation_writer->SetFileName( output_segmentation_fn );
- // Write resulting image
- TImageWriter::Pointer output_image_writer = TImageWriter::New( );
- output_image_writer->SetInput( segmentor->GetOutput( ) );
- output_image_writer->SetFileName( output_image_fn );
- try
- {
- output_image_writer->Update( );
- }
- catch( itk::ExceptionObject& err )
- {
+ itk::ImageFileWriter< TDistanceMap >::Pointer dmap_writer =
+ itk::ImageFileWriter< TDistanceMap >::New( );
+ dmap_writer->SetInput( distanceMap->GetOutput( ) );
+ dmap_writer->SetFileName( output_distancemap_fn );
+
+ itk::ImageFileWriter< TDistanceMap >::Pointer dijk_writer =
+ itk::ImageFileWriter< TDistanceMap >::New( );
+ dijk_writer->SetInput( paths->GetOutput( ) );
+ dijk_writer->SetFileName( output_dijkstra_fn );
+
+ try
+ {
+ segmentation_writer->Update( );
+ dmap_writer->Update( );
+ dijk_writer->Update( );
+ }
+ catch( itk::ExceptionObject& err )
+ {
std::cerr << "Error caught: " << err << std::endl;
- return( 1 );
+ return( -1 );
+
+ } // yrt
- } // yrt
- */
return( 0 );
}
#ifndef __FPA__IMAGE__REGIONGROW__H__
#define __FPA__IMAGE__REGIONGROW__H__
-#include <itkImageFunction.h>
#include <itkImageToImageFilter.h>
#include <itkIndex.h>
#include <fpa/Base/RegionGrow.h>
#include <fpa/Image/Algorithm.h>
+#include <fpa/Image/Functors/ImageFunction.h>
namespace fpa
{
typedef itk::SmartPointer< Self > Pointer;
typedef itk::SmartPointer< const Self > ConstPointer;
- typedef itk::ImageFunction< I, bool > TMembershipFunction;
+ typedef
+ fpa::Image::Functors::ImageFunction< I, bool >
+ TMembershipFunction;
public:
itkNewMacro( Self );
this->GetInput( )
)
this->m_MembershipFunction->SetInputImage( this->GetInput( ) );
- return( this->m_MembershipFunction->EvaluateAtIndex( n.Vertex ) );
+ return( this->m_MembershipFunction->Evaluate( n.Vertex ) );
}
else
return( false );