19 #include <itkImageRegionIteratorWithIndex.h>
23 this->SetNumberOfRequiredInputs(1);
34 m_boundingObjectGroup = testgroup;
38 m_boundingObjectGroup->AddBoundingObject(boundingObject);
44 typedef itk::Image<unsigned char, 3> itkImageType;
47 outputImage->Initialize(inputImage);
51 itkImage->FillBuffer(0);
53 for (
unsigned int i = 0; i < m_boundingObjectGroup->GetCount(); i++)
60 boGeometry->CalculateBoundingBoxRelativeToTransform(inputImageGeometry->GetIndexToWorldTransform());
66 itkImageType::IndexType boIndex;
67 itkImageType::SizeType boSize;
73 for (
int i = 0; i < 3; i++)
75 if (min[i] < minImg[i])
77 if (max[i] < minImg[i])
79 if (max[i] > maxImg[i])
81 if (min[i] > maxImg[i])
82 min[i] = maxImg[i] - 1;
86 boIndex[0] = (mitk::SlicedData::IndexType::IndexValueType)(min[0] + 0.5);
87 boIndex[1] = (mitk::SlicedData::IndexType::IndexValueType)(min[1] + 0.5);
88 boIndex[2] = (mitk::SlicedData::IndexType::IndexValueType)(min[2] + 0.5);
91 boSize[0] = (mitk::SlicedData::IndexType::IndexValueType)(max[0] - min[0]);
92 boSize[1] = (mitk::SlicedData::IndexType::IndexValueType)(max[1] - min[1]);
93 boSize[2] = (mitk::SlicedData::IndexType::IndexValueType)(max[2] - min[2]);
95 itkImageType::RegionType region(boIndex, boSize);
98 itk::ImageRegionIteratorWithIndex<itkImageType> itBoundingObject =
99 itk::ImageRegionIteratorWithIndex<itkImageType>(itkImage, region);
100 itBoundingObject.GoToBegin();
102 while (!itBoundingObject.IsAtEnd())
104 itkImageType::IndexType index = itBoundingObject.GetIndex();
109 inputImageGeometry->IndexToWorld(p, p);
111 if (boundingObject->IsInside(p) && boundingObject->GetPositive())
112 itBoundingObject.Set(1);
113 else if (boundingObject->IsInside(p) && !boundingObject->GetPositive())
114 itBoundingObject.Set(0);
itk::SmartPointer< Self > Pointer
virtual ~BoundingObjectToSegmentationFilter()
virtual void GenerateData() override
A version of GenerateData() specific for image processing filters.
itk::SmartPointer< const Self > ConstPointer
group object, that contains several mitk::BoundingObjects
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()