Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
82cc95a7
Commit
82cc95a7
authored
Feb 08, 2013
by
Sebastian Eichelbaum
Browse files
[MERGE]
parents
9cc550f0
3000a29a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
15 deletions
+67
-15
src/modules/scalarSegmentation/WMScalarSegmentation.cpp
src/modules/scalarSegmentation/WMScalarSegmentation.cpp
+2
-1
src/modules/scalarSegmentation/WSegmentationAlgoThreshold.cpp
...modules/scalarSegmentation/WSegmentationAlgoThreshold.cpp
+30
-5
src/modules/scalarSegmentation/WSegmentationAlgoThreshold.h
src/modules/scalarSegmentation/WSegmentationAlgoThreshold.h
+35
-9
No files found.
src/modules/scalarSegmentation/WMScalarSegmentation.cpp
View file @
82cc95a7
...
...
@@ -40,7 +40,8 @@ WMScalarSegmentation::WMScalarSegmentation():
WModule
()
{
m_algoIndex
=
0
;
m_algos
.
push_back
(
boost
::
shared_ptr
<
WSegmentationAlgo
>
(
new
WSegmentationAlgoThreshold
()
)
);
m_algos
.
push_back
(
boost
::
shared_ptr
<
WSegmentationAlgo
>
(
new
WSegmentationAlgoThreshold
(
WSegmentationAlgoThreshold
::
LOWER_THRESHOLD
)
)
);
m_algos
.
push_back
(
boost
::
shared_ptr
<
WSegmentationAlgo
>
(
new
WSegmentationAlgoThreshold
(
WSegmentationAlgoThreshold
::
UPPER_THRESHOLD
)
)
);
#ifdef OW_USE_ITK
m_algos
.
push_back
(
boost
::
shared_ptr
<
WSegmentationAlgo
>
(
new
WSegmentationAlgoWatershed
()
)
);
m_algos
.
push_back
(
boost
::
shared_ptr
<
WSegmentationAlgo
>
(
new
WSegmentationAlgoOtsu
()
)
);
...
...
src/modules/scalarSegmentation/WSegmentationAlgoThreshold.cpp
View file @
82cc95a7
...
...
@@ -26,8 +26,9 @@
#include "WSegmentationAlgoThreshold.h"
WSegmentationAlgoThreshold
::
WSegmentationAlgoThreshold
()
:
WSegmentationAlgo
()
WSegmentationAlgoThreshold
::
WSegmentationAlgoThreshold
(
ThresholdType
type
)
:
WSegmentationAlgo
(),
m_type
(
type
)
{
}
...
...
@@ -37,17 +38,41 @@ WSegmentationAlgoThreshold::~WSegmentationAlgoThreshold()
void
WSegmentationAlgoThreshold
::
properties
()
{
m_threshold
=
m_properties
->
addProperty
(
"Threshold"
,
"Threshold in %."
,
0.0
,
m_propCondition
);
if
(
m_type
==
LOWER_THRESHOLD
)
{
m_threshold
=
m_properties
->
addProperty
(
"Lower Threshold"
,
"Threshold in %."
,
0.0
,
m_propCondition
);
}
else
{
m_threshold
=
m_properties
->
addProperty
(
"Upper Threshold"
,
"Threshold in %."
,
0.0
,
m_propCondition
);
}
m_threshold
->
setMin
(
0.0
);
m_threshold
->
setMax
(
1.0
);
}
std
::
string
WSegmentationAlgoThreshold
::
getName
()
{
return
"Threshold segmentation"
;
if
(
m_type
==
LOWER_THRESHOLD
)
{
return
"Lower Threshold segmentation"
;
}
else
{
return
"Upper Threshold segmentation"
;
}
}
std
::
string
WSegmentationAlgoThreshold
::
getDescription
()
{
return
"Use thresholding for segmentation."
;
if
(
m_type
==
LOWER_THRESHOLD
)
{
return
"Use lower thresholding for segmentation."
;
}
else
{
return
"Use upper thresholding for segmentation."
;
}
}
bool
WSegmentationAlgoThreshold
::
propChanged
()
...
...
src/modules/scalarSegmentation/WSegmentationAlgoThreshold.h
View file @
82cc95a7
...
...
@@ -31,18 +31,30 @@
#include "WSegmentationAlgo.h"
/**
* A very simple threshold segmentation. voxel that have a value smaller than
* the threshold are set to 0, while the rest of the voxels are set to 100.
* A very simple threshold segmentation working in two modi: If in LOWER_THRESHOLD mode than voxel
* that have a value smaller than the threshold are set to 0, while the rest of the voxels are set
* to 1 where as in UPPER_THRESHOLD mode the opposite applies.
*
* \class WSegmentationAlgoThreshold
*/
class
WSegmentationAlgoThreshold
:
public
WSegmentationAlgo
{
public:
/**
* This flags will select if the threshold should cut lower or upper values to zero.
*/
enum
ThresholdType
{
UPPER_THRESHOLD
,
LOWER_THRESHOLD
};
/**
* Standard constructor.
*
* \param type Specifies if this instance should act as an Upper or Lower threshold.
*/
WSegmentationAlgoThreshold
();
explicit
WSegmentationAlgoThreshold
(
ThresholdType
type
);
/**
* Destructor.
...
...
@@ -91,19 +103,33 @@ private:
//! The threshold in %.
WPropDouble
m_threshold
;
/**
* Each instance can select its threshold type which is stored inhere.
*/
ThresholdType
m_type
;
};
template
<
typename
T
>
WSegmentationAlgo
::
DataSetPtr
WSegmentationAlgoThreshold
::
operator
()
(
WValueSet
<
T
>
const
*
valueset
)
const
{
double
thres
=
m_threshold
->
get
(
true
);
boost
::
shared_ptr
<
std
::
vector
<
T
>
>
values
=
boost
::
shared_ptr
<
std
::
vector
<
T
>
>
(
new
std
::
vector
<
T
>
(
valueset
->
size
()
)
);
for
(
std
::
size_t
k
=
0
;
k
<
valueset
->
size
();
++
k
)
double
threshold
=
valueset
->
getMinimumValue
()
+
m_threshold
->
get
(
true
)
*
(
valueset
->
getMaximumValue
()
-
valueset
->
getMinimumValue
()
);
if
(
m_type
==
LOWER_THRESHOLD
)
{
for
(
std
::
size_t
k
=
0
;
k
<
valueset
->
size
();
++
k
)
{
(
*
values
)[
k
]
=
static_cast
<
T
>
(
static_cast
<
double
>
(
valueset
->
getScalar
(
k
)
)
<
threshold
?
0
:
1
);
}
}
else
{
(
*
values
)[
k
]
=
(
static_cast
<
double
>
(
valueset
->
getScalar
(
k
)
)
<
thres
*
(
valueset
->
getMaximumValue
()
-
valueset
->
getMinimumValue
()
)
/
100.0
+
valueset
->
getMinimumValue
()
?
static_cast
<
T
>
(
0
)
:
static_cast
<
T
>
(
100
)
);
for
(
std
::
size_t
k
=
0
;
k
<
valueset
->
size
();
++
k
)
{
(
*
values
)[
k
]
=
static_cast
<
T
>
(
static_cast
<
double
>
(
valueset
->
getScalar
(
k
)
)
>=
threshold
?
0
:
1
);
}
}
boost
::
shared_ptr
<
WValueSet
<
T
>
>
vs
(
new
WValueSet
<
T
>
(
0
,
1
,
values
,
DataType
<
T
>::
type
)
);
return
DataSetPtr
(
new
WDataSetScalar
(
vs
,
m_dataSet
->
getGrid
()
)
);
...
...
Write
Preview
Markdown
is supported
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