Advertisement
Guest User

Untitled

a guest
Mar 30th, 2015
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1.                     template<typename TImage,typename TPointSet>
  2.                     void convertITKImageToPointSet( typename const TImage::Pointer fImage,
  3.                         typename const TImage::PixelType forgroundValue,
  4.                         typename TPointSet::Pointer fOutputPointSet)
  5.                     {
  6.                         fOutputPointSet = TPointSet::New();
  7.                         TPointSet::PointType tempPoint;
  8.                         itk::ImageRegionConstIterator<TImage> imageIterator(fImage,fImage->GetLargestPossibleRegion());
  9.                         int numberOfPts = 0;
  10.                         for (auto it = imageIterator.Begin();it != imageIterator.End();++it)
  11.                         {
  12.                             if (it.Value() == forgroundValue)
  13.                             {
  14.                                 fImage->TransformIndexToPhysicalPoint(it.GetIndex(),tempPoint);
  15.                                 fOutputPointSet->SetPoint(numberOfPts,tempPoint);
  16.                                 numberOfPts++;
  17.                             }
  18.                         }
  19.                     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement