[Insight-users] AddImageFilter problem...

Sergio Andres sergio at unizar.es
Tue, 17 Feb 2004 12:23:36 +0100


Hi all,

I have a problem with itk::AddImageFilter.
When Update() is called I get an error.

My code is like this:

...   
    // typedefs
    typedef uzImage<unsigned char, 2> UCharImageType;
    typedef uzImage<double, 2> DoubleImageType;

    typedef uzImageWriter<UCharImageType> UCharImageWriterType;

    typedef itk::RescaleIntensityImageFilter<DoubleImageType, 
UCharImageType> RescaleFilter;
    typedef itk::AddImageFilter<DoubleImageType, DoubleImageType, 
DoubleImageType> AddImageFilterType;

    // writer
    UCharImageWriterType::Pointer imageWriter = UCharImageWriterType::New();

    // rescale filter
    RescaleFilter::Pointer rescaleFilter = RescaleFilter::New();
    rescaleFilter->SetOutputMaximum(255);
    rescaleFilter->SetOutputMinimum(0);

    // add filter
    AddImageFilterType::Pointer addFilter = AddImageFilterType::New();

    addFilter->SetInput1(outputImages[0]);
    addFilter->SetInput1(outputImages[1]);
    addFilter->Update();    // this produces an error....***

    DoubleImageType::Pointer outputImage;
    outputImage = addFilter->GetOutput();

    rescaleFilter->SetInput(outputImage.GetPointer());

    imageWriter->SetFileName(fileName);
    imageWriter->SetInput(rescaleFilter->GetOutput());
    imageWriter->Update();
...

I will appreciate any suggestion ...

Thanks in advance,

Sergio.