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 =========================================================================*/
96 #ifndef vtkImageConnectivityFilter_h
97 #define vtkImageConnectivityFilter_h
98 
99 #include "vtkImagingMorphologicalModule.h" // For export macro
100 #include "vtkImageAlgorithm.h"
101 
102 class vtkIdTypeArray;
103 class vtkIntArray;
104 class vtkDataSet;
105 class vtkImageData;
106 class vtkImageStencilData;
107 
108 class VTKIMAGINGMORPHOLOGICAL_EXPORT vtkImageConnectivityFilter :
109  public vtkImageAlgorithm
110 {
111 public:
114  void PrintSelf(ostream& os, vtkIndent indent) override;
115 
120  SeedScalar = 0,
121  ConstantValue = 1,
122  SizeRank = 2
123  };
124 
129  SeededRegions = 0,
130  AllRegions = 1,
131  LargestRegion = 2
132  };
133 
135 
141  void SetSeedConnection(vtkAlgorithmOutput *port);
142  vtkAlgorithmOutput *GetSeedConnection();
143  void SetSeedData(vtkDataSet *data);
145 
147 
153  void SetStencilConnection(vtkAlgorithmOutput *port);
154  vtkAlgorithmOutput *GetStencilConnection();
155  void SetStencilData(vtkImageStencilData *data);
157 
159 
168  this->SetLabelScalarType(VTK_UNSIGNED_CHAR); }
170  this->SetLabelScalarType(VTK_SHORT); }
172  this->SetLabelScalarType(VTK_UNSIGNED_SHORT); }
174  this->SetLabelScalarType(VTK_INT); }
175  const char *GetLabelScalarTypeAsString();
176  vtkSetMacro(LabelScalarType, int);
177  vtkGetMacro(LabelScalarType, int);
179 
181 
193  void SetLabelModeToSeedScalar() { this->SetLabelMode(SeedScalar); }
194  void SetLabelModeToConstantValue() { this->SetLabelMode(ConstantValue); }
195  void SetLabelModeToSizeRank() { this->SetLabelMode(SizeRank); }
196  const char *GetLabelModeAsString();
197  vtkSetMacro(LabelMode, int);
198  vtkGetMacro(LabelMode, int);
200 
202 
210  this->SetExtractionMode(SeededRegions); }
212  this->SetExtractionMode(AllRegions); }
214  this->SetExtractionMode(LargestRegion); }
215  const char *GetExtractionModeAsString();
216  vtkSetMacro(ExtractionMode, int);
217  vtkGetMacro(ExtractionMode, int);
219 
221 
225  vtkSetMacro(LabelConstantValue, int);
226  vtkGetMacro(LabelConstantValue, int);
228 
232  vtkIdType GetNumberOfExtractedRegions();
233 
238  return this->ExtractedRegionLabels; }
239 
240  // Description:
241  // Get the size of each extracted region, as a voxel count.
243  return this->ExtractedRegionSizes; }
244 
250  return this->ExtractedRegionSeedIds; }
251 
258  return this->ExtractedRegionExtents; }
259 
261 
264  vtkSetMacro(GenerateRegionExtents, vtkTypeBool);
265  vtkBooleanMacro(GenerateRegionExtents, vtkTypeBool);
266  vtkGetMacro(GenerateRegionExtents, vtkTypeBool);
268 
270 
275  vtkSetVector2Macro(SizeRange, vtkIdType);
276  vtkGetVector2Macro(SizeRange, vtkIdType);
278 
280 
287  vtkSetVector2Macro(ScalarRange, double);
288  vtkGetVector2Macro(ScalarRange, double);
290 
292 
295  vtkSetMacro(ActiveComponent, int);
296  vtkGetMacro(ActiveComponent, int);
298 
299 protected:
301  ~vtkImageConnectivityFilter() override;
302 
305 
306  double ScalarRange[2];
307  vtkIdType SizeRange[2];
312 
317 
318  void ComputeInputUpdateExtent(int inExt[6], int outExt[6]);
319 
320  int FillInputPortInformation(int port, vtkInformation *info) override;
321  int RequestInformation(
325  int RequestData(
327 
328 private:
330  void operator=(const vtkImageConnectivityFilter&) = delete;
331 };
332 
333 #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:62
void SetExtractionModeToSeededRegions()
Set which regions to output from this filter.
dynamic, self-adjusting array of vtkIdType
int vtkIdType
Definition: vtkType.h:347
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:45
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: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.
void SetLabelModeToConstantValue()
Set the mode for applying labels to the output.
#define VTK_UNSIGNED_CHAR
Definition: vtkType.h:51
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:54