VTK  9.1.0
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 =========================================================================*/
93 #ifndef vtkImageConnectivityFilter_h
94 #define vtkImageConnectivityFilter_h
95 
96 #include "vtkImageAlgorithm.h"
97 #include "vtkImagingMorphologicalModule.h" // For export macro
98 
99 class vtkIdTypeArray;
100 class vtkIntArray;
101 class vtkDataSet;
102 class vtkImageData;
103 class vtkImageStencilData;
104 
105 class VTKIMAGINGMORPHOLOGICAL_EXPORT vtkImageConnectivityFilter : public vtkImageAlgorithm
106 {
107 public:
110  void PrintSelf(ostream& os, vtkIndent indent) override;
111 
116  {
117  SeedScalar = 0,
118  ConstantValue = 1,
119  SizeRank = 2
120  };
121 
126  {
127  SeededRegions = 0,
128  AllRegions = 1,
129  LargestRegion = 2
130  };
131 
133 
143 
145 
155 
157 
165  void SetLabelScalarTypeToUnsignedChar() { this->SetLabelScalarType(VTK_UNSIGNED_CHAR); }
166  void SetLabelScalarTypeToShort() { this->SetLabelScalarType(VTK_SHORT); }
167  void SetLabelScalarTypeToUnsignedShort() { this->SetLabelScalarType(VTK_UNSIGNED_SHORT); }
168  void SetLabelScalarTypeToInt() { this->SetLabelScalarType(VTK_INT); }
170  vtkSetMacro(LabelScalarType, int);
171  vtkGetMacro(LabelScalarType, int);
173 
175 
187  void SetLabelModeToSeedScalar() { this->SetLabelMode(SeedScalar); }
188  void SetLabelModeToConstantValue() { this->SetLabelMode(ConstantValue); }
189  void SetLabelModeToSizeRank() { this->SetLabelMode(SizeRank); }
190  const char* GetLabelModeAsString();
191  vtkSetMacro(LabelMode, int);
192  vtkGetMacro(LabelMode, int);
194 
196 
203  void SetExtractionModeToSeededRegions() { this->SetExtractionMode(SeededRegions); }
204  void SetExtractionModeToAllRegions() { this->SetExtractionMode(AllRegions); }
205  void SetExtractionModeToLargestRegion() { this->SetExtractionMode(LargestRegion); }
207  vtkSetMacro(ExtractionMode, int);
208  vtkGetMacro(ExtractionMode, int);
210 
212 
216  vtkSetMacro(LabelConstantValue, int);
217  vtkGetMacro(LabelConstantValue, int);
219 
224 
228  vtkIdTypeArray* GetExtractedRegionLabels() { return this->ExtractedRegionLabels; }
229 
230  // Description:
231  // Get the size of each extracted region, as a voxel count.
232  vtkIdTypeArray* GetExtractedRegionSizes() { return this->ExtractedRegionSizes; }
233 
238  vtkIdTypeArray* GetExtractedRegionSeedIds() { return this->ExtractedRegionSeedIds; }
239 
245  vtkIntArray* GetExtractedRegionExtents() { return this->ExtractedRegionExtents; }
246 
248 
251  vtkSetMacro(GenerateRegionExtents, vtkTypeBool);
252  vtkBooleanMacro(GenerateRegionExtents, vtkTypeBool);
253  vtkGetMacro(GenerateRegionExtents, vtkTypeBool);
255 
257 
262  vtkSetVector2Macro(SizeRange, vtkIdType);
263  vtkGetVector2Macro(SizeRange, vtkIdType);
265 
267 
274  vtkSetVector2Macro(ScalarRange, double);
275  vtkGetVector2Macro(ScalarRange, double);
277 
279 
282  vtkSetMacro(ActiveComponent, int);
283  vtkGetMacro(ActiveComponent, int);
285 
286 protected:
289 
292 
293  double ScalarRange[2];
294  vtkIdType SizeRange[2];
299 
304 
305  void ComputeInputUpdateExtent(int inExt[6], int outExt[6]);
306 
311 
312 private:
314  void operator=(const vtkImageConnectivityFilter&) = delete;
315 };
316 
317 #endif
Proxy object to connect input/output ports.
abstract class to specify dataset behavior
Definition: vtkDataSet.h:57
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:48
efficient description of an image stencil
a simple class to control print indentation
Definition: vtkIndent.h:34
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:40
@ 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