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.");
150 void BinaryThresholdImageFilter::imageChangedSlot(QString uid)
156 void BinaryThresholdImageFilter::stopPreview()
159 mPreviewImage->stopThresholdPreview();
160 mPreviewImage.reset();
163 void BinaryThresholdImageFilter::thresholdSlot()
168 mPreviewImage = boost::dynamic_pointer_cast<Image>(
mInputTypes[0]->getData());
169 Eigen::Vector2d threshold = Eigen::Vector2d(mThresholdOption->getValue()[0], mThresholdOption->getValue()[1]);
170 mPreviewImage->startThresholdPreview(threshold);
193 typedef itk::BinaryThresholdImageFilter<itkImageType, itkImageType> thresholdFilterType;
194 thresholdFilterType::Pointer thresholdFilter = thresholdFilterType::New();
195 thresholdFilter->SetInput(itkImage);
196 thresholdFilter->SetOutsideValue(0);
197 thresholdFilter->SetInsideValue(1);
198 thresholdFilter->SetLowerThreshold(thresholds->getValue()[0]);
199 thresholdFilter->SetUpperThreshold(thresholds->getValue()[1]);
200 thresholdFilter->Update();
201 itkImage = thresholdFilter->GetOutput();
205 itkToVtkFilter->SetInput(itkImage);
206 itkToVtkFilter->Update();
209 rawResult->DeepCopy(itkToVtkFilter->GetOutput());
212 imageCast->SetInputData(rawResult);
213 imageCast->SetOutputScalarTypeToUnsignedChar();
215 rawResult = imageCast->GetOutput();
219 mRawResult = rawResult;
221 if (generateSurface->getValue())
223 double threshold = 1;
240 QString uid = input->getUid() +
"_seg%1";
241 QString name = input->getName()+
" seg%1";
248 output->resetTransferFunctions();
249 mServices->getPatientService()->insertData(output);
255 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()