VTK
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 "vtkImagingMorphologicalModule.h" // For export macro
97 #include "vtkImageAlgorithm.h"
98 
99 class vtkIdTypeArray;
100 class vtkIntArray;
101 class vtkDataSet;
102 class vtkImageData;
103 class vtkImageStencilData;
104 
105 class VTKIMAGINGMORPHOLOGICAL_EXPORT vtkImageConnectivityFilter :
106  public vtkImageAlgorithm
107 {
108 public:
111  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
112 
117  SeedScalar = 0,
118  ConstantValue = 1,
119  SizeRank = 2
120  };
121 
126  SeededRegions = 0,
127  AllRegions = 1,
128  LargestRegion = 2
129  };
130 
132 
138  void SetSeedConnection(vtkAlgorithmOutput *port);
139  vtkAlgorithmOutput *GetSeedConnection();
140  void SetSeedData(vtkDataSet *data);
142 
144 
150  void SetStencilConnection(vtkAlgorithmOutput *port);
151  vtkAlgorithmOutput *GetStencilConnection();
152  void SetStencilData(vtkImageStencilData *data);
154 
156 
165  this->SetLabelScalarType(VTK_UNSIGNED_CHAR); }
167  this->SetLabelScalarType(VTK_SHORT); }
169  this->SetLabelScalarType(VTK_UNSIGNED_SHORT); }
171  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 
207  this->SetExtractionMode(SeededRegions); }
209  this->SetExtractionMode(AllRegions); }
211  this->SetExtractionMode(LargestRegion); }
212  const char *GetExtractionModeAsString();
213  vtkSetMacro(ExtractionMode, int);
214  vtkGetMacro(ExtractionMode, int);
216 
218 
222  vtkSetMacro(LabelConstantValue, int);
223  vtkGetMacro(LabelConstantValue, int);
225 
229  vtkIdType GetNumberOfExtractedRegions();
230 
235  return this->ExtractedRegionLabels; }
236 
237  // Desciption:
238  // Get the size of each extracted region, as a voxel count.
240  return this->ExtractedRegionSizes; }
241 
247  return this->ExtractedRegionSeedIds; }
248 
255  return this->ExtractedRegionExtents; }
256 
258 
261  vtkSetMacro(GenerateRegionExtents, int);
262  vtkBooleanMacro(GenerateRegionExtents, int);
263  vtkGetMacro(GenerateRegionExtents, int);
265 
267 
272  vtkSetVector2Macro(SizeRange, vtkIdType);
273  vtkGetVector2Macro(SizeRange, vtkIdType);
275 
277 
284  vtkSetVector2Macro(ScalarRange, double);
285  vtkGetVector2Macro(ScalarRange, double);
287 
289 
292  vtkSetMacro(ActiveComponent, int);
293  vtkGetMacro(ActiveComponent, int);
295 
296 protected:
298  ~vtkImageConnectivityFilter() VTK_OVERRIDE;
299 
300  int LabelMode;
301  int ExtractionMode;
302 
303  double ScalarRange[2];
304  vtkIdType SizeRange[2];
305  int LabelConstantValue;
306  int ActiveComponent;
307  int LabelScalarType;
308  int GenerateRegionExtents;
309 
310  vtkIdTypeArray *ExtractedRegionLabels;
311  vtkIdTypeArray *ExtractedRegionSizes;
312  vtkIdTypeArray *ExtractedRegionSeedIds;
313  vtkIntArray *ExtractedRegionExtents;
314 
315  void ComputeInputUpdateExtent(int inExt[6], int outExt[6]);
316 
317  int FillInputPortInformation(int port, vtkInformation *info) VTK_OVERRIDE;
318  int RequestInformation(
320  int RequestUpdateExtent(
322  int RequestData(
324 
325 private:
326  vtkImageConnectivityFilter(const vtkImageConnectivityFilter&) VTK_DELETE_FUNCTION;
327  void operator=(const vtkImageConnectivityFilter&) VTK_DELETE_FUNCTION;
328 };
329 
330 #endif
vtkIdTypeArray * GetExtractedRegionSeedIds()
Get the PointId of the seed for each region.
Store vtkAlgorithm input/output information.
#define VTK_UNSIGNED_SHORT
Definition: vtkType.h:53
abstract class to specify dataset behavior
Definition: vtkDataSet.h:56
void SetExtractionModeToSeededRegions()
Set which regions to output from this filter.
dynamic, self-adjusting array of vtkIdType
int vtkIdType
Definition: vtkType.h:345
vtkIntArray * GetExtractedRegionExtents()
Get the extent (a 6-tuples) for each output region.
Proxy object to connect input/output ports.
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:39
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:33
ExtractionModeEnum
Enum constants for SetExtractionMode().
efficient description of an image stencil
topologically and geometrically regular array of data
Definition: vtkImageData.h:39
void SetLabelScalarTypeToUnsignedShort()
Set the scalar type for the output label image.
#define VTK_SHORT
Definition: vtkType.h:52
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.
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
void SetLabelModeToConstantValue()
Set the mode for applying labels to the output.
#define VTK_UNSIGNED_CHAR
Definition: vtkType.h:51
Label an image by connectivity.
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.
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
#define VTK_INT
Definition: vtkType.h:54