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
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:242
vtkImageConnectivityFilter::LabelModeEnum
LabelModeEnum
Enum constants for SetLabelMode().
Definition: vtkImageConnectivityFilter.h:119
vtkImageConnectivityFilter::GetExtractedRegionExtents
vtkIntArray * GetExtractedRegionExtents()
Get the extent (a 6-tuples) for each output region.
Definition: vtkImageConnectivityFilter.h:257
vtkIdType
int vtkIdType
Definition: vtkType.h:347
vtkX3D::data
Definition: vtkX3D.h:315
vtkImageConnectivityFilter::ExtractedRegionSizes
vtkIdTypeArray * ExtractedRegionSizes
Definition: vtkImageConnectivityFilter.h:314
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:41
VTK_UNSIGNED_SHORT
#define VTK_UNSIGNED_SHORT
Definition: vtkType.h:53
vtkImageConnectivityFilter::SetLabelScalarTypeToUnsignedShort
void SetLabelScalarTypeToUnsignedShort()
Definition: vtkImageConnectivityFilter.h:171
vtkImageConnectivityFilter::ExtractionModeEnum
ExtractionModeEnum
Enum constants for SetExtractionMode().
Definition: vtkImageConnectivityFilter.h:128
vtkImageConnectivityFilter::SetLabelModeToSeedScalar
void SetLabelModeToSeedScalar()
Set the mode for applying labels to the output.
Definition: vtkImageConnectivityFilter.h:193
vtkImageAlgorithm.h
vtkImageConnectivityFilter::SetLabelModeToSizeRank
void SetLabelModeToSizeRank()
Definition: vtkImageConnectivityFilter.h:195
vtkImageConnectivityFilter::ExtractedRegionExtents
vtkIntArray * ExtractedRegionExtents
Definition: vtkImageConnectivityFilter.h:316
vtkImageAlgorithm
Generic algorithm superclass for image algs.
Definition: vtkImageAlgorithm.h:40
vtkImageConnectivityFilter::SetExtractionModeToSeededRegions
void SetExtractionModeToSeededRegions()
Set which regions to output from this filter.
Definition: vtkImageConnectivityFilter.h:209
vtkImageConnectivityFilter
Label an image by connectivity.
Definition: vtkImageConnectivityFilter.h:108
vtkImageConnectivityFilter::ExtractedRegionLabels
vtkIdTypeArray * ExtractedRegionLabels
Definition: vtkImageConnectivityFilter.h:313
vtkImageConnectivityFilter::SetExtractionModeToAllRegions
void SetExtractionModeToAllRegions()
Definition: vtkImageConnectivityFilter.h:211
vtkX3D::port
Definition: vtkX3D.h:447
vtkImageConnectivityFilter::LabelConstantValue
int LabelConstantValue
Definition: vtkImageConnectivityFilter.h:308
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:194
vtkImageConnectivityFilter::SetLabelScalarTypeToShort
void SetLabelScalarTypeToShort()
Definition: vtkImageConnectivityFilter.h:169
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkIntArray
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:45
VTK_UNSIGNED_CHAR
#define VTK_UNSIGNED_CHAR
Definition: vtkType.h:51
vtkImageConnectivityFilter::ActiveComponent
int ActiveComponent
Definition: vtkImageConnectivityFilter.h:309
vtkImageConnectivityFilter::GenerateRegionExtents
vtkTypeBool GenerateRegionExtents
Definition: vtkImageConnectivityFilter.h:311
vtkDataSet
abstract class to specify dataset behavior
Definition: vtkDataSet.h:62
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:86
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:303
VTK_SHORT
#define VTK_SHORT
Definition: vtkType.h:52
vtkIdTypeArray
dynamic, self-adjusting array of vtkIdType
Definition: vtkIdTypeArray.h:41
vtkImageConnectivityFilter::SetExtractionModeToLargestRegion
void SetExtractionModeToLargestRegion()
Definition: vtkImageConnectivityFilter.h:213
vtkAlgorithmOutput
Proxy object to connect input/output ports.
Definition: vtkAlgorithmOutput.h:39
vtkImageConnectivityFilter::ExtractedRegionSeedIds
vtkIdTypeArray * ExtractedRegionSeedIds
Definition: vtkImageConnectivityFilter.h:315
vtkImageStencilData
efficient description of an image stencil
Definition: vtkImageStencilData.h:37
vtkImageConnectivityFilter::GetExtractedRegionSeedIds
vtkIdTypeArray * GetExtractedRegionSeedIds()
Get the PointId of the seed for each region.
Definition: vtkImageConnectivityFilter.h:249
vtkImageConnectivityFilter::ExtractionMode
int ExtractionMode
Definition: vtkImageConnectivityFilter.h:304
VTK_INT
#define VTK_INT
Definition: vtkType.h:54
vtkImageConnectivityFilter::SetLabelScalarTypeToInt
void SetLabelScalarTypeToInt()
Definition: vtkImageConnectivityFilter.h:173
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:237
vtkImageConnectivityFilter::SetLabelScalarTypeToUnsignedChar
void SetLabelScalarTypeToUnsignedChar()
Set the scalar type for the output label image.
Definition: vtkImageConnectivityFilter.h:167
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkImageConnectivityFilter::LabelScalarType
int LabelScalarType
Definition: vtkImageConnectivityFilter.h:310