VTK  9.2.6
vtkImageConnectivityFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkImageConnectivityFilter.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  Copyright (c) 2014 David Gobbi
17  All rights reserved.
18 
19  Redistribution and use in source and binary forms, with or without
20  modification, are permitted provided that the following conditions
21  are met:
22 
23  * Redistributions of source code must retain the above copyright
24  notice, this list of conditions and the following disclaimer.
25 
26  * Redistributions in binary form must reproduce the above copyright
27  notice, this list of conditions and the following disclaimer in the
28  documentation and/or other materials provided with the distribution.
29 
30  * Neither the name of David Gobbi nor the names of any contributors
31  may be used to endorse or promote products derived from this software
32  without specific prior written permission.
33 
34  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
35  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
36  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
37  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
38  HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
39  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
40  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
41  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
42  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
43  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
44  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45 =========================================================================*/
96 #ifndef vtkImageConnectivityFilter_h
97 #define vtkImageConnectivityFilter_h
98 
99 #include "vtkImageAlgorithm.h"
100 #include "vtkImagingMorphologicalModule.h" // For export macro
101 
102 class vtkIdTypeArray;
103 class vtkIntArray;
104 class vtkDataSet;
105 class vtkImageData;
106 class vtkImageStencilData;
107 
108 class VTKIMAGINGMORPHOLOGICAL_EXPORT vtkImageConnectivityFilter : public vtkImageAlgorithm
109 {
110 public:
113  void PrintSelf(ostream& os, vtkIndent indent) override;
114 
119  {
120  SeedScalar = 0,
121  ConstantValue = 1,
122  SizeRank = 2
123  };
124 
129  {
130  SeededRegions = 0,
131  AllRegions = 1,
132  LargestRegion = 2
133  };
134 
136 
142  void SetSeedConnection(vtkAlgorithmOutput* port);
143  vtkAlgorithmOutput* GetSeedConnection();
144  void SetSeedData(vtkDataSet* data);
146 
148 
154  void SetStencilConnection(vtkAlgorithmOutput* port);
155  vtkAlgorithmOutput* GetStencilConnection();
156  void SetStencilData(vtkImageStencilData* data);
158 
160 
168  void SetLabelScalarTypeToUnsignedChar() { this->SetLabelScalarType(VTK_UNSIGNED_CHAR); }
169  void SetLabelScalarTypeToShort() { this->SetLabelScalarType(VTK_SHORT); }
170  void SetLabelScalarTypeToUnsignedShort() { this->SetLabelScalarType(VTK_UNSIGNED_SHORT); }
171  void SetLabelScalarTypeToInt() { this->SetLabelScalarType(VTK_INT); }
172  const char* GetLabelScalarTypeAsString();
173  vtkSetMacro(LabelScalarType, int);
174  vtkGetMacro(LabelScalarType, int);
176 
178 
190  void SetLabelModeToSeedScalar() { this->SetLabelMode(SeedScalar); }
191  void SetLabelModeToConstantValue() { this->SetLabelMode(ConstantValue); }
192  void SetLabelModeToSizeRank() { this->SetLabelMode(SizeRank); }
193  const char* GetLabelModeAsString();
194  vtkSetMacro(LabelMode, int);
195  vtkGetMacro(LabelMode, int);
197 
199 
206  void SetExtractionModeToSeededRegions() { this->SetExtractionMode(SeededRegions); }
207  void SetExtractionModeToAllRegions() { this->SetExtractionMode(AllRegions); }
208  void SetExtractionModeToLargestRegion() { this->SetExtractionMode(LargestRegion); }
209  const char* GetExtractionModeAsString();
210  vtkSetMacro(ExtractionMode, int);
211  vtkGetMacro(ExtractionMode, int);
213 
215 
219  vtkSetMacro(LabelConstantValue, int);
220  vtkGetMacro(LabelConstantValue, int);
222 
226  vtkIdType GetNumberOfExtractedRegions();
227 
231  vtkIdTypeArray* GetExtractedRegionLabels() { return this->ExtractedRegionLabels; }
232 
233  // Description:
234  // Get the size of each extracted region, as a voxel count.
235  vtkIdTypeArray* GetExtractedRegionSizes() { return this->ExtractedRegionSizes; }
236 
241  vtkIdTypeArray* GetExtractedRegionSeedIds() { return this->ExtractedRegionSeedIds; }
242 
248  vtkIntArray* GetExtractedRegionExtents() { return this->ExtractedRegionExtents; }
249 
251 
254  vtkSetMacro(GenerateRegionExtents, vtkTypeBool);
255  vtkBooleanMacro(GenerateRegionExtents, vtkTypeBool);
256  vtkGetMacro(GenerateRegionExtents, vtkTypeBool);
258 
260 
265  vtkSetVector2Macro(SizeRange, vtkIdType);
266  vtkGetVector2Macro(SizeRange, vtkIdType);
268 
270 
277  vtkSetVector2Macro(ScalarRange, double);
278  vtkGetVector2Macro(ScalarRange, double);
280 
282 
285  vtkSetMacro(ActiveComponent, int);
286  vtkGetMacro(ActiveComponent, int);
288 
289 protected:
291  ~vtkImageConnectivityFilter() override;
292 
295 
296  double ScalarRange[2];
297  vtkIdType SizeRange[2];
302 
307 
308  void ComputeInputUpdateExtent(int inExt[6], int outExt[6]);
309 
310  int FillInputPortInformation(int port, vtkInformation* info) override;
314 
315 private:
317  void operator=(const vtkImageConnectivityFilter&) = delete;
318 };
319 
320 #endif
vtkIdTypeArray * GetExtractedRegionSeedIds()
Get the PointId of the seed for each region.
Store vtkAlgorithm input/output information.
#define VTK_UNSIGNED_SHORT
Definition: vtkType.h:49
abstract class to specify dataset behavior
Definition: vtkDataSet.h:62
void SetExtractionModeToSeededRegions()
Set which regions to output from this filter.
dynamic, self-adjusting array of vtkIdType
int vtkIdType
Definition: vtkType.h:332
vtkIntArray * GetExtractedRegionExtents()
Get the extent (a 6-tuples) for each output region.
virtual int RequestUpdateExtent(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
Subclasses can reimplement this method to translate the update extent requests from each output port ...
Proxy object to connect input/output ports.
int vtkTypeBool
Definition: vtkABI.h:69
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:45
vtkIdTypeArray * GetExtractedRegionLabels()
Get the label used for each extracted region.
LabelModeEnum
Enum constants for SetLabelMode().
void SetLabelModeToSizeRank()
Set the mode for applying labels to the output.
void SetLabelModeToSeedScalar()
Set the mode for applying labels to the output.
void SetExtractionModeToLargestRegion()
Set which regions to output from this filter.
a simple class to control print indentation
Definition: vtkIndent.h:39
ExtractionModeEnum
Enum constants for SetExtractionMode().
efficient description of an image stencil
topologically and geometrically regular array of data
Definition: vtkImageData.h:53
virtual int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
Subclasses can reimplement this method to collect information from their inputs and set information f...
void SetLabelScalarTypeToUnsignedShort()
Set the scalar type for the output label image.
#define VTK_SHORT
Definition: vtkType.h:48
void SetLabelScalarTypeToShort()
Set the scalar type for the output label image.
void SetLabelScalarTypeToInt()
Set the scalar type for the output label image.
void SetLabelScalarTypeToUnsignedChar()
Set the scalar type for the output label image.
void SetLabelModeToConstantValue()
Set the mode for applying labels to the output.
#define VTK_UNSIGNED_CHAR
Definition: vtkType.h:47
Label an image by connectivity.
int FillInputPortInformation(int port, vtkInformation *info) override
These method should be reimplemented by subclasses that have more than a single input or single outpu...
Generic algorithm superclass for image algs.
Store zero or more vtkInformation instances.
static vtkAlgorithm * New()
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetExtractionModeToAllRegions()
Set which regions to output from this filter.
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
This is called in response to a REQUEST_DATA request from the executive.
#define VTK_INT
Definition: vtkType.h:50