58 vtkInformation * vtkNotUsed(request),
59 vtkInformationVector **inputVector,
60 vtkInformationVector *outputVector)
62 vtkInformation *outInfo = outputVector->GetInformationObject(0);
63 vtkDataObject::SetPointDataActiveScalarInfo(outInfo, VTK_UNSIGNED_SHORT, -1);
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;
76 ImageType::Pointer inImage = ImageType::New();
80 typedef itk::OtsuMultipleThresholdsImageFilter<ImageType, OutputImageType> OtsuFilterType;
81 typedef OtsuFilterType::ThresholdVectorType ThresholdVectorType;
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();
90 const ThresholdVectorType& thresholds = imageFilter->GetThresholds();
94 this->Thresholds->Delete();
95 this->Thresholds = NULL;
98 this->Thresholds = vtkFloatArray::New();
99 this->Thresholds->SetNumberOfTuples(thresholds.size());
101 for (
unsigned long j=0; j<thresholds.size(); j++)
103 this->Thresholds->SetValue(j,thresholds[j]);
106 OutputImageType::Pointer outputImage = imageFilter->GetOutput();