ITK/Examples/Smoothing/CurvatureFlowImageFilter: Difference between revisions

From KitwarePublic
< ITK‎ | Examples
Jump to navigationJump to search
(Deprecated content that is moved to sphinx)
 
(4 intermediate revisions by one other user not shown)
Line 1: Line 1:
==CurvatureFlowImageFilter.cxx==
{{warning|1=The media wiki content on this page is no longer maintained. The examples presented on the https://itk.org/Wiki/* pages likely require ITK version 4.13 or earlier releases.   In many cases, the examples on this page no longer conform to the best practices for modern ITK versions.}}
<source lang="cpp">
#include "itkImage.h"
#include "itkCastImageFilter.h"
#include "itkCurvatureFlowImageFilter.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
 
int main( int argc, char *argv[])
{
  if( argc < 3 )
  {
    std::cerr << "Missing Parameters " << std::endl;
    std::cerr << "Usage: " << argv[0];
    std::cerr << " inputImage  outputImage" << std::endl;
    return 1;
  }
 
  typedef  float          InternalPixelType;
  typedef unsigned char    ExternalPixelType;
  const    unsigned int    Dimension = 2;
  typedef itk::Image< InternalPixelType, Dimension > InternalImageType;
  typedef itk::Image< ExternalPixelType, Dimension >  ExternalImageType;
 
  typedef  itk::ImageFileReader< InternalImageType > ReaderType;
  typedef itk::ImageFileWriter< ExternalImageType  > WriterType;
 
   ReaderType::Pointer reader = ReaderType::New();
  WriterType::Pointer writer = WriterType::New();
 
  reader->SetFileName( argv[1] );
  writer->SetFileName( argv[2] );
 
  typedef itk::CurvatureFlowImageFilter< InternalImageType, InternalImageType >CurvatureFlowImageFilterType;
 
  CurvatureFlowImageFilterType::Pointer smoothing = CurvatureFlowImageFilterType::New();
 
  smoothing->SetInput( reader->GetOutput() );
 
  typedef itk::CastImageFilter< InternalImageType, ExternalImageType > CastingFilterType;
  CastingFilterType::Pointer caster = CastingFilterType::New();
 
  caster->SetInput( smoothing->GetOutput() );
  writer->SetInput( caster->GetOutput() );
 
  smoothing->SetNumberOfIterations( 5 );
  smoothing->SetTimeStep( 0.125 );
 
  writer->Update();
 
  return 0;
}
</source>
 
==CMakeLists.txt==
<source lang="cmake">
cmake_minimum_required(VERSION 2.6)
 
PROJECT(CurvatureFlowImageFilter)
 
FIND_PACKAGE(ITK REQUIRED)
INCLUDE(${ITK_USE_FILE})
 
ADD_EXECUTABLE(CurvatureFlowImageFilter CurvatureFlowImageFilter.cxx)
TARGET_LINK_LIBRARIES(CurvatureFlowImageFilter ITKIO)
 
 
</source>

Latest revision as of 17:13, 6 June 2019

Warning: The media wiki content on this page is no longer maintained. The examples presented on the https://itk.org/Wiki/* pages likely require ITK version 4.13 or earlier releases. In many cases, the examples on this page no longer conform to the best practices for modern ITK versions.