VMTK
Loading...
Searching...
No Matches
vtkvmtkOtsuMultipleThresholdsImageFilter Class Reference

Wraps itk::OtsuMultipleThresholdsImageFilter. More...

#include <vtkvmtkOtsuMultipleThresholdsImageFilter.h>

Inheritance diagram for vtkvmtkOtsuMultipleThresholdsImageFilter:
[legend]
Collaboration diagram for vtkvmtkOtsuMultipleThresholdsImageFilter:
[legend]

Public Types

typedef vtkSimpleImageToImageFilter Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkOtsuMultipleThresholdsImageFilter * NewInstance () const
virtual vtkFloatArray * GetThresholds ()
virtual int GetNumberOfHistogramBins ()
virtual void SetNumberOfHistogramBins (int)
virtual int GetNumberOfThresholds ()
virtual void SetNumberOfThresholds (int)
virtual int GetLabelOffset ()
virtual void SetLabelOffset (int)

Static Public Member Functions

static vtkvmtkOtsuMultipleThresholdsImageFilter * New ()
static int IsTypeOf (const char *type)
static vtkvmtkOtsuMultipleThresholdsImageFilter * SafeDownCast (vtkObjectBase *o)

Protected Member Functions

virtual vtkObjectBase * NewInstanceInternal () const
 vtkvmtkOtsuMultipleThresholdsImageFilter ()
 ~vtkvmtkOtsuMultipleThresholdsImageFilter ()
virtual void SimpleExecute (vtkImageData *input, vtkImageData *output) override
virtual int RequestInformation (vtkInformation *vtkNotUsed(request), vtkInformationVector **inputVector, vtkInformationVector *outputVector) override

Detailed Description

Wraps itk::OtsuMultipleThresholdsImageFilter.

vtkvmtkOtsuMultipleThresholdsImageFilter automatically labels an image into NumberOfThresholds+1 intensity classes by computing NumberOfThresholds thresholds that maximize the between-class variance of the image histogram (Otsu's method, generalized to multiple thresholds), producing an unsigned short label image and the vector of computed threshold values (retrievable with GetThresholds). It is the filter behind the vmtkimageotsuthresholds pype script, typically used for coarse, unsupervised segmentation/labeling of an image prior to further refinement (e.g. as an initialization for level set segmentation). Like the other ITK wrappers in this module, it is a thin vtkSimpleImageToImageFilter: SimpleExecute() converts the VTK input to a float itk::Image, runs itk::OtsuMultipleThresholdsImageFilter, and converts the unsigned short label output back to vtkImageData; RequestInformation sets the output scalar type to VTK_UNSIGNED_SHORT.

Definition at line 47 of file vtkvmtkOtsuMultipleThresholdsImageFilter.h.

Member Typedef Documentation

◆ Superclass

typedef vtkSimpleImageToImageFilter vtkvmtkOtsuMultipleThresholdsImageFilter::Superclass

Definition at line 51 of file vtkvmtkOtsuMultipleThresholdsImageFilter.h.

Constructor & Destructor Documentation

◆ vtkvmtkOtsuMultipleThresholdsImageFilter()

vtkvmtkOtsuMultipleThresholdsImageFilter::vtkvmtkOtsuMultipleThresholdsImageFilter ( )
protected

Definition at line 40 of file vtkvmtkOtsuMultipleThresholdsImageFilter.cxx.

41{
42 this->NumberOfHistogramBins = 128;
43 this->NumberOfThresholds = 1;
44 this->LabelOffset = 0;
45 this->Thresholds = NULL;
46}

◆ ~vtkvmtkOtsuMultipleThresholdsImageFilter()

vtkvmtkOtsuMultipleThresholdsImageFilter::~vtkvmtkOtsuMultipleThresholdsImageFilter ( )
protected

Definition at line 48 of file vtkvmtkOtsuMultipleThresholdsImageFilter.cxx.

49{
50 if (this->Thresholds)
51 {
52 this->Thresholds->Delete();
53 this->Thresholds = NULL;
54 }
55}

Member Function Documentation

◆ New()

vtkvmtkOtsuMultipleThresholdsImageFilter * vtkvmtkOtsuMultipleThresholdsImageFilter::New ( )
static

◆ IsTypeOf()

int vtkvmtkOtsuMultipleThresholdsImageFilter::IsTypeOf ( const char * type)
static

◆ IsA()

virtual int vtkvmtkOtsuMultipleThresholdsImageFilter::IsA ( const char * type)
virtual

◆ SafeDownCast()

vtkvmtkOtsuMultipleThresholdsImageFilter * vtkvmtkOtsuMultipleThresholdsImageFilter::SafeDownCast ( vtkObjectBase * o)
static

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkOtsuMultipleThresholdsImageFilter::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkOtsuMultipleThresholdsImageFilter * vtkvmtkOtsuMultipleThresholdsImageFilter::NewInstance ( ) const

◆ GetNumberOfHistogramBins()

virtual int vtkvmtkOtsuMultipleThresholdsImageFilter::GetNumberOfHistogramBins ( )
virtual

Set/get the number of bins used to build the image intensity histogram from which the Otsu thresholds are computed. Default: 128.

◆ SetNumberOfHistogramBins()

virtual void vtkvmtkOtsuMultipleThresholdsImageFilter::SetNumberOfHistogramBins ( int )
virtual

Set/get the number of bins used to build the image intensity histogram from which the Otsu thresholds are computed. Default: 128.

◆ GetNumberOfThresholds()

virtual int vtkvmtkOtsuMultipleThresholdsImageFilter::GetNumberOfThresholds ( )
virtual

Set/get the number of intensity thresholds to compute; the output label image will have NumberOfThresholds+1 distinct label values. Default: 1.

◆ SetNumberOfThresholds()

virtual void vtkvmtkOtsuMultipleThresholdsImageFilter::SetNumberOfThresholds ( int )
virtual

Set/get the number of intensity thresholds to compute; the output label image will have NumberOfThresholds+1 distinct label values. Default: 1.

◆ GetLabelOffset()

virtual int vtkvmtkOtsuMultipleThresholdsImageFilter::GetLabelOffset ( )
virtual

Set/get the lowest label value used when generating the output labeled image (label values are consecutive integers starting at LabelOffset). Default: 0.

◆ SetLabelOffset()

virtual void vtkvmtkOtsuMultipleThresholdsImageFilter::SetLabelOffset ( int )
virtual

Set/get the lowest label value used when generating the output labeled image (label values are consecutive integers starting at LabelOffset). Default: 0.

◆ GetThresholds()

virtual vtkFloatArray * vtkvmtkOtsuMultipleThresholdsImageFilter::GetThresholds ( )
virtual

Get the array of NumberOfThresholds intensity threshold values computed by the most recent Update(), in increasing order.

◆ SimpleExecute()

void vtkvmtkOtsuMultipleThresholdsImageFilter::SimpleExecute ( vtkImageData * input,
vtkImageData * output )
overrideprotectedvirtual

Definition at line 68 of file vtkvmtkOtsuMultipleThresholdsImageFilter.cxx.

69{
70 typedef float PixelType;
71 typedef unsigned short OutputPixelType;
72 const int Dimension = 3;
73 typedef itk::Image<PixelType, Dimension> ImageType;
74 typedef itk::Image<OutputPixelType, Dimension> OutputImageType;
75
76 ImageType::Pointer inImage = ImageType::New();
77
79
80 typedef itk::OtsuMultipleThresholdsImageFilter<ImageType, OutputImageType> OtsuFilterType;
81 typedef OtsuFilterType::ThresholdVectorType ThresholdVectorType;
82
83 OtsuFilterType::Pointer imageFilter = OtsuFilterType::New();
84 imageFilter->SetInput(inImage);
85 imageFilter->SetNumberOfHistogramBins(this->NumberOfHistogramBins);
86 imageFilter->SetNumberOfThresholds(this->NumberOfThresholds);
87 imageFilter->SetLabelOffset(this->LabelOffset);
88 imageFilter->Update();
89
90 const ThresholdVectorType& thresholds = imageFilter->GetThresholds();
91
92 if (this->Thresholds)
93 {
94 this->Thresholds->Delete();
95 this->Thresholds = NULL;
96 }
97
98 this->Thresholds = vtkFloatArray::New();
99 this->Thresholds->SetNumberOfTuples(thresholds.size());
100
101 for (unsigned long j=0; j<thresholds.size(); j++)
102 {
103 this->Thresholds->SetValue(j,thresholds[j]);
104 }
105
106 OutputImageType::Pointer outputImage = imageFilter->GetOutput();
107
109}
static void ITKToVTKImage(typename TImage::Pointer input, vtkImageData *output)
static void VTKToITKImage(vtkImageData *input, typename TImage::Pointer output)

◆ RequestInformation()

int vtkvmtkOtsuMultipleThresholdsImageFilter::RequestInformation ( vtkInformation * vtkNotUsedrequest,
vtkInformationVector ** inputVector,
vtkInformationVector * outputVector )
overrideprotectedvirtual

Definition at line 57 of file vtkvmtkOtsuMultipleThresholdsImageFilter.cxx.

61{
62 vtkInformation *outInfo = outputVector->GetInformationObject(0);
63 vtkDataObject::SetPointDataActiveScalarInfo(outInfo, VTK_UNSIGNED_SHORT, -1);
64
65 return 1;
66}

The documentation for this class was generated from the following files: