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 the lower and upper thresholds for the segmentation",
DoubleRange(0, 100, 1), 0,
95 "Generate a surface of the output volume",
true,
103 "The color of the output model.",
104 QColor(
"green"), root);
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.");
150 void BinaryThresholdImageFilter::imageChangedSlot(QString uid)
156 void BinaryThresholdImageFilter::stopPreview()
170 Eigen::Vector2d threshold = Eigen::Vector2d(mThresholdOption->getValue()[0], mThresholdOption->getValue()[1]);
194 typedef itk::BinaryThresholdImageFilter<itkImageType, itkImageType> thresholdFilterType;
195 thresholdFilterType::Pointer thresholdFilter = thresholdFilterType::New();
196 thresholdFilter->SetInput(itkImage);
197 thresholdFilter->SetOutsideValue(0);
198 thresholdFilter->SetInsideValue(1);
199 thresholdFilter->SetLowerThreshold(thresholds->getValue()[0]);
200 thresholdFilter->SetUpperThreshold(thresholds->getValue()[1]);
201 thresholdFilter->Update();
202 itkImage = thresholdFilter->GetOutput();
206 itkToVtkFilter->SetInput(itkImage);
207 itkToVtkFilter->Update();
210 rawResult->DeepCopy(itkToVtkFilter->GetOutput());
213 imageCast->SetInputData(rawResult);
214 imageCast->SetOutputScalarTypeToUnsignedChar();
216 rawResult = imageCast->GetOutput();
220 mRawResult = rawResult;
222 if (generateSurface->getValue())
224 double threshold = 1;
241 QString uid = input->getUid() +
"_seg%1";
242 QString name = input->getName()+
" seg%1";
249 output->resetTransferFunctions();
250 mServices->patient()->insertData(output);
256 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)
static StringPropertySelectDataPtr New(PatientModelServicePtr patientModelService, QString typeRegexp=".*")
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
virtual bool postProcess()
std::vector< PropertyPtr > mOptionsAdapters
vtkSmartPointer< class vtkPolyData > vtkPolyDataPtr
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
void changed()
emit when the underlying data value is changed: The user interface will be updated.
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()