1 /*========================================================================= 2 3 Program: Visualization Toolkit 4 Module: vtkImageOpenClose3D.h 5 6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 7 All rights reserved. 8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 9 10 This software is distributed WITHOUT ANY WARRANTY; without even 11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 12 PURPOSE. See the above copyright notice for more information. 13 14 =========================================================================*/ 15 /** 16 * @class vtkImageOpenClose3D 17 * @brief Will perform opening or closing. 18 * 19 * vtkImageOpenClose3D performs opening or closing by having two 20 * vtkImageErodeDilates in series. The size of operation 21 * is determined by the method SetKernelSize, and the operator is an ellipse. 22 * OpenValue and CloseValue determine how the filter behaves. For binary 23 * images Opening and closing behaves as expected. 24 * Close value is first dilated, and then eroded. 25 * Open value is first eroded, and then dilated. 26 * Degenerate two dimensional opening/closing can be achieved by setting the 27 * one axis the 3D KernelSize to 1. 28 * Values other than open value and close value are not touched. 29 * This enables the filter to processes segmented images containing more than 30 * two tags. 31 */ 32 33 #ifndef vtkImageOpenClose3D_h 34 #define vtkImageOpenClose3D_h 35 36 37 #include "vtkImagingMorphologicalModule.h" // For export macro 38 #include "vtkImageAlgorithm.h" 39 40 class vtkImageDilateErode3D; 41 42 class VTKIMAGINGMORPHOLOGICAL_EXPORT vtkImageOpenClose3D : public vtkImageAlgorithm 43 { 44 public: 45 //@{ 46 /** 47 * Default open value is 0, and default close value is 255. 48 */ 49 static vtkImageOpenClose3D *New(); 50 vtkTypeMacro(vtkImageOpenClose3D,vtkImageAlgorithm); 51 void PrintSelf(ostream& os, vtkIndent indent) override; 52 //@} 53 54 /** 55 * This method considers the sub filters MTimes when computing this objects 56 * modified time. 57 */ 58 vtkMTimeType GetMTime() override; 59 60 //@{ 61 /** 62 * Turn debugging output on. (in sub filters also) 63 */ 64 void DebugOn() override; 65 void DebugOff() override; 66 //@} 67 68 /** 69 * Pass modified message to sub filters. 70 */ 71 void Modified() override; 72 73 // Forward Source messages to filter1 74 75 /** 76 * Selects the size of gaps or objects removed. 77 */ 78 void SetKernelSize(int size0, int size1, int size2); 79 80 //@{ 81 /** 82 * Determines the value that will opened. 83 * Open value is first eroded, and then dilated. 84 */ 85 void SetOpenValue(double value); 86 double GetOpenValue(); 87 //@} 88 89 //@{ 90 /** 91 * Determines the value that will closed. 92 * Close value is first dilated, and then eroded 93 */ 94 void SetCloseValue(double value); 95 double GetCloseValue(); 96 //@} 97 98 //@{ 99 /** 100 * Needed for Progress functions 101 */ 102 vtkGetObjectMacro(Filter0, vtkImageDilateErode3D); 103 vtkGetObjectMacro(Filter1, vtkImageDilateErode3D); 104 //@} 105 106 /** 107 * see vtkAlgorithm for details 108 */ 109 int ProcessRequest(vtkInformation*, 110 vtkInformationVector**, 111 vtkInformationVector*) override; 112 113 /** 114 * Override to send the request to internal pipeline. 115 */ 116 int 117 ComputePipelineMTime(vtkInformation* request, 118 vtkInformationVector** inInfoVec, 119 vtkInformationVector* outInfoVec, 120 int requestFromOutputPort, 121 vtkMTimeType* mtime) override; 122 123 protected: 124 vtkImageOpenClose3D(); 125 ~vtkImageOpenClose3D() override; 126 127 vtkImageDilateErode3D *Filter0; 128 vtkImageDilateErode3D *Filter1; 129 130 void ReportReferences(vtkGarbageCollector*) override; 131 private: 132 vtkImageOpenClose3D(const vtkImageOpenClose3D&) = delete; 133 void operator=(const vtkImageOpenClose3D&) = delete; 134 }; 135 136 #endif 137 138 139 140