VMTK
Loading...
Searching...
No Matches
vtkvmtkGrayscaleMorphologyImageFilter Class Reference

Wraps itk::GrayscaleMorphologyImageFilter. More...

#include <vtkvmtkGrayscaleMorphologyImageFilter.h>

Inheritance diagram for vtkvmtkGrayscaleMorphologyImageFilter:
[legend]
Collaboration diagram for vtkvmtkGrayscaleMorphologyImageFilter:
[legend]

Public Types

enum  { DILATE , ERODE , CLOSE , OPEN }
typedef vtkSimpleImageToImageFilter Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkGrayscaleMorphologyImageFilter * NewInstance () const
void SetOperationToDilate ()
void SetOperationToErode ()
void SetOperationToClose ()
void SetOperationToOpen ()
virtual int * GetBallRadius ()
virtual void GetBallRadius (int data[3])
virtual void SetBallRadius (int data[])
virtual void SetOperation (int)
virtual int GetOperation ()

Static Public Member Functions

static vtkvmtkGrayscaleMorphologyImageFilter * New ()
static int IsTypeOf (const char *type)
static vtkvmtkGrayscaleMorphologyImageFilter * SafeDownCast (vtkObjectBase *o)

Protected Member Functions

virtual vtkObjectBase * NewInstanceInternal () const
 vtkvmtkGrayscaleMorphologyImageFilter ()
 ~vtkvmtkGrayscaleMorphologyImageFilter ()
virtual void SimpleExecute (vtkImageData *input, vtkImageData *output) override
virtual int RequestInformation (vtkInformation *vtkNotUsed(request), vtkInformationVector **inputVector, vtkInformationVector *outputVector) override

Protected Attributes

int BallRadius [3]
int Operation

Detailed Description

Wraps itk::GrayscaleMorphologyImageFilter.

Applies a grayscale morphological operation (dilate, erode, or their compositions close/open) to the input image using a ball-shaped structuring element of radius BallRadius (in voxels, one value per axis). Used e.g. to clean up or fill small gaps in a segmented/thresholded image.

Definition at line 38 of file vtkvmtkGrayscaleMorphologyImageFilter.h.

Member Typedef Documentation

◆ Superclass

typedef vtkSimpleImageToImageFilter vtkvmtkGrayscaleMorphologyImageFilter::Superclass

Definition at line 42 of file vtkvmtkGrayscaleMorphologyImageFilter.h.

Member Enumeration Documentation

◆ anonymous enum

Constructor & Destructor Documentation

◆ vtkvmtkGrayscaleMorphologyImageFilter()

vtkvmtkGrayscaleMorphologyImageFilter::vtkvmtkGrayscaleMorphologyImageFilter ( )
protected

◆ ~vtkvmtkGrayscaleMorphologyImageFilter()

vtkvmtkGrayscaleMorphologyImageFilter::~vtkvmtkGrayscaleMorphologyImageFilter ( )
protected

Definition at line 49 of file vtkvmtkGrayscaleMorphologyImageFilter.cxx.

50{
51}

Member Function Documentation

◆ New()

vtkvmtkGrayscaleMorphologyImageFilter * vtkvmtkGrayscaleMorphologyImageFilter::New ( )
static

◆ IsTypeOf()

int vtkvmtkGrayscaleMorphologyImageFilter::IsTypeOf ( const char * type)
static

◆ IsA()

virtual int vtkvmtkGrayscaleMorphologyImageFilter::IsA ( const char * type)
virtual

◆ SafeDownCast()

vtkvmtkGrayscaleMorphologyImageFilter * vtkvmtkGrayscaleMorphologyImageFilter::SafeDownCast ( vtkObjectBase * o)
static

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkGrayscaleMorphologyImageFilter::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkGrayscaleMorphologyImageFilter * vtkvmtkGrayscaleMorphologyImageFilter::NewInstance ( ) const

◆ GetBallRadius() [1/2]

virtual int * vtkvmtkGrayscaleMorphologyImageFilter::GetBallRadius ( )
virtual

Set/Get the radius, in voxels (one value per axis), of the ball-shaped structuring element used for the morphological operation. Default: (1,1,1).

◆ GetBallRadius() [2/2]

virtual void vtkvmtkGrayscaleMorphologyImageFilter::GetBallRadius ( int data[3])
virtual

Set/Get the radius, in voxels (one value per axis), of the ball-shaped structuring element used for the morphological operation. Default: (1,1,1).

◆ SetBallRadius()

virtual void vtkvmtkGrayscaleMorphologyImageFilter::SetBallRadius ( int data[])
virtual

Set/Get the radius, in voxels (one value per axis), of the ball-shaped structuring element used for the morphological operation. Default: (1,1,1).

◆ SetOperation()

virtual void vtkvmtkGrayscaleMorphologyImageFilter::SetOperation ( int )
virtual

Set/Get the morphological operation to apply: DILATE, ERODE (default), CLOSE (dilate then erode, fills small gaps/holes), or OPEN (erode then dilate, removes small protrusions). See also SetOperationToDilate / SetOperationToErode / SetOperationToClose / SetOperationToOpen.

◆ GetOperation()

virtual int vtkvmtkGrayscaleMorphologyImageFilter::GetOperation ( )
virtual

Set/Get the morphological operation to apply: DILATE, ERODE (default), CLOSE (dilate then erode, fills small gaps/holes), or OPEN (erode then dilate, removes small protrusions). See also SetOperationToDilate / SetOperationToErode / SetOperationToClose / SetOperationToOpen.

◆ SetOperationToDilate()

void vtkvmtkGrayscaleMorphologyImageFilter::SetOperationToDilate ( )
inline

Convenience method: set Operation to DILATE.

Definition at line 65 of file vtkvmtkGrayscaleMorphologyImageFilter.h.

66 { this->SetOperation(DILATE); }

◆ SetOperationToErode()

void vtkvmtkGrayscaleMorphologyImageFilter::SetOperationToErode ( )
inline

Convenience method: set Operation to ERODE (default).

Definition at line 70 of file vtkvmtkGrayscaleMorphologyImageFilter.h.

71 { this->SetOperation(ERODE); }

◆ SetOperationToClose()

void vtkvmtkGrayscaleMorphologyImageFilter::SetOperationToClose ( )
inline

Convenience method: set Operation to CLOSE (dilate then erode).

Definition at line 75 of file vtkvmtkGrayscaleMorphologyImageFilter.h.

76 { this->SetOperation(CLOSE); }

◆ SetOperationToOpen()

void vtkvmtkGrayscaleMorphologyImageFilter::SetOperationToOpen ( )
inline

Convenience method: set Operation to OPEN (erode then dilate).

Definition at line 80 of file vtkvmtkGrayscaleMorphologyImageFilter.h.

81 { this->SetOperation(OPEN); }

◆ SimpleExecute()

void vtkvmtkGrayscaleMorphologyImageFilter::SimpleExecute ( vtkImageData * input,
vtkImageData * output )
overrideprotectedvirtual

Definition at line 64 of file vtkvmtkGrayscaleMorphologyImageFilter.cxx.

65{
66 typedef float PixelType;
67 const int Dimension = 3;
68 typedef itk::Image<PixelType, Dimension> ImageType;
69
70 ImageType::Pointer inImage = ImageType::New();
71
73
74 typedef itk::BinaryBallStructuringElement<PixelType, Dimension> KernelType;
75 typedef itk::GrayscaleMorphologicalClosingImageFilter<ImageType, ImageType, KernelType> ClosingFilterType;
76 typedef itk::GrayscaleMorphologicalOpeningImageFilter<ImageType, ImageType, KernelType> OpeningFilterType;
77 typedef itk::GrayscaleErodeImageFilter<ImageType, ImageType, KernelType> ErodeFilterType;
78 typedef itk::GrayscaleDilateImageFilter<ImageType, ImageType, KernelType> DilateFilterType;
79
80 KernelType ball;
81 KernelType::SizeType ballRadius;
82 ballRadius[0] = this->BallRadius[0];
83 ballRadius[1] = this->BallRadius[1];
84 ballRadius[2] = this->BallRadius[2];
85 ball.SetRadius(ballRadius);
86 ball.CreateStructuringElement();
87
88 ImageType::Pointer outputImage;
89
90 if (this->Operation == CLOSE)
91 {
92 ClosingFilterType::Pointer imageFilter = ClosingFilterType::New();
93 imageFilter->SetKernel(ball);
94 imageFilter->SetInput(inImage);
95 imageFilter->SafeBorderOff();
96 try {
97 imageFilter->Update();
98 }
99 catch( itk::ExceptionObject & excep )
100 {
101 std::cerr << "Exception caught !" << std::endl;
102 std::cerr << excep << std::endl;
103 }
104 outputImage = imageFilter->GetOutput();
105 }
106 if (this->Operation == OPEN)
107 {
108 OpeningFilterType::Pointer imageFilter = OpeningFilterType::New();
109 imageFilter->SetKernel(ball);
110 imageFilter->SetInput(inImage);
111 imageFilter->SafeBorderOff();
112 try {
113 imageFilter->Update();
114 }
115 catch( itk::ExceptionObject & excep )
116 {
117 std::cerr << "Exception caught !" << std::endl;
118 std::cerr << excep << std::endl;
119 }
120 outputImage = imageFilter->GetOutput();
121 }
122 if (this->Operation == DILATE)
123 {
124 DilateFilterType::Pointer imageFilter = DilateFilterType::New();
125 imageFilter->SetKernel(ball);
126 imageFilter->SetInput(inImage);
127 try {
128 imageFilter->Update();
129 }
130 catch( itk::ExceptionObject & excep )
131 {
132 std::cerr << "Exception caught !" << std::endl;
133 std::cerr << excep << std::endl;
134 }
135 outputImage = imageFilter->GetOutput();
136 }
137 if (this->Operation == ERODE)
138 {
139 ErodeFilterType::Pointer imageFilter = ErodeFilterType::New();
140 imageFilter->SetKernel(ball);
141 imageFilter->SetInput(inImage);
142 try {
143 imageFilter->Update();
144 }
145 catch( itk::ExceptionObject & excep )
146 {
147 std::cerr << "Exception caught !" << std::endl;
148 std::cerr << excep << std::endl;
149 }
150 outputImage = imageFilter->GetOutput();
151 }
152
154}
static void ITKToVTKImage(typename TImage::Pointer input, vtkImageData *output)
static void VTKToITKImage(vtkImageData *input, typename TImage::Pointer output)

◆ RequestInformation()

int vtkvmtkGrayscaleMorphologyImageFilter::RequestInformation ( vtkInformation * vtkNotUsedrequest,
vtkInformationVector ** inputVector,
vtkInformationVector * outputVector )
overrideprotectedvirtual

Definition at line 53 of file vtkvmtkGrayscaleMorphologyImageFilter.cxx.

57{
58 vtkInformation *outInfo = outputVector->GetInformationObject(0);
59 vtkDataObject::SetPointDataActiveScalarInfo(outInfo, VTK_FLOAT, -1);
60
61 return 1;
62}

Member Data Documentation

◆ BallRadius

int vtkvmtkGrayscaleMorphologyImageFilter::BallRadius[3]
protected

Definition at line 101 of file vtkvmtkGrayscaleMorphologyImageFilter.h.

◆ Operation

int vtkvmtkGrayscaleMorphologyImageFilter::Operation
protected

Definition at line 102 of file vtkvmtkGrayscaleMorphologyImageFilter.h.


The documentation for this class was generated from the following files: