An error with curvature flow filter code

Hi,
I wrote this code about curvature flow filter for 3D images but there is an error in this line:

	Writer->SetInput(Smoother->GetOutput());

Does any one know what is the problem?

#include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkCurvatureFlowImageFilter.h"
#include "itkConfidenceConnectedImageFilter.h"
#include "itkCastImageFilter.h"
#include "itkImageFileWriter.h"
#include "itkBinaryErodeImageFilter.h"
#include "itkBinaryDilateImageFilter.h"
#include "itkBinaryBallStructuringElement.h"
#include "itkVectorIndexSelectionCastImageFilter.h"
#include "itkSubtractImageFilter.h"
#include "itkCropImageFilter.h"
#include <itkMultiplyImageFilter.h>
#include <stdio.h>
#include "itkPointSet.h"
#include "itkBSplineScatteredDataPointSetToImageFilter.h"
#include <itkSliceBySliceImageFilter.h>
#include "itkImageRegion.h"
#include "itkImageRegionIterator.h"
#include "itkImageRegionIteratorWithIndex.h"
#include <itkBinaryFillholeImageFilter.h>
#include <itkGradientMagnitudeImageFilter.h>
#include <itkSignedDanielssonDistanceMapImageFilter.h>
#include <itkApproximateSignedDistanceMapImageFilter.h>
#include <itkStatisticsImageFilter.h>
#include <itkConnectedComponentImageFilter.h>
#include <itkRelabelComponentImageFilter.h>
#include "itkGradientRecursiveGaussianImageFilter.h"
#include <itkBinaryThresholdImageFilter.h>
#include <itkLaplacianRecursiveGaussianImageFilter.h>
#include <itkLaplacianImageFilter.h>
#include <itkImageSliceIteratorWithIndex.h>
#include "itkCannyEdgeDetectionImageFilter.h"
#include <math.h>       /* atan */
#include <stdio.h>
#include<iostream>
using namespace std;
#include <fstream>
#include <time.h>
#include <itkBinaryContourImageFilter.h>

#include <itkHausdorffDistanceImageFilter.h>
#include "itkContourMeanDistanceImageFilter.h"
#include <itkDirectedHausdorffDistanceImageFilter.h>
#include "itkLabelOverlapMeasuresImageFilter.h"

int main()
{

	//// "a" is the threshold value for segmenting the ribs 
	//// "b" is the lower threshold and "c" is the upper threshold value for segmenting the air 
	//// "d" is the number of image slices
	//// "e" is the number of slice which has the oval area

	typedef itk::Image<short, 3> TImage;
	typedef itk::Image<double, 3> TFloatImage;
	typedef itk::ImageFileReader<TImage> TImageReader;

	TImageReader::Pointer Reader = TImageReader::New();
	typedef itk::CurvatureFlowImageFilter<TImage, TFloatImage> TSmoother;


	TSmoother::Pointer Smoother = TSmoother::New();
	Reader->SetFileName("Descending-aorta.nrrd");

	Reader->Update();




	//// 2. CT Image Air Segmentation



	Smoother->SetInput(Reader->GetOutput());
	Smoother->SetNumberOfIterations(10);
	Smoother->SetTimeStep(0.0625);
	Smoother->Update();
	typedef itk::Image<short, 3> TImage;
	typedef itk::ImageFileWriter<TImage> TImageWriter;
	TImageWriter::Pointer Writer = TImageWriter::New();
	Writer->SetFileName("output.nrrd");

	Writer->SetInput(Smoother->GetOutput());
	

	Writer->Update();
	return EXIT_SUCCESS;
}

Writer should be of filter’s output type, like this:
typedef itk::ImageFileWriter<TFloatImage> TImageWriter;

That is because TSmoother takes TImage as input but produces TFloatImage as output.

1 Like

It works, thanks.