SimpleITK  2.0.0rc2.post59
FastMarchingSegmentation/FastMarchingSegmentation.cxx
/*=========================================================================
*
* Copyright NumFOCUS
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/
// This example is based on ITK's FastMarchingImageFilter.cxx example
#include <SimpleITK.h>
#include <iostream>
#include <string>
#include <cstdlib>
namespace sitk = itk::simple;
int main(int argc, char *argv[])
{
if ( argc < 10 )
{
std::cerr << "Missing Parameters " << std::endl;
std::cerr << "Usage: " << argv[0];
std::cerr << " inputImage outputImage seedX seedY";
std::cerr << " Sigma SigmoidAlpha SigmoidBeta TimeThreshold StoppingTime" << std::endl;
return EXIT_FAILURE;
}
const std::string inputFilename(argv[1]);
const std::string outputFilename(argv[2]);
unsigned int seedPosition[2];
seedPosition[0] = atoi( argv[3] );
seedPosition[1] = atoi( argv[4] );
const double sigma = atof( argv[5] );
const double alpha = atof( argv[6] );
const double beta = atof( argv[7] );
const double timeThreshold = atof( argv[8] );
const double stoppingTime = atof( argv[9] );
sitk::Image inputImage = sitk::ReadImage( inputFilename, sitk::sitkFloat32 );
smoothing.SetTimeStep( 0.125 );
smoothing.SetNumberOfIterations( 5 );
smoothing.SetConductanceParameter( 9.0 );
sitk::Image smoothingOutput = smoothing.Execute( inputImage );
gradientMagnitude.SetSigma( sigma );
sitk::Image gradientMagnitudeOutput = gradientMagnitude.Execute( smoothingOutput );
sigmoid.SetOutputMinimum( 0.0 );
sigmoid.SetOutputMaximum( 1.0 );
sigmoid.SetAlpha( alpha );
sigmoid.SetBeta( beta );
sitk::Image sigmoidOutput = sigmoid.Execute( gradientMagnitudeOutput );
std::vector< unsigned int > trialPoint(3);
trialPoint[0] = seedPosition[0];
trialPoint[1] = seedPosition[1];
trialPoint[2] = 0u; // Seed Value
fastMarching.AddTrialPoint( trialPoint );
fastMarching.SetStoppingValue(stoppingTime);
sitk::Image fastmarchingOutput = fastMarching.Execute( sigmoidOutput );
thresholder.SetLowerThreshold( 0.0 );
thresholder.SetUpperThreshold( timeThreshold );
thresholder.SetOutsideValue( 0 );
thresholder.SetInsideValue( 255 );
sitk::Image result = thresholder.Execute(fastmarchingOutput);
sitk::WriteImage(result, outputFilename);
return 0;
}
itk::simple::SigmoidImageFilter::SetOutputMinimum
Self & SetOutputMinimum(double OutputMinimum)
Definition: sitkSigmoidImageFilter.h:87
itk::simple::Image
The Image class for SimpleITK.
Definition: sitkImage.h:75
itk::simple::SigmoidImageFilter::SetAlpha
Self & SetAlpha(double Alpha)
Definition: sitkSigmoidImageFilter.h:63
itk::simple::BinaryThresholdImageFilter::SetLowerThreshold
Self & SetLowerThreshold(double LowerThreshold)
Definition: sitkBinaryThresholdImageFilter.h:67
itk::simple::SigmoidImageFilter
Computes the sigmoid function pixel-wise.
Definition: sitkSigmoidImageFilter.h:46
itk::simple::BinaryThresholdImageFilter::SetOutsideValue
Self & SetOutsideValue(uint8_t OutsideValue)
Definition: sitkBinaryThresholdImageFilter.h:96
itk::simple::BinaryThresholdImageFilter::SetInsideValue
Self & SetInsideValue(uint8_t InsideValue)
Definition: sitkBinaryThresholdImageFilter.h:86
SimpleITK.h
itk::simple::SigmoidImageFilter::SetOutputMaximum
Self & SetOutputMaximum(double OutputMaximum)
Definition: sitkSigmoidImageFilter.h:79
itk::simple::FastMarchingImageFilter
Solve an Eikonal equation using Fast Marching.
Definition: sitkFastMarchingImageFilter.h:69
itk::simple::CurvatureAnisotropicDiffusionImageFilter::SetTimeStep
Self & SetTimeStep(double TimeStep)
Definition: sitkCurvatureAnisotropicDiffusionImageFilter.h:77
itk::simple::FastMarchingImageFilter::AddTrialPoint
Self & AddTrialPoint(std::vector< unsigned int > point)
Add TrialPoints point.
Definition: sitkFastMarchingImageFilter.h:94
itk::simple::SigmoidImageFilter::Execute
Image Execute(Image &&image1)
itk::simple::GradientMagnitudeRecursiveGaussianImageFilter::Execute
Image Execute(Image &&image1)
itk::simple::BinaryThresholdImageFilter::SetUpperThreshold
Self & SetUpperThreshold(double UpperThreshold)
Definition: sitkBinaryThresholdImageFilter.h:76
itk::simple::sitkFloat32
@ sitkFloat32
32 bit float
Definition: sitkPixelIDValues.h:100
itk::simple::GradientMagnitudeRecursiveGaussianImageFilter
Computes the Magnitude of the Gradient of an image by convolution with the first derivative of a Gaus...
Definition: sitkGradientMagnitudeRecursiveGaussianImageFilter.h:42
itk::simple::BinaryThresholdImageFilter::Execute
Image Execute(Image &&image1)
itk::simple::CurvatureAnisotropicDiffusionImageFilter::SetConductanceParameter
Self & SetConductanceParameter(double ConductanceParameter)
Definition: sitkCurvatureAnisotropicDiffusionImageFilter.h:85
itk::simple::BinaryThresholdImageFilter
Binarize an input image by thresholding.
Definition: sitkBinaryThresholdImageFilter.h:50
itk::simple::CurvatureAnisotropicDiffusionImageFilter::Execute
Image Execute(Image &&image1)
itk::simple::GradientMagnitudeRecursiveGaussianImageFilter::SetSigma
Self & SetSigma(double Sigma)
Definition: sitkGradientMagnitudeRecursiveGaussianImageFilter.h:60
itk::simple::WriteImage
SITKIO_EXPORT void WriteImage(const Image &image, const std::string &fileName, bool useCompression=false, int compressionLevel=-1)
WriteImage is a procedural interface to the ImageFileWriter. class which is convenient for many image...
itk::simple::ReadImage
SITKIO_EXPORT Image ReadImage(const std::string &filename, PixelIDValueEnum outputPixelType=sitkUnknown, const std::string &imageIO="")
ReadImage is a procedural interface to the ImageFileReader class which is convenient for most image r...
itk::simple::CurvatureAnisotropicDiffusionImageFilter
Definition: sitkCurvatureAnisotropicDiffusionImageFilter.h:60
itk::simple::FastMarchingImageFilter::Execute
Image Execute(const Image &image1)
itk::simple::FastMarchingImageFilter::SetStoppingValue
Self & SetStoppingValue(double StoppingValue)
Definition: sitkFastMarchingImageFilter.h:112
itk::simple::CurvatureAnisotropicDiffusionImageFilter::SetNumberOfIterations
Self & SetNumberOfIterations(uint32_t NumberOfIterations)
Definition: sitkCurvatureAnisotropicDiffusionImageFilter.h:101
itk::simple
Definition: sitkAdditionalProcedures.h:29
itk::simple::SigmoidImageFilter::SetBeta
Self & SetBeta(double Beta)
Definition: sitkSigmoidImageFilter.h:71