15 #include <itkBinaryThresholdImageFilter.h>
16 #include <vtkImageCast.h>
43 return "Segmentation";
48 return "binary_threshold_image_filter";
54 "<h3>Binary Threshold Image Filter.</h3>"
55 "<p><i>Segment out areas from the selected image using a threshold.</i></p>"
56 "<p>This filter produces an output image whose pixels are either one of two values"
57 "( OutsideValue or InsideValue ), depending on whether the corresponding input"
58 "image pixels lie between the two thresholds ( LowerThreshold and UpperThreshold )."
59 "Values equal to either threshold is considered to be between the thresholds.<p>"
66 "Select the lower and upper thresholds for the segmentation",
DoubleRange(0, 100, 1), 0,
74 "Generate a surface of the output volume",
true,
82 "The color of the output model.",
83 QColor(
"green"), root);
100 temp->setValueName(
"Input");
101 temp->setHelp(
"Select image input for thresholding");
102 connect(temp.get(), SIGNAL(dataChanged(QString)),
this, SLOT(imageChangedSlot(QString)));
111 temp->setValueName(
"Output");
112 temp->setHelp(
"Output thresholded binary image");
116 temp->setValueName(
"Contour");
117 temp->setHelp(
"Output contour generated from thresholded binary image.");
129 void BinaryThresholdImageFilter::imageChangedSlot(QString uid)
135 void BinaryThresholdImageFilter::stopPreview()
149 Eigen::Vector2d threshold = Eigen::Vector2d(mThresholdOption->getValue()[0], mThresholdOption->getValue()[1]);
173 typedef itk::BinaryThresholdImageFilter<itkImageType, itkImageType> thresholdFilterType;
174 thresholdFilterType::Pointer thresholdFilter = thresholdFilterType::New();
175 thresholdFilter->SetInput(itkImage);
176 thresholdFilter->SetOutsideValue(0);
177 thresholdFilter->SetInsideValue(1);
178 thresholdFilter->SetLowerThreshold(thresholds->getValue()[0]);
179 thresholdFilter->SetUpperThreshold(thresholds->getValue()[1]);
180 thresholdFilter->Update();
181 itkImage = thresholdFilter->GetOutput();
185 itkToVtkFilter->SetInput(itkImage);
186 itkToVtkFilter->Update();
189 rawResult->DeepCopy(itkToVtkFilter->GetOutput());
192 imageCast->SetInputData(rawResult);
193 imageCast->SetOutputScalarTypeToUnsignedChar();
195 rawResult = imageCast->GetOutput();
199 mRawResult = rawResult;
201 if (generateSurface->getValue())
203 double threshold = 1;
220 QString uid = input->getUid() +
"_seg%1";
221 QString name = input->getName()+
" seg%1";
228 output->setInitialWindowLevel(-1, -1);
229 output->resetTransferFunctions();
230 mServices->patient()->insertData(output);
236 if (mRawContour!=NULL)