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)
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
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)
vtkSmartPointer< vtkPolyData > vtkPolyDataPtr
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()
Namespace for all CustusX production code.