Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
QmitkToFCompositeFilterWidget.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
14 
15 #include <mitkProperties.h>
16 #include <mitkNodePredicateAnd.h>
19 
20 const std::string QmitkToFCompositeFilterWidget::VIEW_ID = "org.mitk.views.qmitktofcompositefilterwidget";
21 
22 QmitkToFCompositeFilterWidget::QmitkToFCompositeFilterWidget(QWidget* parent, Qt::WindowFlags f): QWidget(parent, f)
23 {
24  this->m_ToFCompositeFilter = nullptr;
25 
26  m_Controls = nullptr;
27  CreateQtPartControl(this);
28 }
29 
31 {
32 }
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  {
91  }
92  return this->m_ToFCompositeFilter;
93 }
94 
96 {
97  m_DataStorage = dataStorage;
98  m_Controls->maskImageComboBox->SetDataStorage(dataStorage);
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 
111 void 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 
121 void 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 
245 void 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 
252 void 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 OnShowAdvancedOptionsCheckboxChecked(bool checked)
OnShowAdvancedOptionsCheckboxChecked Show/hide advanced options.
void OnThresholdFilterCheckBoxChecked(bool checked)
slot en-/disabling threshold filter in internal ToFCompositeFilter
static Pointer New()
void OnThresholdFilterMaxValueChanged(int value)
slot updating the paramter "maximal threshold" of the threshold filter in the ToFCompositeFilter ...
void OnThresholdFilterMinValueChanged(int value)
slot updating the paramter "minimal threshold" of the threshold filter in the ToFCompositeFilter ...
Ui::QmitkToFCompositeFilterWidgetControls * m_Controls
member holding the UI elements of this widget
mitk::ToFCompositeFilter * GetToFCompositeFilter()
Returns the ToFCompositeFilter used by this widget.
void OnResetThresholdFilterRangeSlider()
slot resetting threshold range slider to default values (min: 1, max: 7000)
mitk::ToFCompositeFilter::Pointer m_ToFCompositeFilter
member holding the internally used ToFCompositeFilter
void SetStandardParametersThresholdFilter(int min, int max)
set the standard parameters for the threshold filter to the combo boxes in the GUI ...
void OnBilateralFilterCheckBoxChecked(bool checked)
slot en-/disabling bilateral filter in internal ToFCompositeFilter
void OnTemporalMedianFilterNumOfFramesSpinBoxValueChanged(int value)
slot updating the parameter "number of frames" of the temporal median filter in the ToFCompositeFilte...
void OnSpanChanged(int lower, int upper)
slot updating threshold spin boxes according to slider position
static Pointer New()
void SetToFCompositeFilter(mitk::ToFCompositeFilter *toFCompositeFilter)
Sets the ToFCompositeFilter used by this widget.
void OnBilateralFilterKernelRadiusSpinBoxValueChanged(int value)
slot updating the paramter "kernel radius" of the bilateral filter in the ToFCompositeFilter ...
virtual void CreateQtPartControl(QWidget *parent)
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
static Pointer New()
QmitkToFCompositeFilterWidget(QWidget *p=nullptr, Qt::WindowFlags f1=nullptr)
Image class for storing images.
Definition: mitkImage.h:72
void OnMedianFilterCheckBoxChecked(bool checked)
slot en-/disabling median filter in internal ToFCompositeFilter
void SetDataStorage(mitk::DataStorage::Pointer dataStorage)
static T max(T x, T y)
Definition: svm.cpp:56
void OnAverageFilterCheckBoxChecked(bool checked)
slot en-/disabling average filter in internal ToFCompositeFilter
static Pointer New(const char *_arg)
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 ...
static Pointer New(const char *_arg)
static T min(T x, T y)
Definition: svm.cpp:53
void OnTemporalMedianFilterCheckBoxChecked(bool checked)
slot en-/disabling temporal median filter in internal ToFCompositeFilter
void OnBilateralFilterDomainSigmaSpinBoxValueChanged(double value)
slot updating the parameter "domain sigma" of the bilateral filter in the ToFCompositeFilter ...
mitk::Image::Pointer mask
Applies a common filter-pipeline to the first input of this filter.
void UpdateFilterParameter()
update parameters of ToFCompositeFilter according to current GUI setting
void OnBilateralFilterRangeSigmaSpinBoxValueChanged(double value)
slot updating the paramter "range sigma" of the bilateral filter in the ToFCompositeFilter ...
void OnMaskSegmentationCheckBoxChecked(bool checked)
slot en-/disabling the mask segmentation 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 ...