29 : m_MakeOutputBinary(true), m_TimeStep(0), m_ReferenceImage(nullptr)
33 Superclass::SetNumberOfRequiredInputs(1);
34 Superclass::SetNumberOfRequiredOutputs(1);
35 Superclass::SetNthOutput(0, output);
55 itkDebugMacro(<<
"GenerateOutputInformation()");
57 if ((m_ReferenceImage ==
nullptr) || (m_ReferenceImage->IsInitialized() ==
false) ||
58 (m_ReferenceImage->GetTimeGeometry() ==
nullptr))
61 if (m_MakeOutputBinary)
63 output->Initialize(mitk::MakeScalarPixelType<unsigned char>(), *m_ReferenceImage->GetTimeGeometry(), 1, 1);
67 output->Initialize(m_ReferenceImage->GetPixelType(), *m_ReferenceImage->GetTimeGeometry());
70 output->SetPropertyList(m_ReferenceImage->GetPropertyList()->Clone());
80 itkDebugMacro(
"MakeOutput(" << name <<
")");
81 if (this->IsIndexedOutputName(name))
83 return this->MakeOutput(this->MakeIndexFromOutputName(name));
90 if (this->GetNumberOfInputs() < 1)
101 this->ProcessObject::SetNthInput(0, const_cast<mitk::ContourModelSet *>(input));
106 m_ReferenceImage = refImage;
111 return m_ReferenceImage;
123 this->InitializeOutputEmpty();
127 if (outputImage.IsNull() || outputImage->IsInitialized() ==
false || !outputImage->IsVolumeSet(m_TimeStep))
129 MITK_ERROR <<
"Error creating output for specified image!";
146 extractor->SetInput(outputImage);
147 extractor->SetTimeStep(m_TimeStep);
148 extractor->SetResliceTransformByGeometry(outputImageGeo);
151 auto it = contourSet->
Begin();
152 auto end = contourSet->
End();
165 bool isFrontside =
true;
166 bool isRotated =
false;
179 sliceIndex = point3D[0];
184 sliceIndex = point3D[1];
189 sliceIndex = point3D[2];
195 <<
"Cannot detect correct slice number! Only axial, sagittal and frontal oriented contours are supported!";
200 plane->InitializeStandardPlane(outputImageGeo, orientation, sliceIndex, isFrontside, isRotated);
201 point3D = plane->GetOrigin();
202 normal = plane->GetNormal();
204 point3D += normal * 0.5;
205 plane->SetOrigin(point3D);
208 extractor->SetWorldGeometry(plane);
209 extractor->SetVtkOutputRequest(
false);
210 reslice->SetOverwriteMode(
false);
212 extractor->Modified();
215 slice = extractor->GetOutput();
216 slice->DisconnectPipeline();
224 reslice->SetInputSlice(slice->GetVtkImageData());
227 reslice->SetOverwriteMode(
true);
230 extractor->Modified();
233 reslice->SetInputSlice(
nullptr);
241 outputImage->Modified();
242 outputImage->GetVtkImageData()->Modified();
253 for (
unsigned int dim = 0; dim < output->
GetDimension(); ++dim)
260 memset(writeAccess.GetData(), 0, byteSize);
265 for (
unsigned int dim = 0; dim < 3; ++dim)
270 for (
unsigned int volumeNumber = 0; volumeNumber < output->
GetDimension(3); volumeNumber++)
274 memset(writeAccess.GetData(), 0, byteSize);
void Progress(unsigned int steps=1)
Sets the current amount of progress to current progress + steps.
const mitk::ContourModelSet * GetInput(void)
const mitk::Image * GetImage(void)
void InitializeOutputEmpty()
Initializes the volume of the output image with zeros.
itk::DataObject::DataObjectIdentifierType DataObjectIdentifierType
ContourModel is a structure of linked vertices defining a contour in 3D space. The vertices are store...
itk::SmartPointer< Self > Pointer
mitk::Point3D Coordinates
Coordinates in 3D space.
static void FillContourInSlice(ContourModel *projectedContour, Image *sliceImage, mitk::Image::Pointer workingImage, int paintingPixelValue=1)
Fill a contour in a 2D slice with a specified pixel value at time step 0.
virtual void GenerateOutputInformation() override
virtual itk::DataObject::Pointer MakeOutput(DataObjectPointerArraySizeType idx) override
virtual void GenerateData() override
A version of GenerateData() specific for image processing filters.
virtual ContourModelSetIterator Begin()
Return an iterator a the front.
virtual ContourModelSetIterator End()
Return an iterator a the front.
virtual ImageDataItemPointer GetVolumeData(int t=0, int n=0, void *data=nullptr, ImportMemoryManagementType importMemoryManagement=CopyMemory) const
static ProgressBar * GetInstance()
static method to get the GUI dependent ProgressBar-instance so the methods for steps to do and progre...
ContourModelSetToImageFilter()
vcl_size_t GetSize() const
Get size of the PixelType in bytes.
ContourModelListType * GetContourModelList()
Returns the container of the contours.
Image class for storing images.
static ContourModel::Pointer ProjectContourTo2DSlice(Image *slice, ContourModel *contourIn3D, bool correctionForIpSegmentation, bool constrainToInside)
Projects a contour onto an image point by point. Converts from world to index coordinates.
const mitk::PixelType GetPixelType(int n=0) const
Returns the PixelType of channel n.
void SetImage(const mitk::Image *refImage)
Set the image which will be used to initialize the output of this filter.
void GenerateTimeInInputRegion(const mitk::TimeGeometry *outputTimeGeometry, const TOutputRegion &outputRegion, const mitk::TimeGeometry *inputTimeGeometry, TInputRegion &inputRegion)
virtual void SetInput(const mitk::ContourModelSet *input)
void AddStepsToDo(unsigned int steps)
Adds steps to totalSteps.
MITKNEWMODULE_EXPORT bool Equal(mitk::ExampleDataStructure *leftHandSide, mitk::ExampleDataStructure *rightHandSide, mitk::ScalarType eps, bool verbose)
Returns true if the example data structures are considered equal.
virtual bool IsInitialized() const
Check whether the data has been initialized, i.e., at least the Geometry and other header data has be...
virtual ~ContourModelSetToImageFilter()
virtual void GenerateInputRequestedRegion() override
ImageWriteAccessor class to get locked write-access for a particular image part.
unsigned int GetDimension() const
Get dimension of the image.
BaseGeometry Describes the geometry of a data object.
virtual const VertexType * GetVertexAt(int index, int timestep=0) const
Returns the vertex at the index position within the container.
void WorldToIndex(const mitk::Point3D &pt_mm, mitk::Point3D &pt_units) const
Convert world coordinates (in mm) of a point to (continuous!) index coordinates.
int GetNumberOfVertices(int timestep=0) const
Returns the number of vertices at a given timestep.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.