vtkImageIslandRemoval2D.h 2.57 KB
Newer Older
1 2 3
/*=========================================================================

  Program:   Visualization Toolkit
Charles Law's avatar
Charles Law committed
4
  Module:    vtkImageIslandRemoval2D.h
5

6
  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 8
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
Will Schroeder's avatar
Will Schroeder committed
9

10 11
     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12
     PURPOSE.  See the above copyright notice for more information.
13 14

=========================================================================*/
Charles Law's avatar
Charles Law committed
15
// .NAME vtkImageIslandRemoval2D - Removes small clusters in masks.
16
// .SECTION Description
17
// vtkImageIslandRemoval2D computes the area of separate islands in
18
// a mask image.  It removes any island that has less than AreaThreshold
19 20
// pixels.  Output has the same ScalarType as input.  It generates
// the whole 2D output image for any output request.
21 22


23 24
#ifndef vtkImageIslandRemoval2D_h
#define vtkImageIslandRemoval2D_h
25 26


27
#include "vtkImagingMorphologicalModule.h" // For export macro
Amy Squillacote's avatar
Amy Squillacote committed
28
#include "vtkImageAlgorithm.h"
29

30
//BTX
31 32 33 34 35
typedef struct{
  void *inPtr;
  void *outPtr;
  int idx0;
  int idx1;
Charles Law's avatar
Charles Law committed
36
  } vtkImage2DIslandPixel;
37
//ETX
38

39
class VTKIMAGINGMORPHOLOGICAL_EXPORT vtkImageIslandRemoval2D : public vtkImageAlgorithm
40 41
{
public:
42 43
  // Description:
  // Constructor: Sets default filter to be identity.
44
  static vtkImageIslandRemoval2D *New();
45
  vtkTypeMacro(vtkImageIslandRemoval2D,vtkImageAlgorithm);
46
  void PrintSelf(ostream& os, vtkIndent indent);
47

48 49 50 51 52 53 54 55 56 57 58 59 60
  // Description:
  // Set/Get the cutoff area for removal
  vtkSetMacro(AreaThreshold, int);
  vtkGetMacro(AreaThreshold, int);

  // Description:
  // Set/Get whether to use 4 or 8 neighbors
  vtkSetMacro(SquareNeighborhood, int);
  vtkGetMacro(SquareNeighborhood, int);
  vtkBooleanMacro(SquareNeighborhood, int);

  // Description:
  // Set/Get the value to remove.
Ken Martin's avatar
Ken Martin committed
61 62
  vtkSetMacro(IslandValue, double);
  vtkGetMacro(IslandValue, double);
63 64 65

  // Description:
  // Set/Get the value to put in the place of removed pixels.
Ken Martin's avatar
Ken Martin committed
66 67
  vtkSetMacro(ReplaceValue, double);
  vtkGetMacro(ReplaceValue, double);
68

69
protected:
70
  vtkImageIslandRemoval2D();
71
  ~vtkImageIslandRemoval2D() {}
72

73 74
  int AreaThreshold;
  int SquareNeighborhood;
Ken Martin's avatar
Ken Martin committed
75 76
  double IslandValue;
  double ReplaceValue;
77

78 79 80
  virtual int RequestData(vtkInformation *,
                          vtkInformationVector **,
                          vtkInformationVector *);
Amy Squillacote's avatar
Amy Squillacote committed
81

82 83 84
private:
  vtkImageIslandRemoval2D(const vtkImageIslandRemoval2D&);  // Not implemented.
  void operator=(const vtkImageIslandRemoval2D&);  // Not implemented.
85 86 87 88 89 90
};

#endif