36 #include <itkBinaryThresholdImageFilter.h>
37 #include <vtkImageCast.h>
64 return "Segmentation";
69 return "BinaryThresholdImageFilter";
75 "<h3>Binary Threshold Image Filter.</h3>"
76 "<p><i>Segment out areas from the selected image using a threshold.</i></p>"
77 "<p>This filter produces an output image whose pixels are either one of two values"
78 "( OutsideValue or InsideValue ), depending on whether the corresponding input"
79 "image pixels lie between the two thresholds ( LowerThreshold and UpperThreshold )."
80 "Values equal to either threshold is considered to be between the thresholds.<p>"
87 "Select lower and upper threshold for the segmentation",
DoubleRange(0, 100, 1), 0,
95 "Generate a surface of the output volume",
true,
103 "Color of output model.",
104 QColor(
"green"), root);
110 connect(mThresholdOption.get(), SIGNAL(
changed()),
this, SLOT(thresholdSlot()));
121 temp->setValueName(
"Input");
122 temp->setHelp(
"Select image input for thresholding");
123 connect(temp.get(), SIGNAL(dataChanged(QString)),
this, SLOT(imageChangedSlot(QString)));
132 temp->setValueName(
"Output");
133 temp->setHelp(
"Output thresholded binary image");
137 temp->setValueName(
"Contour");
138 temp->setHelp(
"Output contour generated from thresholded binary image.");
147 mServices->visualizationService->removePreview();
150 void BinaryThresholdImageFilter::imageChangedSlot(QString uid)
153 mServices->visualizationService->removePreview();
156 void BinaryThresholdImageFilter::thresholdSlot()
161 std::vector<double> threshold;
162 threshold.push_back(mThresholdOption->getValue()[0]);
163 threshold.push_back(mThresholdOption->getValue()[1]);
164 mServices->visualizationService->setPreview(image, threshold);
170 mServices->visualizationService->removePreview();
187 typedef itk::BinaryThresholdImageFilter<itkImageType, itkImageType> thresholdFilterType;
188 thresholdFilterType::Pointer thresholdFilter = thresholdFilterType::New();
189 thresholdFilter->SetInput(itkImage);
190 thresholdFilter->SetOutsideValue(0);
191 thresholdFilter->SetInsideValue(1);
192 thresholdFilter->SetLowerThreshold(thresholds->getValue()[0]);
193 thresholdFilter->SetUpperThreshold(thresholds->getValue()[1]);
194 thresholdFilter->Update();
195 itkImage = thresholdFilter->GetOutput();
199 itkToVtkFilter->SetInput(itkImage);
200 itkToVtkFilter->Update();
203 rawResult->DeepCopy(itkToVtkFilter->GetOutput());
206 imageCast->SetInputData(rawResult);
207 imageCast->SetOutputScalarTypeToUnsignedChar();
209 rawResult = imageCast->GetOutput();
213 mRawResult = rawResult;
215 if (generateSurface->getValue())
217 double threshold = 1;
234 QString uid = input->getUid() +
"_seg%1";
235 QString name = input->getName()+
" seg%1";
242 output->resetTransferFunctions();
243 mServices->getPatientService()->insertData(output);
249 if (mRawContour!=NULL)
static BoolPropertyPtr initialize(const QString &uid, QString name, QString help, bool value, QDomNode root=QDomNode())
std::vector< SelectDataStringPropertyBasePtr > mInputTypes
QDomElement mCopiedOptions
boost::shared_ptr< class ColorProperty > ColorPropertyPtr
boost::shared_ptr< class VisServices > VisServicesPtr
virtual bool preProcess()
void updateThresholdPairFromImageChange(QString uid, DoublePairPropertyPtr threshold)
Utility class for describing a bounded numeric range.
boost::shared_ptr< class Image > ImagePtr
BoolPropertyPtr getGenerateSurfaceOption(QDomElement root)
virtual QString getName() const
virtual QString getType() const
vtkSmartPointer< class vtkPolyData > vtkPolyDataPtr
virtual bool postProcess()
std::vector< PropertyPtr > mOptionsAdapters
ImagePtr createDerivedImage(PatientModelServicePtr dataManager, QString uid, QString name, vtkImageDataPtr raw, ImagePtr parent)
boost::shared_ptr< class SelectDataStringPropertyBase > SelectDataStringPropertyBasePtr
virtual void createOutputTypes()
DoublePairPropertyPtr getThresholdOption(QDomElement root)
SmartPointer< Self > Pointer
ImagePtr getCopiedInputImage(int index=0)
virtual void setActive(bool on)
vtkSmartPointer< class vtkImageCast > vtkImageCastPtr
virtual QString getHelp() const
static StringPropertySelectDataPtr New(PatientModelServicePtr patientModelService)
ColorPropertyPtr getColorOption(QDomElement root)
virtual void createInputTypes()
std::vector< SelectDataStringPropertyBasePtr > mOutputTypes
boost::shared_ptr< class DoublePairProperty > DoublePairPropertyPtr
static DoublePairPropertyPtr initialize(const QString &uid, QString name, QString help, DoubleRange range, int decimals, QDomNode root=QDomNode())
virtual bool postProcess()
static itkImageType::ConstPointer getITKfromSSCImage(ImagePtr image)
static StringPropertySelectImagePtr New(PatientModelServicePtr patientModelService)
BinaryThresholdImageFilter(VisServicesPtr services)
static ColorPropertyPtr initialize(const QString &uid, QString name, QString help, QColor value, QDomNode root=QDomNode())
boost::shared_ptr< class BoolProperty > BoolPropertyPtr
boost::shared_ptr< class Mesh > MeshPtr
virtual void setActive(bool on)
virtual void createOptions()