[Insight-developers] Possible PasteImageFilter bug

Barry Branham bhb at branham.ws
Tue Sep 21 12:30:15 EDT 2010


Hello,

I have a function which employs the ConfidenceConnectedImageFilter on a 
region of an image produced by the RegionOfInterestImageFilter.  I then 
employ the PasteImageFilter to paste 
ConfidenceConnectedFilter->GetOutput() into a zeroed full size image.

The output full size image (m_RegionImage) doesn't get the pasteFilter 
output unless I add the line:
m_RegionImage = pasteFilter->GetOutput();

It seems this shouldn't be necessary since I already had:
pasteFilter->SetDestinationImage( m_RegionImage);
and
pasteFilter->Update();

But it is.

Here's the relevant code snippet:

     m_ConfConImage = ConfidenceConnectedFilter->GetOutput();

     if ( !m_RegionImage)
     {
         m_RegionImage = LabelImageType::New();
         LabelImageType::RegionType region;
         region.SetSize( 
m_SmoothedImage->GetLargestPossibleRegion().GetSize());
         region.SetIndex( 
m_SmoothedImage->GetLargestPossibleRegion().GetIndex());
         m_RegionImage->SetRegions( region);
         m_RegionImage->Allocate();
     }
     m_RegionImage->FillBuffer( 0);
     m_RegionImage->Update();        // ?? do we need this?

     typedef itk::PasteImageFilter< LabelImageType, LabelImageType > 
PasteFilterType;
     PasteFilterType::Pointer pasteFilter = PasteFilterType::New();
     pasteFilter->SetSourceImage( m_ConfConImage);
     pasteFilter->SetDestinationImage( m_RegionImage);
     pasteFilter->SetDestinationIndex( region.GetIndex());
     pasteFilter->SetSourceRegion( m_ConfConImage->GetBufferedRegion());
     pasteFilter->Update();
//    m_RegionImage->Update();
     m_RegionImage = pasteFilter->GetOutput();

     // write m_RegionImage
     typedef itk::ImageFileWriter< LabelImageType >   WriterType;
     WriterType::Pointer writer = WriterType::New();
     writer->SetFileName( "RegionImage.jpg");
     writer->SetInput( m_RegionImage);
     try
     {
         writer->Update();
     }
     catch( itk::ExceptionObject & err )
     {
         std::cerr << "ExceptionObject caught !" << std::endl;
         std::cerr << err << std::endl;
         return;
     }

Thanks,
Barry Branham




More information about the Insight-developers mailing list