15 #include <itkImageRegionIteratorWithIndex.h> 19 this->SetNumberOfRequiredInputs(1);
40 typedef itk::Image<unsigned char, 3> itkImageType;
43 outputImage->Initialize(inputImage);
45 itkImageType::Pointer itkImage;
47 itkImage->FillBuffer(0);
55 mitk::BoundingBox::Pointer boToIm =
56 boGeometry->CalculateBoundingBoxRelativeToTransform(inputImageGeometry->GetIndexToWorldTransform());
58 mitk::BoundingBox::ConstPointer imgBB = inputImageGeometry->GetBoundingBox();
59 mitk::BoundingBox::PointType minImg = imgBB->GetMinimum();
60 mitk::BoundingBox::PointType maxImg = imgBB->GetMaximum();
62 itkImageType::IndexType boIndex;
63 itkImageType::SizeType boSize;
65 mitk::BoundingBox::PointType
min = boToIm->GetMinimum();
66 mitk::BoundingBox::PointType
max = boToIm->GetMaximum();
69 for (
int i = 0; i < 3; i++)
71 if (min[i] < minImg[i])
73 if (max[i] < minImg[i])
75 if (max[i] > maxImg[i])
77 if (min[i] > maxImg[i])
78 min[i] = maxImg[i] - 1;
82 boIndex[0] = (mitk::SlicedData::IndexType::IndexValueType)(min[0] + 0.5);
83 boIndex[1] = (mitk::SlicedData::IndexType::IndexValueType)(min[1] + 0.5);
84 boIndex[2] = (mitk::SlicedData::IndexType::IndexValueType)(min[2] + 0.5);
87 boSize[0] = (mitk::SlicedData::IndexType::IndexValueType)(max[0] - min[0]);
88 boSize[1] = (mitk::SlicedData::IndexType::IndexValueType)(max[1] - min[1]);
89 boSize[2] = (mitk::SlicedData::IndexType::IndexValueType)(max[2] - min[2]);
91 itkImageType::RegionType region(boIndex, boSize);
94 itk::ImageRegionIteratorWithIndex<itkImageType> itBoundingObject =
95 itk::ImageRegionIteratorWithIndex<itkImageType>(itkImage, region);
96 itBoundingObject.GoToBegin();
98 while (!itBoundingObject.IsAtEnd())
100 itkImageType::IndexType index = itBoundingObject.GetIndex();
105 inputImageGeometry->IndexToWorld(p, p);
107 if (boundingObject->IsInside(p) && boundingObject->GetPositive())
108 itBoundingObject.Set(1);
109 else if (boundingObject->IsInside(p) && !boundingObject->GetPositive())
110 itBoundingObject.Set(0);
void GenerateData() override
~BoundingObjectToSegmentationFilter() override
group object, that contains several mitk::BoundingObjects
mitk::BoundingObjectGroup::Pointer m_boundingObjectGroup
InputImageType * GetInput(void)
void SetBoundingObject(mitk::BoundingObject::Pointer boundingObject)
void CastToMitkImage(const itk::SmartPointer< ItkOutputImageType > &itkimage, itk::SmartPointer< mitk::Image > &mitkoutputimage)
Cast an itk::Image (with a specific type) to an mitk::Image.
void MITKCORE_EXPORT CastToItkImage(const mitk::Image *mitkImage, itk::SmartPointer< ItkOutputImageType > &itkOutputImage)
Cast an mitk::Image to an itk::Image with a specific type.
BoundingObjectToSegmentationFilter()
OutputType * GetOutput()
Get the output data of this image source object.