Medical Imaging Interaction Toolkit  2016.11.0
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
18 
19 #include <mitkProperties.h>
20 #include <mitkNodePredicateAnd.h>
23 
24 const std::string QmitkToFCompositeFilterWidget::VIEW_ID = "org.mitk.views.qmitktofcompositefilterwidget";
25 
26 QmitkToFCompositeFilterWidget::QmitkToFCompositeFilterWidget(QWidget* parent, Qt::WindowFlags f): QWidget(parent, f)
27 {
28  this->m_ToFCompositeFilter = NULL;
29 
30  m_Controls = NULL;
31  CreateQtPartControl(this);
32 }
33 
35 {
36 }
37 
39 {
40  if (!m_Controls)
41  {
42  // create GUI widgets
43  m_Controls = new Ui::QmitkToFCompositeFilterWidgetControls;
44  m_Controls->setupUi(parent);
45 
46  int min = m_Controls->m_ThresholdFilterMinValueSpinBox->value();
47  int max = m_Controls->m_ThresholdFilterMaxValueSpinBox->value();
48  m_Controls->m_ThresholdFilterRangeSlider->setMinimum(min);
49  m_Controls->m_ThresholdFilterRangeSlider->setMaximum(max);
50  m_Controls->m_ThresholdFilterRangeSlider->setMinimumValue(min);
51  m_Controls->m_ThresholdFilterRangeSlider->setMaximumValue(max);
52  this->CreateConnections();
53 
55  }
56 }
57 
59 {
60  if ( m_Controls )
61  {
62  connect(m_Controls->m_TemporalMedianFilterNumOfFramesSpinBox, SIGNAL(valueChanged(int)), this, SLOT(OnTemporalMedianFilterNumOfFramesSpinBoxValueChanged(int)));
63  connect(m_Controls->m_BilateralFilterDomainSigmaSpinBox, SIGNAL(valueChanged(double)), this, SLOT(OnBilateralFilterDomainSigmaSpinBoxValueChanged(double)));
64  connect(m_Controls->m_BilateralFilterRangeSigmaSpinBox, SIGNAL(valueChanged(double)), this, SLOT(OnBilateralFilterRangeSigmaSpinBoxValueChanged(double)));
65  connect(m_Controls->m_BilateralFilterKernelRadiusSpinBox, SIGNAL(valueChanged(int)), this, SLOT(OnBilateralFilterKernelRadiusSpinBoxValueChanged(int)));
66  connect(m_Controls->m_ThresholdFilterMinValueSpinBox, SIGNAL(valueChanged(int)), this, SLOT(OnThresholdFilterMinValueChanged(int)));
67  connect(m_Controls->m_ThresholdFilterMaxValueSpinBox, SIGNAL(valueChanged(int)), this, SLOT(OnThresholdFilterMaxValueChanged(int)));
68 
69  connect( (QObject*)(m_Controls->m_TemporalMedianFilterCheckBox), SIGNAL(toggled(bool)), this, SLOT(OnTemporalMedianFilterCheckBoxChecked(bool)) );
70  connect( (QObject*)(m_Controls->m_AverageFilterCheckBox), SIGNAL(toggled(bool)), this, SLOT(OnAverageFilterCheckBoxChecked(bool)) );
71  connect( (QObject*)(m_Controls->m_ThresholdFilterCheckBox), SIGNAL(toggled(bool)), this, SLOT(OnThresholdFilterCheckBoxChecked(bool)) );
72  connect( (QObject*)(m_Controls->maskSegmentationCheckBox), SIGNAL(toggled(bool)), this, SLOT(OnMaskSegmentationCheckBoxChecked(bool)) );
73  connect( (QObject*)(m_Controls->m_BilateralFilterCheckBox), SIGNAL(toggled(bool)), this, SLOT(OnBilateralFilterCheckBoxChecked(bool)) );
74  connect( (QObject*)(m_Controls->m_MedianFilterCheckBox), SIGNAL(toggled(bool)), this, SLOT(OnMedianFilterCheckBoxChecked(bool)) );
75  connect( (QObject*)(m_Controls->m_ShowAdvancedOptionsCheckbox), SIGNAL(toggled(bool)), this, SLOT(OnShowAdvancedOptionsCheckboxChecked(bool)) );
76 
77  connect(m_Controls->m_ThresholdFilterRangeSlider, SIGNAL(spanChanged(int, int) ),this, SLOT( OnSpanChanged(int , int ) ));
78 
79  //reset button
80  connect(m_Controls->m_ThresholdFilterRangeSliderReset, SIGNAL(pressed()), this, SLOT(OnResetThresholdFilterRangeSlider()));
81 
82  }
83 }
84 
86 {
87  this->m_ToFCompositeFilter = toFCompositeFilter;
88 }
89 
91 {
92  if (this->m_ToFCompositeFilter.IsNull())
93  {
95  }
96  return this->m_ToFCompositeFilter;
97 }
98 
100 {
101  m_DataStorage = dataStorage;
102  m_Controls->maskImageComboBox->SetDataStorage(dataStorage);
104 }
105 
107 {
108  OnTemporalMedianFilterCheckBoxChecked(m_Controls->m_TemporalMedianFilterCheckBox->isChecked());
109  OnAverageFilterCheckBoxChecked(m_Controls->m_AverageFilterCheckBox->isChecked());
110  OnMedianFilterCheckBoxChecked(m_Controls->m_MedianFilterCheckBox->isChecked());
111  OnThresholdFilterCheckBoxChecked(m_Controls->m_ThresholdFilterCheckBox->isChecked());
112  OnBilateralFilterCheckBoxChecked(m_Controls->m_BilateralFilterCheckBox->isChecked());
113 }
114 
115 void QmitkToFCompositeFilterWidget::SetWidgetConfiguration(bool threshold, bool mask, bool tempMedian, bool tempAverage, bool median, bool bilateral )
116 {
117  m_Controls->m_ThresholdFilterCheckBox->setChecked(threshold);
118  m_Controls->maskSegmentationCheckBox->setChecked(mask);
119  m_Controls->m_TemporalMedianFilterCheckBox->setChecked(tempMedian);
120  m_Controls->m_AverageFilterCheckBox->setChecked(tempAverage);
121  m_Controls->m_MedianFilterCheckBox->setChecked(median);
122  m_Controls->m_BilateralFilterCheckBox->setChecked(bilateral);
123 }
124 
125 void QmitkToFCompositeFilterWidget::SetStandardParametersBilateralFilter(double domainSigma, double rangeSigma, int kernelRadius)
126 {
127  m_Controls->m_BilateralFilterDomainSigmaSpinBox->setValue(domainSigma);
128  m_Controls->m_BilateralFilterRangeSigmaSpinBox->setValue(rangeSigma);
129  m_Controls->m_BilateralFilterKernelRadiusSpinBox->setValue(kernelRadius);
130 }
131 
133 {
134  m_Controls->m_ThresholdFilterMinValueSpinBox->setValue(min);
135  m_Controls->m_ThresholdFilterMaxValueSpinBox->setValue(max);
136 }
137 
139 {
140  m_Controls->m_TemporalMedianFilterNumOfFramesSpinBox->setValue(nImages);
141 }
142 
144 {
145  this->m_ToFCompositeFilter->SetApplyTemporalMedianFilter(checked);
146  // disable average filter if temporal median filter is enabled
147  if (checked)
148  {
149  m_Controls->m_AverageFilterCheckBox->setChecked(false);
150  this->m_ToFCompositeFilter->SetApplyAverageFilter(false);
151  }
152 }
153 
155 {
156  this->m_ToFCompositeFilter->SetApplyAverageFilter(checked);
157  // disable temporal median filter if average filter is enabled
158  if (checked)
159  {
160  m_Controls->m_TemporalMedianFilterCheckBox->setChecked(false);
161  this->m_ToFCompositeFilter->SetApplyTemporalMedianFilter(false);
162  }
163 }
164 
166 {
167  this->m_Controls->m_AverageFilterCheckBox->setVisible(checked);
168  this->m_Controls->m_BilateralFilterCheckBox->setVisible(checked);
169  this->m_Controls->m_BilateralFilterDomainSigmaSpinBox->setVisible(checked);
170  this->m_Controls->m_BilateralFilterKernelRadiusSpinBox->setVisible(checked);
171  this->m_Controls->m_BilateralFilterRangeSigmaSpinBox->setVisible(checked);
172  this->m_Controls->m_MedianFilterCheckBox->setVisible(checked);
173  this->m_Controls->m_TemporalMedianFilterCheckBox->setVisible(checked);
174  this->m_Controls->m_TemporalMedianFilterNumOfFramesSpinBox->setVisible(checked);
175  this->m_Controls->m_ThresholdFilterCheckBox->setVisible(checked);
176  this->m_Controls->m_ThresholdFilterMaxValueSpinBox->setVisible(checked);
177  this->m_Controls->m_ThresholdFilterMinValueSpinBox->setVisible(checked);
178  this->m_Controls->m_ThresholdFilterRangeSlider->setVisible(checked);
179  this->m_Controls->m_ThresholdFilterRangeSliderReset->setVisible(checked);
180  this->m_Controls->label_3->setVisible(checked);
181  this->m_Controls->label_4->setVisible(checked);
182  this->m_Controls->label_12->setVisible(checked);
183  this->m_Controls->maskImageComboBox->setVisible(checked);
184  this->m_Controls->maskSegmentationCheckBox->setVisible(checked);
185 }
186 
188 {
189  this->m_ToFCompositeFilter->SetApplyThresholdFilter(checked);
190 }
191 
193 {
194  this->m_ToFCompositeFilter->SetApplyMaskSegmentation(checked);
195  if (checked)
196  {
197  mitk::DataNode::Pointer maskImageNode = m_Controls->maskImageComboBox->GetSelectedNode();
198  if (maskImageNode.IsNotNull())
199  {
200  mitk::Image::Pointer maskImage = dynamic_cast<mitk::Image*>(maskImageNode->GetData());
201  this->m_ToFCompositeFilter->SetSegmentationMask(maskImage);
202  }
203  }
204 }
205 
207 {
208  this->m_ToFCompositeFilter->SetApplyMedianFilter(checked);
209 }
210 
212 {
213  this->m_ToFCompositeFilter->SetApplyBilateralFilter(checked);
214 }
215 
217 {
218  this->m_ToFCompositeFilter->SetTemporalMedianFilterParameter(value);
219 }
220 
222 {
223  SetBilateralFilterParameter();
224 }
225 
227 {
228  SetBilateralFilterParameter();
229 }
230 
232 {
233  SetBilateralFilterParameter();
234 }
235 
237 {
238  m_Controls->m_ThresholdFilterRangeSlider->setMinimumValue(value);
239  SetThresholdFilterParameter();
240 }
241 
243 {
244  m_Controls->m_ThresholdFilterRangeSlider->setMaximumValue(value);
245  SetThresholdFilterParameter();
246 }
247 
248 
249 void QmitkToFCompositeFilterWidget::SetThresholdFilterParameter()
250 {
251  int min = m_Controls->m_ThresholdFilterMinValueSpinBox->value();
252  int max = m_Controls->m_ThresholdFilterMaxValueSpinBox->value();
253  this->m_ToFCompositeFilter->SetThresholdFilterParameter(min, max);
254 }
255 
256 void QmitkToFCompositeFilterWidget::SetBilateralFilterParameter()
257 {
258  double domainSigma = m_Controls->m_BilateralFilterDomainSigmaSpinBox->value();
259  double rangeSigma = m_Controls->m_BilateralFilterRangeSigmaSpinBox->value();
260  int kernelRadius = m_Controls->m_BilateralFilterKernelRadiusSpinBox->value();
261  this->m_ToFCompositeFilter->SetBilateralFilterParameter(domainSigma, rangeSigma, kernelRadius);
262 }
263 
265 {
266  int lowerVal = m_Controls->m_ThresholdFilterRangeSlider->minimumValue();
267  int upperVal = m_Controls->m_ThresholdFilterRangeSlider->maximumValue();
268 
269  m_Controls->m_ThresholdFilterMinValueSpinBox->setValue(lowerVal);
270  m_Controls->m_ThresholdFilterMaxValueSpinBox->setValue(upperVal);
271 }
272 
274 {
275  int lower = 1;
276  int upper = 7000;
277 
278  m_Controls->m_ThresholdFilterRangeSlider->setMinimumValue(lower);
279  m_Controls->m_ThresholdFilterRangeSlider->setMaximumValue(upper);
280 
281  m_Controls->m_ThresholdFilterMinValueSpinBox->setValue(lower);
282  m_Controls->m_ThresholdFilterMaxValueSpinBox->setValue(upper);
283 }
QmitkToFCompositeFilterWidget(QWidget *p=0, Qt::WindowFlags f1=0)
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()
Image class for storing images.
Definition: mitkImage.h:76
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:70
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:67
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 ...
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 ...