Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
CamiTK
CamiTK Community Edition
Commits
697276ce
Commit
697276ce
authored
Apr 19, 2019
by
Tiffet Théophile
Browse files
Correction of the bug 62 (Manual Threshold value could only be between 0 and 255)
parent
f01a7319
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
imaging/actions/itksegmentation/ManualThreshold.cpp
View file @
697276ce
...
...
@@ -24,6 +24,7 @@
****************************************************************************/
// CamiTK incldues
#include "ManualThreshold.h"
#include "ActionWidget.h"
#include <Application.h>
#include <ItkProgressObserver.h>
#include <Property.h>
...
...
@@ -72,6 +73,40 @@ ManualThreshold::~ManualThreshold() {
// do not delete the widget has it might have been used in the ActionViewer (i.e. the ownership might have been taken by the stacked widget)
}
// --------------- trigger -------------------
Action
::
ApplyStatus
ManualThreshold
::
trigger
(
QWidget
*
parent
)
{
if
(
Action
::
trigger
(
parent
)
==
ERROR
)
return
ERROR
;
// Computing the maximum and the minimum possible value for the image
double
min
=
0
;
double
max
=
0
;
foreach
(
Component
*
comp
,
getTargets
())
{
vtkSmartPointer
<
vtkImageData
>
inputImage
=
dynamic_cast
<
ImageComponent
*>
(
comp
)
->
getImageData
();
if
(
min
>
inputImage
->
GetScalarTypeMin
())
min
=
inputImage
->
GetScalarTypeMin
();
if
(
max
<
inputImage
->
GetScalarTypeMax
())
max
=
inputImage
->
GetScalarTypeMax
();
}
// Applying those value to the thresholds
camitk
::
Property
*
lowThresholdProperty
=
getProperty
(
"Low threshold"
);
lowThresholdProperty
->
setAttribute
(
"minimum"
,
min
);
lowThresholdProperty
->
setAttribute
(
"maximum"
,
max
);
lowThresholdProperty
->
setAttribute
(
"singleStep"
,
(
max
-
min
)
/
255
);
addParameter
(
lowThresholdProperty
);
camitk
::
Property
*
highThresholdProperty
=
getProperty
(
"High threshold"
);
highThresholdProperty
->
setAttribute
(
"minimum"
,
min
);
highThresholdProperty
->
setAttribute
(
"maximum"
,
max
);
highThresholdProperty
->
setAttribute
(
"singleStep"
,
(
max
-
min
)
/
255
);
addParameter
(
highThresholdProperty
);
// Updating the widget
if
(
actionWidget
)
dynamic_cast
<
camitk
::
ActionWidget
*>
(
actionWidget
)
->
update
();
return
SUCCESS
;
}
// --------------- apply -------------------
Action
::
ApplyStatus
ManualThreshold
::
apply
()
{
foreach
(
Component
*
comp
,
getTargets
())
{
...
...
imaging/actions/itksegmentation/ManualThreshold.h
View file @
697276ce
...
...
@@ -47,6 +47,12 @@ public:
virtual
~
ManualThreshold
();
public
slots
:
/**
* This method triggers the action.
* The parent widget is used if the action is embedded, see class description for more information about the algorithm.
* This method cannot be redefined in inherited class.
*/
virtual
ApplyStatus
trigger
(
QWidget
*
parent
=
nullptr
);
/** this method is automatically called when the action is triggered.
* Use getTargets() QList to get the list of component to use.
* \note getTargets() is automatically filtered so that it only contains compatible components,
...
...
sdk/libraries/core/action/Action.h
View file @
697276ce
...
...
@@ -241,7 +241,7 @@ public slots:
* The parent widget is used if the action is embedded, see class description for more information about the algorithm.
* This method cannot be redefined in inherited class.
*/
ApplyStatus
trigger
(
QWidget
*
parent
=
nullptr
);
virtual
ApplyStatus
trigger
(
QWidget
*
parent
=
nullptr
);
/**
* This method is called when the action has to be applied on the target list (get the target lists using getTargets())
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment