[Insight-users] problem using itkGeodesicActiveContourLevelSetImageFilter
john smith
mkitkinsightuser at gmail.com
Fri Jun 10 14:45:24 EDT 2011
Hello,
I am reading a 3D volume, rescale it to [0,255], extract a 3D region from
this volume, use the itkGeodesicActiveContourLevelSetImageFilter over the
extracted region and finally get a slice from the output of the GAC filter.
Well I have wrote some code, which doesn't give any debug errors. I have
loaded a small extracted region (5x5x5) as input for the
itkGeodesicActiveContourLevelSetImageFilte.After finishing the debug of the
code, the compiler seems to still runing, for 3 hours so far. I cannot
understand the reason why debuger is still runing and I didn't get any
result, while I do not get any debug error when using breakpoints. Here is
my code. I hope someone could help me.
Thanks
///////////filter rescale
FilterType_rescale::Pointer filter_rescale =
FilterType_rescale::New();
filter_rescale->SetOutputMinimum( 0 );
filter_rescale->SetOutputMaximum( value_norm );
//////extract region filter
FilterType_region::Pointer filter_region = FilterType_region::New();
OutputImageType::IndexType start_region;
start_region[0] = ui->doubleSpinBox_start_x->value();
start_region[1] = ui->doubleSpinBox_start_y->value();
start_region[2] = ui->doubleSpinBox_start_z->value();
OutputImageType::SizeType size_region;
size_region[0] = ui->doubleSpinBox_size_x->value();
size_region[1] = ui->doubleSpinBox_size_y->value();
size_region[2] = ui->doubleSpinBox_size_z->value();
OutputImageType::RegionType desiredRegion_region;
desiredRegion_region.SetSize( size_region );
desiredRegion_region.SetIndex( start_region );
filter_region->SetRegionOfInterest( desiredRegion_region );
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName( fileName.toStdString() );
filter_rescale->SetInput( reader->GetOutput() );
filter_region->SetInput( filter_rescale->GetOutput() );
////////////////////////////////////////////////////////////
/////////////////////GAC algorithm in extracted region
ThresholdingFilterType::Pointer thresholder =
ThresholdingFilterType::New();
thresholder->SetLowerThreshold( -1000.0 );
thresholder->SetUpperThreshold( 0.0 );
thresholder->SetOutsideValue( 0 );
thresholder->SetInsideValue( 255 );
SmoothingFilterType::Pointer smoothing = SmoothingFilterType::New();
GradientFilterType::Pointer gradientMagnitude =
GradientFilterType::New();
SigmoidFilterType::Pointer sigmoid = SigmoidFilterType::New();
sigmoid->SetOutputMinimum( 0.0 );
sigmoid->SetOutputMaximum( 1.0 );
FastMarchingFilterType::Pointer fastMarching =
FastMarchingFilterType::New();
GeodesicActiveContourFilterType::Pointer geodesicActiveContour =
GeodesicActiveContourFilterType::New();
const double propagationScaling =
ui->doubleSpinBox_propagationScaling->value();
geodesicActiveContour->SetPropagationScaling( propagationScaling );
geodesicActiveContour->SetCurvatureScaling( 1.0 );
geodesicActiveContour->SetAdvectionScaling( 1.0 );
geodesicActiveContour->SetMaximumRMSError( 0.02 );
geodesicActiveContour->SetNumberOfIterations( 800 );
smoothing->SetInput( filter_region->GetOutput() );
gradientMagnitude->SetInput( smoothing->GetOutput() );
sigmoid->SetInput( gradientMagnitude->GetOutput() );
geodesicActiveContour->SetInput( fastMarching->GetOutput() );
geodesicActiveContour->SetFeatureImage( sigmoid->GetOutput() );
thresholder->SetInput( geodesicActiveContour->GetOutput() );
//////////////////////////
FilterType_extract_GAC::Pointer filter_extract_z =
FilterType_extract_GAC::New();
WriterType::Pointer writer_z = WriterType::New();
writer_z->SetFileName( "result_z.png" );
filter_region->Update();
InputImageType::RegionType inputRegion =
filter_region->GetOutput()->GetLargestPossibleRegion();
InputImageType::SizeType size = inputRegion.GetSize();
// get the size of the hole 3D image
size_x = size[0];
size_y = size[1];
size_z = size[2];
// get slices of z coordinate
size[2] = 0;
InputImageType::IndexType start = inputRegion.GetIndex();
// const unsigned int sliceNumber = 90;
ui->verticalScrollBar_z->setRange(0,size_z-1);
unsigned int sliceNumber = ui->verticalScrollBar_z->value();
start[2] = sliceNumber;
// ui->verticalScrollBar_z->setValue(sliceNumber);
InputImageType::RegionType desiredRegion;
desiredRegion.SetSize( size );
desiredRegion.SetIndex( start );
filter_extract_z->SetExtractionRegion( desiredRegion );
////////////////////////////
filter_extract_z->SetInput( thresholder->GetOutput() );
writer_z->SetInput( filter_extract_z->GetOutput() );
smoothing->SetTimeStep( 0.0625 );
smoothing->SetNumberOfIterations( 5 );
smoothing->SetConductanceParameter( 9.0 );
const double sigma = ui->doubleSpinBox_sigma->value();
gradientMagnitude->SetSigma( sigma );
const double alpha = ui->doubleSpinBox_alpha->value();
const double beta = ui->doubleSpinBox_beta->value();
sigmoid->SetAlpha( alpha );
sigmoid->SetBeta( beta );
NodeContainer::Pointer seeds = NodeContainer::New();
InputImageType::IndexType seedPosition;
seedPosition[0] = ui->doubleSpinBox_seed_x->value();
seedPosition[1] = ui->doubleSpinBox_seed_y->value();
seedPosition[2] = ui->doubleSpinBox_seed_z->value();
const double initialDistance =
ui->doubleSpinBox_initial_distance->value();
NodeType node;
const double seedValue = - initialDistance;
node.SetValue( seedValue );
node.SetIndex( seedPosition );
seeds->Initialize();
seeds->InsertElement( 0, node );
fastMarching->SetTrialPoints( seeds );
fastMarching->SetSpeedConstant( 1.0 );
fastMarching->SetOutputSize(
reader->GetOutput()->GetBufferedRegion().GetSize() );
try
{
writer_z->Update();
}
catch( itk::ExceptionObject & excep )
{
std::cerr << "Exception caught !" << std::endl;
std::cerr << excep << std::endl;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110610/f8dbcd21/attachment.htm>
More information about the Insight-users
mailing list