diff --git a/Examples/N4BiasFieldCorrection.cxx b/Examples/N4BiasFieldCorrection.cxx index 4596471b7..5880a4886 100644 --- a/Examples/N4BiasFieldCorrection.cxx +++ b/Examples/N4BiasFieldCorrection.cxx @@ -151,14 +151,10 @@ int N4( itk::ants::CommandLineParser *parser ) thresholder->SetUpperThreshold( itk::NumericTraits::ZeroValue() ); thresholder->SetInput( maskImage ); - typename IntImageType::Pointer thresholdedMask = thresholder->GetOutput(); - thresholdedMask->Update(); - thresholdedMask->DisconnectPipeline(); - typedef itk::LabelStatisticsImageFilter StatsType; typename StatsType::Pointer statsOriginal = StatsType::New(); statsOriginal->SetInput( inputImage ); - statsOriginal->SetLabelInput( thresholdedMask ); + statsOriginal->SetLabelInput( thresholder->GetOutput() ); statsOriginal->UseHistogramsOff(); statsOriginal->Update(); @@ -540,11 +536,16 @@ int N4( itk::ants::CommandLineParser *parser ) if( doRescale ) { - thresholdedMask->SetRegions( dividedImage->GetLargestPossibleRegion() ); + typename ThresholderType::Pointer thresholder2 = ThresholderType::New(); + thresholder2->SetInsideValue( itk::NumericTraits::ZeroValue() ); + thresholder2->SetOutsideValue( itk::NumericTraits::OneValue() ); + thresholder2->SetLowerThreshold( itk::NumericTraits::ZeroValue() ); + thresholder2->SetUpperThreshold( itk::NumericTraits::ZeroValue() ); + thresholder2->SetInput( maskImage ); typename StatsType::Pointer statsBiasCorrected = StatsType::New(); statsBiasCorrected->SetInput( dividedImage ); - statsBiasCorrected->SetLabelInput( thresholdedMask ); + statsBiasCorrected->SetLabelInput( thresholder2->GetOutput() ); statsBiasCorrected->UseHistogramsOff(); statsBiasCorrected->Update();