[Insight-developers] Possible PasteImageFilter bug
Jim Miller
millerjv at gmail.com
Tue Sep 21 22:04:48 EDT 2010
I will have to look at the implementation of the PasteImageFilter but I expect it is performing as designed. It operates like the ITK filters in that it takes a set of inputs and produces a set of outputs.
If it were an InPlace filter and the proper pixel type constraints were met then it would not be necessary to grab the output of the paste filter to get the mixture of your two images.
Jim
On Sep 21, 2010, at 12:30 PM, Barry Branham <bhb at branham.ws> wrote:
> 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
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-developers
More information about the Insight-developers
mailing list