VTK  9.2.5
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 
146 
148 
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); }
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); }
210  vtkSetMacro(ExtractionMode, int);
211  vtkGetMacro(ExtractionMode, int);
213 
215 
219  vtkSetMacro(LabelConstantValue, int);
220  vtkGetMacro(LabelConstantValue, int);
222 
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:
292 
295 
296  double ScalarRange[2];
297  vtkIdType SizeRange[2];
302 
307 
308  void ComputeInputUpdateExtent(int inExt[6], int outExt[6]);
309 
314 
315 private:
317  void operator=(const vtkImageConnectivityFilter&) = delete;
318 };
319 
320 #endif
Proxy object to connect input/output ports.
abstract class to specify dataset behavior
Definition: vtkDataSet.h:172
dynamic, self-adjusting array of vtkIdType
Generic algorithm superclass for image algs.
Label an image by connectivity.
void SetExtractionModeToAllRegions()
Set which regions to output from this filter.
int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
Subclasses can reimplement this method to collect information from their inputs and set information f...
void SetExtractionModeToLargestRegion()
Set which regions to output from this filter.
~vtkImageConnectivityFilter() override
const char * GetLabelScalarTypeAsString()
Set the scalar type for the output label image.
int FillInputPortInformation(int port, vtkInformation *info) override
These method should be reimplemented by subclasses that have more than a single input or single outpu...
vtkAlgorithmOutput * GetSeedConnection()
The input for seed locations (input port 1).
void SetLabelScalarTypeToShort()
Set the scalar type for the output label image.
vtkIdType GetNumberOfExtractedRegions()
Get the number of extracted regions.
void SetStencilData(vtkImageStencilData *data)
The input for a stencil (input port 2).
const char * GetExtractionModeAsString()
Set which regions to output from this filter.
void SetSeedData(vtkDataSet *data)
The input for seed locations (input port 1).
const char * GetLabelModeAsString()
Set the mode for applying labels to the output.
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called in response to a REQUEST_DATA request from the executive.
vtkIdTypeArray * GetExtractedRegionLabels()
Get the label used for each extracted region.
ExtractionModeEnum
Enum constants for SetExtractionMode().
vtkAlgorithmOutput * GetStencilConnection()
The input for a stencil (input port 2).
void SetLabelScalarTypeToInt()
Set the scalar type for the output label image.
void SetSeedConnection(vtkAlgorithmOutput *port)
The input for seed locations (input port 1).
vtkIntArray * GetExtractedRegionExtents()
Get the extent (a 6-tuples) for each output region.
void SetLabelScalarTypeToUnsignedChar()
Set the scalar type for the output label image.
void SetLabelModeToConstantValue()
Set the mode for applying labels to the output.
int RequestUpdateExtent(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
Subclasses can reimplement this method to translate the update extent requests from each output port ...
LabelModeEnum
Enum constants for SetLabelMode().
static vtkImageConnectivityFilter * New()
void SetLabelScalarTypeToUnsignedShort()
Set the scalar type for the output label image.
vtkIdTypeArray * GetExtractedRegionSeedIds()
Get the PointId of the seed for each region.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void ComputeInputUpdateExtent(int inExt[6], int outExt[6])
void SetExtractionModeToSeededRegions()
Set which regions to output from this filter.
void SetLabelModeToSeedScalar()
Set the mode for applying labels to the output.
void SetStencilConnection(vtkAlgorithmOutput *port)
The input for a stencil (input port 2).
void SetLabelModeToSizeRank()
Set the mode for applying labels to the output.
topologically and geometrically regular array of data
Definition: vtkImageData.h:163
efficient description of an image stencil
a simple class to control print indentation
Definition: vtkIndent.h:119
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:155
@ info
Definition: vtkX3D.h:382
@ port
Definition: vtkX3D.h:453
@ data
Definition: vtkX3D.h:321
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_SHORT
Definition: vtkType.h:48
int vtkIdType
Definition: vtkType.h:332
#define VTK_UNSIGNED_CHAR
Definition: vtkType.h:47
#define VTK_UNSIGNED_SHORT
Definition: vtkType.h:49
#define VTK_INT
Definition: vtkType.h:50