# An error with curvature flow filter code

**URL:** https://discourse.itk.org/t/an-error-with-curvature-flow-filter-code/2977
**Category:** Beginner Questions
**Created:** [April 20, 2020, 6:08pm UTC](https://discourse.itk.org/t/an-error-with-curvature-flow-filter-code/2977 "2020-04-20T18:08:15Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![basal](https://discourse.itk.org/letter_avatar_proxy/v4/letter/b/a8b319/32.png) [@basal](https://discourse.itk.org/u/basal)
#### Post date: [April 20, 2020, 6:08pm UTC](https://discourse.itk.org/t/an-error-with-curvature-flow-filter-code/2977/1 "2020-04-20T18:08:16Z")

</div>

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

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

```

Does any one know what is the problem?

```auto
#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;
}

```

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [April 20, 2020, 6:36pm UTC](https://discourse.itk.org/t/an-error-with-curvature-flow-filter-code/2977/2 "2020-04-20T18:36:49Z")

</div>

> [@basal](#):
>
> typedef itk::ImageFileWriter TImageWriter;

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.

---

<div class="post-metadata">

### Author: ![basal](https://discourse.itk.org/letter_avatar_proxy/v4/letter/b/a8b319/32.png) [@basal](https://discourse.itk.org/u/basal)
#### Post date: [April 20, 2020, 7:58pm UTC](https://discourse.itk.org/t/an-error-with-curvature-flow-filter-code/2977/3 "2020-04-20T19:58:13Z")

</div>

It works, thanks.
