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) 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  // Description:
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, vtkTypeBool);
262  vtkBooleanMacro(GenerateRegionExtents, vtkTypeBool);
263  vtkGetMacro(GenerateRegionExtents, vtkTypeBool);
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() override;
299 
302 
303  double ScalarRange[2];
304  vtkIdType SizeRange[2];
309 
314 
315  void ComputeInputUpdateExtent(int inExt[6], int outExt[6]);
316 
317  int FillInputPortInformation(int port, vtkInformation *info) override;
318  int RequestInformation(
322  int RequestData(
324 
325 private:
327  void operator=(const vtkImageConnectivityFilter&) = delete;
328 };
329 
330 #endif
vtkImageAlgorithm::RequestData
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
This is called in response to a REQUEST_DATA request from the executive.
vtkImageConnectivityFilter::GetExtractedRegionSizes
vtkIdTypeArray * GetExtractedRegionSizes()
Definition: vtkImageConnectivityFilter.h:239
vtkImageConnectivityFilter::LabelModeEnum
LabelModeEnum
Enum constants for SetLabelMode().
Definition: vtkImageConnectivityFilter.h:116
vtkImageConnectivityFilter::GetExtractedRegionExtents
vtkIntArray * GetExtractedRegionExtents()
Get the extent (a 6-tuples) for each output region.
Definition: vtkImageConnectivityFilter.h:254
vtkIdType
int vtkIdType
Definition: vtkType.h:347
vtkX3D::data
Definition: vtkX3D.h:315
vtkImageConnectivityFilter::ExtractedRegionSizes
vtkIdTypeArray * ExtractedRegionSizes
Definition: vtkImageConnectivityFilter.h:311
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:35
VTK_UNSIGNED_SHORT
#define VTK_UNSIGNED_SHORT
Definition: vtkType.h:53
vtkImageConnectivityFilter::SetLabelScalarTypeToUnsignedShort
void SetLabelScalarTypeToUnsignedShort()
Definition: vtkImageConnectivityFilter.h:168
vtkImageConnectivityFilter::ExtractionModeEnum
ExtractionModeEnum
Enum constants for SetExtractionMode().
Definition: vtkImageConnectivityFilter.h:125
vtkImageConnectivityFilter::SetLabelModeToSeedScalar
void SetLabelModeToSeedScalar()
Set the mode for applying labels to the output.
Definition: vtkImageConnectivityFilter.h:190
vtkImageAlgorithm.h
vtkImageConnectivityFilter::SetLabelModeToSizeRank
void SetLabelModeToSizeRank()
Definition: vtkImageConnectivityFilter.h:192
vtkImageConnectivityFilter::ExtractedRegionExtents
vtkIntArray * ExtractedRegionExtents
Definition: vtkImageConnectivityFilter.h:313
vtkImageAlgorithm
Generic algorithm superclass for image algs.
Definition: vtkImageAlgorithm.h:37
vtkImageConnectivityFilter::SetExtractionModeToSeededRegions
void SetExtractionModeToSeededRegions()
Set which regions to output from this filter.
Definition: vtkImageConnectivityFilter.h:206
vtkImageConnectivityFilter
Label an image by connectivity.
Definition: vtkImageConnectivityFilter.h:105
vtkImageConnectivityFilter::ExtractedRegionLabels
vtkIdTypeArray * ExtractedRegionLabels
Definition: vtkImageConnectivityFilter.h:310
vtkImageConnectivityFilter::SetExtractionModeToAllRegions
void SetExtractionModeToAllRegions()
Definition: vtkImageConnectivityFilter.h:208
vtkX3D::port
Definition: vtkX3D.h:447
vtkImageConnectivityFilter::LabelConstantValue
int LabelConstantValue
Definition: vtkImageConnectivityFilter.h:305
vtkImageAlgorithm::RequestUpdateExtent
virtual int RequestUpdateExtent(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
Subclasses can reimplement this method to translate the update extent requests from each output port ...
vtkImageAlgorithm::RequestInformation
virtual int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
Subclasses can reimplement this method to collect information from their inputs and set information f...
vtkImageConnectivityFilter::SetLabelModeToConstantValue
void SetLabelModeToConstantValue()
Definition: vtkImageConnectivityFilter.h:191
vtkImageConnectivityFilter::SetLabelScalarTypeToShort
void SetLabelScalarTypeToShort()
Definition: vtkImageConnectivityFilter.h:166
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:39
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkIntArray
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:39
VTK_UNSIGNED_CHAR
#define VTK_UNSIGNED_CHAR
Definition: vtkType.h:51
vtkImageConnectivityFilter::ActiveComponent
int ActiveComponent
Definition: vtkImageConnectivityFilter.h:306
vtkImageConnectivityFilter::GenerateRegionExtents
vtkTypeBool GenerateRegionExtents
Definition: vtkImageConnectivityFilter.h:308
vtkDataSet
abstract class to specify dataset behavior
Definition: vtkDataSet.h:56
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:80
vtkX3D::info
Definition: vtkX3D.h:376
vtkImageAlgorithm::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkAlgorithm::New
static vtkAlgorithm * New()
vtkImageConnectivityFilter::LabelMode
int LabelMode
Definition: vtkImageConnectivityFilter.h:300
VTK_SHORT
#define VTK_SHORT
Definition: vtkType.h:52
vtkIdTypeArray
dynamic, self-adjusting array of vtkIdType
Definition: vtkIdTypeArray.h:35
vtkImageConnectivityFilter::SetExtractionModeToLargestRegion
void SetExtractionModeToLargestRegion()
Definition: vtkImageConnectivityFilter.h:210
vtkAlgorithmOutput
Proxy object to connect input/output ports.
Definition: vtkAlgorithmOutput.h:36
vtkImageConnectivityFilter::ExtractedRegionSeedIds
vtkIdTypeArray * ExtractedRegionSeedIds
Definition: vtkImageConnectivityFilter.h:312
vtkImageStencilData
efficient description of an image stencil
Definition: vtkImageStencilData.h:34
vtkImageConnectivityFilter::GetExtractedRegionSeedIds
vtkIdTypeArray * GetExtractedRegionSeedIds()
Get the PointId of the seed for each region.
Definition: vtkImageConnectivityFilter.h:246
vtkImageConnectivityFilter::ExtractionMode
int ExtractionMode
Definition: vtkImageConnectivityFilter.h:301
VTK_INT
#define VTK_INT
Definition: vtkType.h:54
vtkImageConnectivityFilter::SetLabelScalarTypeToInt
void SetLabelScalarTypeToInt()
Definition: vtkImageConnectivityFilter.h:170
vtkImageAlgorithm::FillInputPortInformation
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
vtkImageConnectivityFilter::GetExtractedRegionLabels
vtkIdTypeArray * GetExtractedRegionLabels()
Get the label used for each extracted region.
Definition: vtkImageConnectivityFilter.h:234
vtkImageConnectivityFilter::SetLabelScalarTypeToUnsignedChar
void SetLabelScalarTypeToUnsignedChar()
Set the scalar type for the output label image.
Definition: vtkImageConnectivityFilter.h:164
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkImageConnectivityFilter::LabelScalarType
int LabelScalarType
Definition: vtkImageConnectivityFilter.h:307