[Insight-developers] two-input filters don't work

Michael Xanadu xanadu.michael at googlemail.com
Fri Sep 18 06:32:03 EDT 2009


Yes, that is something that I want. But I also tried to get some other
segments and changed the seedpoint (for example the two bags left and right
of the image). I just finished trying to use the pipeline like you wanted me
to do. I put the output of sigmoid to the input of fast marching and removed
setting speed constant and output size. But like I wrote in my last mail,
the application crashes when the fast marching filter is arrived (i can see
that because of the output images I create after each filter step). An
"unhandled exception" occurs in the file "free.c".
Furthermore, I subtracted a constant from fastMarching, like you said. I
tried setIsoSurfaceValue and a negative seed value, but the error still
occurs. I wanted to use "itkSubtractConstantFromImageFilter.h" but couldn't
include it, because the compiler doesn't know it anyway?!

I will keep trying to solve the problem, but can you take a look at my code
in the meantime? Maybe you see something.

Regards, Michael




const double initialDistance = 5.0; // for seed Value
const double sigma = 1.0;
const double alpha = -0.3;
const double beta  = 2.0;
const double curvatureScaling   = 0.05;
const double propagationScaling = 1.0;

typedef unsigned char OutputPixelType;
typedef float InternalPixelType;
typedef short ShortPixelType;
const unsigned int Dimension = 3;

typedef itk::Image<InternalPixelType, Dimension> InternalImageType;
typedef itk::Image<OutputPixelType, Dimension> OutputImageType;
typedef itk::Image<ShortPixelType, Dimension> ShortImageType;
typedef itk::ImageFileWriter<OutputImageType> WriterType;

WriterType::Pointer writer = WriterType::New();
writer->SetFileName("c://ShapeDetectionLevelSetFilterDicomOutput6.png");

typedef itk::CurvatureAnisotropicDiffusionImageFilter <ShortImageType,
InternalImageType> SmoothingFilterType;
typedef itk::GradientMagnitudeRecursiveGaussianImageFilter
<InternalImageType, InternalImageType> GradientFilterType;
typedef itk::SigmoidImageFilter <InternalImageType, InternalImageType>
SigmoidFilterType;
typedef itk::FastMarchingImageFilter <InternalImageType, InternalImageType>
FastMarchingFilterType;
typedef itk::ShapeDetectionLevelSetImageFilter <InternalImageType,
InternalImageType> ShapeDetectionFilterType;
typedef itk::BinaryThresholdImageFilter <InternalImageType, OutputImageType>
ThresholdingFilterType;

typedef itk::RescaleIntensityImageFilter<ShortImageType, OutputImageType>
CastFilterType0;
typedef itk::RescaleIntensityImageFilter<InternalImageType, OutputImageType>
CastFilterType;

ThresholdingFilterType::Pointer thresholder = ThresholdingFilterType::New();
SmoothingFilterType::Pointer smoothing = SmoothingFilterType::New();
GradientFilterType::Pointer gradientMagnitude = GradientFilterType::New();
SigmoidFilterType::Pointer sigmoid = SigmoidFilterType::New();
FastMarchingFilterType::Pointer fastMarching =
FastMarchingFilterType::New();
ShapeDetectionFilterType::Pointer shapeDetection =
ShapeDetectionFilterType::New();

smoothing->SetInput(m_Dicomreader->GetITKOutput());
gradientMagnitude->SetInput(smoothing->GetOutput());
sigmoid->SetInput(gradientMagnitude->GetOutput());
fastMarching->SetInput(sigmoid->GetOutput());
shapeDetection->SetInput(fastMarching->GetOutput());
shapeDetection->SetFeatureImage( sigmoid->GetOutput());
thresholder->SetInput(shapeDetection->GetOutput());
writer->SetInput(thresholder->GetOutput());

smoothing->SetTimeStep(0.0625);
smoothing->SetNumberOfIterations(5);
smoothing->SetConductanceParameter(9.0);

gradientMagnitude->SetSigma(sigma);

sigmoid->SetAlpha(alpha);
sigmoid->SetBeta(beta);
sigmoid->SetOutputMinimum(0.0);
sigmoid->SetOutputMaximum(1.0);

InternalImageType::IndexType  seedPosition;
seedPosition[0] = 252;
seedPosition[1] = 292;
seedPosition[2] = 0;

typedef FastMarchingFilterType::NodeContainer NodeContainer;
typedef FastMarchingFilterType::NodeType NodeType;

NodeType node;
const double seedValue = - initialDistance; //make value negative
node.SetValue( seedValue );
node.SetIndex( seedPosition );

NodeContainer::Pointer seeds = NodeContainer::New();
seeds->Initialize();
seeds->InsertElement( 0, node );

fastMarching->SetTrialPoints(  seeds  );
//fastMarching->SetSpeedConstant( 1.0 );
//shapeDetection->SetIsoSurfaceValue(a value);

CastFilterType0::Pointer caster0 = CastFilterType0::New();
CastFilterType::Pointer caster1 = CastFilterType::New();
CastFilterType::Pointer caster2 = CastFilterType::New();
CastFilterType::Pointer caster3 = CastFilterType::New();
CastFilterType::Pointer caster4 = CastFilterType::New();
CastFilterType::Pointer caster5 = CastFilterType::New();

WriterType::Pointer writer0 = WriterType::New();
WriterType::Pointer writer1 = WriterType::New();
WriterType::Pointer writer2 = WriterType::New();
WriterType::Pointer writer3 = WriterType::New();
WriterType::Pointer writer4 = WriterType::New();
WriterType::Pointer writer5 = WriterType::New();

caster0->SetInput( this->m_Dicomreader->GetITKOutput() );
writer0->SetInput( caster0->GetOutput() );
writer0->SetFileName("c://ShapeDetectionLevelSetFilterDicomOutput0.png");
caster0->SetOutputMinimum(   0 );
caster0->SetOutputMaximum( 255 );
writer0->Update();

caster1->SetInput( smoothing->GetOutput() );
writer1->SetInput( caster1->GetOutput() );
writer1->SetFileName("c://ShapeDetectionLevelSetFilterDicomOutput1.png");
caster1->SetOutputMinimum(   0 );
caster1->SetOutputMaximum( 255 );
writer1->Update();

caster2->SetInput( gradientMagnitude->GetOutput() );
writer2->SetInput( caster2->GetOutput() );
writer2->SetFileName("c://ShapeDetectionLevelSetFilterDicomOutput2.png");
caster2->SetOutputMinimum(   0 );
caster2->SetOutputMaximum( 255 );
writer2->Update();

caster3->SetInput( sigmoid->GetOutput() );
writer3->SetInput( caster3->GetOutput() );
writer3->SetFileName("c://ShapeDetectionLevelSetFilterDicomOutput3.png");
caster3->SetOutputMinimum(   0 );
caster3->SetOutputMaximum( 255 );
writer3->Update();

caster4->SetInput( fastMarching->GetOutput() );
writer4->SetInput( caster4->GetOutput() );
writer4->SetFileName("c://ShapeDetectionLevelSetFilterDicomOutput4.png");
caster4->SetOutputMinimum(   0 );
caster4->SetOutputMaximum( 255 );

caster5->SetInput( shapeDetection->GetOutput() );
writer5->SetInput( caster5->GetOutput() );
writer5->SetFileName("c://ShapeDetectionLevelSetFilterDicomOutput5.png");
caster5->SetOutputMinimum(   0 );
caster5->SetOutputMaximum( 255 );

//fastMarching->SetOutputSize(
m_Dicomreader->GetITKOutput()->GetBufferedRegion().GetSize() );

shapeDetection->SetPropagationScaling(  propagationScaling );
shapeDetection->SetCurvatureScaling( curvatureScaling );
shapeDetection->SetMaximumRMSError( 0.02 );
shapeDetection->SetNumberOfIterations( 800 );

thresholder->SetLowerThreshold(-1000.0);
thresholder->SetUpperThreshold(0.0);
thresholder->SetOutsideValue(0);
thresholder->SetInsideValue(255);

writer->Update();
writer4->Update();
writer5->Update();











2009/9/17 Kevin H. Hobbs <hobbsk at ohiou.edu>

> On Thu, 2009-09-17 at 18:10 +0200, Michael Xanadu wrote:
> > In step 9 of your mail you said to put the output of sigmoid to the
> > input of fastMarching. That made me stunning, because in the examples
> > of two-input-filters (i.g. itk manual page 542) fastMarching never has
> > an input. Is it a failure or did you do so on purpose?
>
> I said that on purpose.
>
> The examples use fast marching only as a very rough initialization for
> the other filters. It produces only a circle of about the right radius
> centered on the object to be segmented.
>
> The fast marching filter can either advance through the image at a
> constant speed, essentially labeling every pixel with its distance from
> the seed point, or it can advance with a speed equal to the value of an
> input image at each point.
>
> This behavior is controlled by :
>
> giving the filter no input image, setting the size of the output image,
> and setting a speed constant
>
> OR
>
> giving the filter an input image.
>
> From your image "4 fast Marching.PNG" I can see that constant speed was
> used. Don't use it.
>
> Also don't set the output size.
>
> It's not that there is anything wrong with using constant speed for fast
> marching, it's just that you clearly do not have your feature image
> quite right yet and we need to get that fixed before we can move on.
>
> Now from looking at your image "3 sigmoid.PNG" it looks like you could
> get regions like those I've highlighted with the GIMP from the fast
> marching filter ( some of these will likely merge if the input is 3D )
> is that what you want?
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/mailman/private/insight-developers/attachments/20090918/0666a749/attachment.htm>


More information about the Insight-developers mailing list