MITK-IGT
IGT Extension of MITK
Loading...
Searching...
No Matches
QmitkToFCompositeFilterWidget.cpp
Go to the documentation of this file.
1/*============================================================================
2
3The Medical Imaging Interaction Toolkit (MITK)
4
5Copyright (c) German Cancer Research Center (DKFZ)
6All rights reserved.
7
8Use of this source code is governed by a 3-clause BSD license that can be
9found in the LICENSE file.
10
11============================================================================*/
12
14
15#include <mitkProperties.h>
16#include <mitkNodePredicateAnd.h>
17#include <mitkNodePredicateDataType.h>
18#include <mitkNodePredicateProperty.h>
19
20const std::string QmitkToFCompositeFilterWidget::VIEW_ID = "org.mitk.views.qmitktofcompositefilterwidget";
21
22QmitkToFCompositeFilterWidget::QmitkToFCompositeFilterWidget(QWidget* parent, Qt::WindowFlags f): QWidget(parent, f)
23{
24 this->m_ToFCompositeFilter = nullptr;
25
26 m_Controls = nullptr;
28}
29
33
35{
36 if (!m_Controls)
37 {
38 // create GUI widgets
39 m_Controls = new Ui::QmitkToFCompositeFilterWidgetControls;
40 m_Controls->setupUi(parent);
41
42 int min = m_Controls->m_ThresholdFilterMinValueSpinBox->value();
43 int max = m_Controls->m_ThresholdFilterMaxValueSpinBox->value();
44 m_Controls->m_ThresholdFilterRangeSlider->setMinimum(min);
45 m_Controls->m_ThresholdFilterRangeSlider->setMaximum(max);
46 m_Controls->m_ThresholdFilterRangeSlider->setMinimumValue(min);
47 m_Controls->m_ThresholdFilterRangeSlider->setMaximumValue(max);
48 this->CreateConnections();
49
51 }
52}
53
55{
56 if ( m_Controls )
57 {
58 connect(m_Controls->m_TemporalMedianFilterNumOfFramesSpinBox, SIGNAL(valueChanged(int)), this, SLOT(OnTemporalMedianFilterNumOfFramesSpinBoxValueChanged(int)));
59 connect(m_Controls->m_BilateralFilterDomainSigmaSpinBox, SIGNAL(valueChanged(double)), this, SLOT(OnBilateralFilterDomainSigmaSpinBoxValueChanged(double)));
60 connect(m_Controls->m_BilateralFilterRangeSigmaSpinBox, SIGNAL(valueChanged(double)), this, SLOT(OnBilateralFilterRangeSigmaSpinBoxValueChanged(double)));
61 connect(m_Controls->m_BilateralFilterKernelRadiusSpinBox, SIGNAL(valueChanged(int)), this, SLOT(OnBilateralFilterKernelRadiusSpinBoxValueChanged(int)));
62 connect(m_Controls->m_ThresholdFilterMinValueSpinBox, SIGNAL(valueChanged(int)), this, SLOT(OnThresholdFilterMinValueChanged(int)));
63 connect(m_Controls->m_ThresholdFilterMaxValueSpinBox, SIGNAL(valueChanged(int)), this, SLOT(OnThresholdFilterMaxValueChanged(int)));
64
65 connect( (QObject*)(m_Controls->m_TemporalMedianFilterCheckBox), SIGNAL(toggled(bool)), this, SLOT(OnTemporalMedianFilterCheckBoxChecked(bool)) );
66 connect( (QObject*)(m_Controls->m_AverageFilterCheckBox), SIGNAL(toggled(bool)), this, SLOT(OnAverageFilterCheckBoxChecked(bool)) );
67 connect( (QObject*)(m_Controls->m_ThresholdFilterCheckBox), SIGNAL(toggled(bool)), this, SLOT(OnThresholdFilterCheckBoxChecked(bool)) );
68 connect( (QObject*)(m_Controls->maskSegmentationCheckBox), SIGNAL(toggled(bool)), this, SLOT(OnMaskSegmentationCheckBoxChecked(bool)) );
69 connect( (QObject*)(m_Controls->m_BilateralFilterCheckBox), SIGNAL(toggled(bool)), this, SLOT(OnBilateralFilterCheckBoxChecked(bool)) );
70 connect( (QObject*)(m_Controls->m_MedianFilterCheckBox), SIGNAL(toggled(bool)), this, SLOT(OnMedianFilterCheckBoxChecked(bool)) );
71 connect( (QObject*)(m_Controls->m_ShowAdvancedOptionsCheckbox), SIGNAL(toggled(bool)), this, SLOT(OnShowAdvancedOptionsCheckboxChecked(bool)) );
72
73 connect(m_Controls->m_ThresholdFilterRangeSlider, SIGNAL(valuesChanged(int, int) ),this, SLOT( OnSpanChanged(int , int ) ));
74
75 //reset button
76 connect(m_Controls->m_ThresholdFilterRangeSliderReset, SIGNAL(pressed()), this, SLOT(OnResetThresholdFilterRangeSlider()));
77
78 }
79}
80
82{
83 this->m_ToFCompositeFilter = toFCompositeFilter;
84}
85
87{
88 if (this->m_ToFCompositeFilter.IsNull())
89 {
90 this->m_ToFCompositeFilter = mitk::ToFCompositeFilter::New();
91 }
92 return this->m_ToFCompositeFilter;
93}
94
95void QmitkToFCompositeFilterWidget::SetDataStorage(mitk::DataStorage::Pointer dataStorage)
96{
97 m_DataStorage = dataStorage;
98 m_Controls->maskImageComboBox->SetDataStorage(dataStorage);
99 m_Controls->maskImageComboBox->SetPredicate(mitk::NodePredicateAnd::New(mitk::NodePredicateDataType::New("Image"),mitk::NodePredicateProperty::New("binary", mitk::BoolProperty::New(true))));
100}
101
103{
104 OnTemporalMedianFilterCheckBoxChecked(m_Controls->m_TemporalMedianFilterCheckBox->isChecked());
105 OnAverageFilterCheckBoxChecked(m_Controls->m_AverageFilterCheckBox->isChecked());
106 OnMedianFilterCheckBoxChecked(m_Controls->m_MedianFilterCheckBox->isChecked());
107 OnThresholdFilterCheckBoxChecked(m_Controls->m_ThresholdFilterCheckBox->isChecked());
108 OnBilateralFilterCheckBoxChecked(m_Controls->m_BilateralFilterCheckBox->isChecked());
109}
110
111void QmitkToFCompositeFilterWidget::SetWidgetConfiguration(bool threshold, bool mask, bool tempMedian, bool tempAverage, bool median, bool bilateral )
112{
113 m_Controls->m_ThresholdFilterCheckBox->setChecked(threshold);
114 m_Controls->maskSegmentationCheckBox->setChecked(mask);
115 m_Controls->m_TemporalMedianFilterCheckBox->setChecked(tempMedian);
116 m_Controls->m_AverageFilterCheckBox->setChecked(tempAverage);
117 m_Controls->m_MedianFilterCheckBox->setChecked(median);
118 m_Controls->m_BilateralFilterCheckBox->setChecked(bilateral);
119}
120
121void QmitkToFCompositeFilterWidget::SetStandardParametersBilateralFilter(double domainSigma, double rangeSigma, int kernelRadius)
122{
123 m_Controls->m_BilateralFilterDomainSigmaSpinBox->setValue(domainSigma);
124 m_Controls->m_BilateralFilterRangeSigmaSpinBox->setValue(rangeSigma);
125 m_Controls->m_BilateralFilterKernelRadiusSpinBox->setValue(kernelRadius);
126}
127
129{
130 m_Controls->m_ThresholdFilterMinValueSpinBox->setValue(min);
131 m_Controls->m_ThresholdFilterMaxValueSpinBox->setValue(max);
132}
133
135{
136 m_Controls->m_TemporalMedianFilterNumOfFramesSpinBox->setValue(nImages);
137}
138
140{
141 this->m_ToFCompositeFilter->SetApplyTemporalMedianFilter(checked);
142 // disable average filter if temporal median filter is enabled
143 if (checked)
144 {
145 m_Controls->m_AverageFilterCheckBox->setChecked(false);
146 this->m_ToFCompositeFilter->SetApplyAverageFilter(false);
147 }
148}
149
151{
152 this->m_ToFCompositeFilter->SetApplyAverageFilter(checked);
153 // disable temporal median filter if average filter is enabled
154 if (checked)
155 {
156 m_Controls->m_TemporalMedianFilterCheckBox->setChecked(false);
157 this->m_ToFCompositeFilter->SetApplyTemporalMedianFilter(false);
158 }
159}
160
162{
163 this->m_Controls->m_AverageFilterCheckBox->setVisible(checked);
164 this->m_Controls->m_BilateralFilterCheckBox->setVisible(checked);
165 this->m_Controls->m_BilateralFilterDomainSigmaSpinBox->setVisible(checked);
166 this->m_Controls->m_BilateralFilterKernelRadiusSpinBox->setVisible(checked);
167 this->m_Controls->m_BilateralFilterRangeSigmaSpinBox->setVisible(checked);
168 this->m_Controls->m_MedianFilterCheckBox->setVisible(checked);
169 this->m_Controls->m_TemporalMedianFilterCheckBox->setVisible(checked);
170 this->m_Controls->m_TemporalMedianFilterNumOfFramesSpinBox->setVisible(checked);
171 this->m_Controls->m_ThresholdFilterCheckBox->setVisible(checked);
172 this->m_Controls->m_ThresholdFilterMaxValueSpinBox->setVisible(checked);
173 this->m_Controls->m_ThresholdFilterMinValueSpinBox->setVisible(checked);
174 this->m_Controls->m_ThresholdFilterRangeSlider->setVisible(checked);
175 this->m_Controls->m_ThresholdFilterRangeSliderReset->setVisible(checked);
176 this->m_Controls->label_3->setVisible(checked);
177 this->m_Controls->label_4->setVisible(checked);
178 this->m_Controls->label_12->setVisible(checked);
179 this->m_Controls->maskImageComboBox->setVisible(checked);
180 this->m_Controls->maskSegmentationCheckBox->setVisible(checked);
181}
182
184{
185 this->m_ToFCompositeFilter->SetApplyThresholdFilter(checked);
186}
187
189{
190 this->m_ToFCompositeFilter->SetApplyMaskSegmentation(checked);
191 if (checked)
192 {
193 mitk::DataNode::Pointer maskImageNode = m_Controls->maskImageComboBox->GetSelectedNode();
194 if (maskImageNode.IsNotNull())
195 {
196 mitk::Image::Pointer maskImage = dynamic_cast<mitk::Image*>(maskImageNode->GetData());
197 this->m_ToFCompositeFilter->SetSegmentationMask(maskImage);
198 }
199 }
200}
201
203{
204 this->m_ToFCompositeFilter->SetApplyMedianFilter(checked);
205}
206
208{
209 this->m_ToFCompositeFilter->SetApplyBilateralFilter(checked);
210}
211
213{
214 this->m_ToFCompositeFilter->SetTemporalMedianFilterParameter(value);
215}
216
218{
219 SetBilateralFilterParameter();
220}
221
223{
224 SetBilateralFilterParameter();
225}
226
228{
229 SetBilateralFilterParameter();
230}
231
233{
234 m_Controls->m_ThresholdFilterRangeSlider->setMinimumValue(value);
235 SetThresholdFilterParameter();
236}
237
239{
240 m_Controls->m_ThresholdFilterRangeSlider->setMaximumValue(value);
241 SetThresholdFilterParameter();
242}
243
244
245void QmitkToFCompositeFilterWidget::SetThresholdFilterParameter()
246{
247 int min = m_Controls->m_ThresholdFilterMinValueSpinBox->value();
248 int max = m_Controls->m_ThresholdFilterMaxValueSpinBox->value();
249 this->m_ToFCompositeFilter->SetThresholdFilterParameter(min, max);
250}
251
252void QmitkToFCompositeFilterWidget::SetBilateralFilterParameter()
253{
254 double domainSigma = m_Controls->m_BilateralFilterDomainSigmaSpinBox->value();
255 double rangeSigma = m_Controls->m_BilateralFilterRangeSigmaSpinBox->value();
256 int kernelRadius = m_Controls->m_BilateralFilterKernelRadiusSpinBox->value();
257 this->m_ToFCompositeFilter->SetBilateralFilterParameter(domainSigma, rangeSigma, kernelRadius);
258}
259
261{
262 int lowerVal = m_Controls->m_ThresholdFilterRangeSlider->minimumValue();
263 int upperVal = m_Controls->m_ThresholdFilterRangeSlider->maximumValue();
264
265 m_Controls->m_ThresholdFilterMinValueSpinBox->setValue(lowerVal);
266 m_Controls->m_ThresholdFilterMaxValueSpinBox->setValue(upperVal);
267}
268
270{
271 int lower = 1;
272 int upper = 7000;
273
274 m_Controls->m_ThresholdFilterRangeSlider->setMinimumValue(lower);
275 m_Controls->m_ThresholdFilterRangeSlider->setMaximumValue(upper);
276
277 m_Controls->m_ThresholdFilterMinValueSpinBox->setValue(lower);
278 m_Controls->m_ThresholdFilterMaxValueSpinBox->setValue(upper);
279}
void UpdateFilterParameter()
update parameters of ToFCompositeFilter according to current GUI setting
void OnTemporalMedianFilterNumOfFramesSpinBoxValueChanged(int value)
slot updating the parameter "number of frames" of the temporal median filter in the ToFCompositeFilte...
void OnResetThresholdFilterRangeSlider()
slot resetting threshold range slider to default values (min: 1, max: 7000)
void SetStandardParametersBilateralFilter(double domainSigma, double rangeSigma, int kernelRadius=0)
sets the standard parameters used for the bilateral filter to the ComboBoxes used in the GUI
void OnBilateralFilterDomainSigmaSpinBoxValueChanged(double value)
slot updating the parameter "domain sigma" of the bilateral filter in the ToFCompositeFilter
void OnBilateralFilterRangeSigmaSpinBoxValueChanged(double value)
slot updating the paramter "range sigma" of the bilateral filter in the ToFCompositeFilter
void SetWidgetConfiguration(bool threshold, bool mask, bool tempMedian, bool tempAverage, bool median, bool bilateral)
set the configuration of the widget specifying which filter is enabled on start
void SetToFCompositeFilter(mitk::ToFCompositeFilter *toFCompositeFilter)
Sets the ToFCompositeFilter used by this widget.
void OnThresholdFilterMinValueChanged(int value)
slot updating the paramter "minimal threshold" of the threshold filter in the ToFCompositeFilter
mitk::ToFCompositeFilter::Pointer m_ToFCompositeFilter
member holding the internally used ToFCompositeFilter
void OnThresholdFilterMaxValueChanged(int value)
slot updating the paramter "maximal threshold" of the threshold filter in the ToFCompositeFilter
void OnTemporalMedianFilterCheckBoxChecked(bool checked)
slot en-/disabling temporal median filter in internal ToFCompositeFilter
QmitkToFCompositeFilterWidget(QWidget *p=nullptr, Qt::WindowFlags f1={})
void OnAverageFilterCheckBoxChecked(bool checked)
slot en-/disabling average filter in internal ToFCompositeFilter
void OnBilateralFilterKernelRadiusSpinBoxValueChanged(int value)
slot updating the paramter "kernel radius" of the bilateral filter in the ToFCompositeFilter
void OnShowAdvancedOptionsCheckboxChecked(bool checked)
OnShowAdvancedOptionsCheckboxChecked Show/hide advanced options.
void SetStandardParametersThresholdFilter(int min, int max)
set the standard parameters for the threshold filter to the combo boxes in the GUI
void OnThresholdFilterCheckBoxChecked(bool checked)
slot en-/disabling threshold filter in internal ToFCompositeFilter
void SetStandardParameterTemporalAveraging(int nImages)
set the standard value for the number of images to be averaged to the combo box in the GUI
virtual void CreateQtPartControl(QWidget *parent)
void SetDataStorage(mitk::DataStorage::Pointer dataStorage)
mitk::ToFCompositeFilter * GetToFCompositeFilter()
Returns the ToFCompositeFilter used by this widget.
void OnBilateralFilterCheckBoxChecked(bool checked)
slot en-/disabling bilateral filter in internal ToFCompositeFilter
void OnMaskSegmentationCheckBoxChecked(bool checked)
slot en-/disabling the mask segmentation in internal ToFCompositeFilter
void OnSpanChanged(int lower, int upper)
slot updating threshold spin boxes according to slider position
void OnMedianFilterCheckBoxChecked(bool checked)
slot en-/disabling median filter in internal ToFCompositeFilter
Ui::QmitkToFCompositeFilterWidgetControls * m_Controls
member holding the UI elements of this widget
Applies a common filter-pipeline to the first input of this filter.