SimpleITK  2.0.0
Segmentation/NeighborhoodConnectedImageFilter.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.
*
*=========================================================================*/
#if defined(_MSC_VER)
#pragma warning ( disable : 4786 )
#endif
#include "sitkImage.h"
#include <stdlib.h>
#include <iostream>
namespace sitk = itk::simple;
int main( int argc, char *argv[])
{
//
// Check command line parameters
//
if( argc < 7 )
{
std::cerr << "Missing Parameters " << std::endl;
std::cerr << "Usage: " << argv[0];
std::cerr << " inputImage outputImage lowerThreshold upperThreshold seedX seedY [seed2X seed2Y ... ]" << std::endl;
return 1;
}
//
// Read the image
//
reader.SetFileName( std::string( argv[1] ) );
sitk::Image image = reader.Execute();
//
// Set up writer
//
writer.SetFileName( std::string( argv[2] ) );
//
// Blur using CurvatureFlowImageFilter
//
blurFilter.SetNumberOfIterations( 5 );
blurFilter.SetTimeStep( 0.125 );
image = blurFilter.Execute( image );
//
// Set up NeighborhoodConnectedImageFilter for segmentation
//
segmentationFilter.SetLower( atof( argv[3] ) );
segmentationFilter.SetUpper( atof( argv[4] ) );
segmentationFilter.SetReplaceValue( 255 );
std::vector<unsigned int> radius = { 2, 2 };
segmentationFilter.SetRadius( radius );
for (int i = 5; i+1 < argc; i+=2)
{
std::vector<unsigned int> seed = { (unsigned int) atoi(argv[i]), (unsigned int) atoi(argv[i+1]) };
segmentationFilter.AddSeed(seed);
std::cout << "Adding a seed at ";
for( unsigned int j = 0; j < seed.size(); ++j )
{
std::cout << seed[j] << " ";
}
std::cout << std::endl;
}
sitk::Image outImage = segmentationFilter.Execute(image);
//
// Write out the resulting file
//
writer.Execute(outImage);
return 0;
}
itk::simple::Image
The Image class for SimpleITK.
Definition: sitkImage.h:75
itk::simple::CurvatureFlowImageFilter::Execute
Image Execute(Image &&image1)
itk::simple::NeighborhoodConnectedImageFilter::SetReplaceValue
Self & SetReplaceValue(double ReplaceValue)
Definition: sitkNeighborhoodConnectedImageFilter.h:108
itk::simple::NeighborhoodConnectedImageFilter
Label pixels that are connected to a seed and lie within a neighborhood.
Definition: sitkNeighborhoodConnectedImageFilter.h:42
itk::simple::NeighborhoodConnectedImageFilter::Execute
Image Execute(const Image &image1)
itk::simple::ImageFileWriter::SetFileName
Self & SetFileName(const std::string &fileName)
itk::simple::NeighborhoodConnectedImageFilter::SetRadius
Self & SetRadius(std::vector< unsigned int > Radius)
Definition: sitkNeighborhoodConnectedImageFilter.h:95
sitkImageFileWriter.h
sitkImage.h
itk::simple::ImageFileWriter::Execute
Self & Execute(const Image &)
itk::simple::ImageFileReader
Read an image file and return a SimpleITK Image.
Definition: sitkImageFileReader.h:60
itk::simple::ImageFileReader::SetFileName
Self & SetFileName(const std::string &fn)
itk::simple::CurvatureFlowImageFilter
Denoise an image using curvature driven flow.
Definition: sitkCurvatureFlowImageFilter.h:72
itk::simple::CurvatureFlowImageFilter::SetNumberOfIterations
Self & SetNumberOfIterations(uint32_t NumberOfIterations)
Definition: sitkCurvatureFlowImageFilter.h:99
itk::simple::CurvatureFlowImageFilter::SetTimeStep
Self & SetTimeStep(double TimeStep)
Definition: sitkCurvatureFlowImageFilter.h:90
sitkImageFileReader.h
itk::simple::NeighborhoodConnectedImageFilter::SetLower
Self & SetLower(double Lower)
Definition: sitkNeighborhoodConnectedImageFilter.h:75
itk::simple::NeighborhoodConnectedImageFilter::AddSeed
Self & AddSeed(std::vector< unsigned int > point)
Add SeedList point.
Definition: sitkNeighborhoodConnectedImageFilter.h:67
sitkCurvatureFlowImageFilter.h
itk::simple::ImageFileReader::Execute
Image Execute() override
Set/Get The output PixelType of the image.
itk::simple
Definition: sitkAdditionalProcedures.h:29
itk::simple::NeighborhoodConnectedImageFilter::SetUpper
Self & SetUpper(double Upper)
Definition: sitkNeighborhoodConnectedImageFilter.h:85
sitkNeighborhoodConnectedImageFilter.h
itk::simple::ImageFileWriter
Write out a SimpleITK image to the specified file location.
Definition: sitkImageFileWriter.h:48