Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
CAMP
campvis-public
Commits
2ce650a8
Commit
2ce650a8
authored
Dec 30, 2013
by
Christian Schulte zu Berge
Browse files
Added little demo pipeline TensorDemo
parent
a5c67131
Changes
4
Hide whitespace changes
Inline
Side-by-side
modules/tensor/pipelines/tensordemo.cpp
0 → 100644
View file @
2ce650a8
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012-2013, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universität München
// Boltzmannstr. 3, 85748 Garching b. München, Germany
//
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.
//
// ================================================================================================
#include
"tensordemo.h"
#include
"tgt/event/keyevent.h"
#include
"core/classification/geometry1dtransferfunction.h"
#include
"core/classification/tfgeometry1d.h"
namespace
campvis
{
TensorDemo
::
TensorDemo
(
DataContainer
*
dc
)
:
AutoEvaluationPipeline
(
dc
)
,
_imageReader
()
,
_ta
()
,
_sliceExtractor
(
&
_canvasSize
)
,
_wheelHandler
(
&
_sliceExtractor
.
p_zSliceNumber
)
{
addProcessor
(
&
_imageReader
);
addProcessor
(
&
_ta
);
addProcessor
(
&
_sliceExtractor
);
addEventListenerToBack
(
&
_wheelHandler
);
}
TensorDemo
::~
TensorDemo
()
{
}
void
TensorDemo
::
init
()
{
AutoEvaluationPipeline
::
init
();
_imageReader
.
p_url
.
setValue
(
CAMPVIS_SOURCE_DIR
"/modules/tensor/sampledata/planar_tensor.mhd"
);
_imageReader
.
p_targetImageID
.
setValue
(
"reader.output"
);
_imageReader
.
p_targetImageID
.
addSharedProperty
(
&
_ta
.
p_inputImage
);
_ta
.
p_outputProperties
[
0
]
->
_imageId
.
addSharedProperty
(
&
_sliceExtractor
.
p_sourceImageID
);
_ta
.
p_outputProperties
[
0
]
->
_imageType
.
selectById
(
"MainEigenvector"
);
_ta
.
s_validated
.
connect
(
this
,
&
TensorDemo
::
onProcessorValidated
);
_sliceExtractor
.
p_xSliceNumber
.
setValue
(
0
);
Geometry1DTransferFunction
*
tf
=
new
Geometry1DTransferFunction
(
128
,
tgt
::
vec2
(
0.
f
,
1.
f
));
tf
->
addGeometry
(
TFGeometry1D
::
createQuad
(
tgt
::
vec2
(
0.
f
,
1.
f
),
tgt
::
col4
(
0
,
0
,
0
,
0
),
tgt
::
col4
(
255
,
255
,
255
,
255
)));
_sliceExtractor
.
p_transferFunction
.
replaceTF
(
tf
);
_renderTargetID
.
setValue
(
"renderTarget"
);
_renderTargetID
.
addSharedProperty
(
&
(
_sliceExtractor
.
p_targetImageID
));
}
void
TensorDemo
::
onProcessorValidated
(
AbstractProcessor
*
processor
)
{
if
(
processor
==
&
_imageReader
)
{
ScopedTypedData
<
ImageData
>
img
(
*
_data
,
_sliceExtractor
.
p_sourceImageID
.
getValue
());
if
(
img
!=
0
)
{
_sliceExtractor
.
p_transferFunction
.
getTF
()
->
setImageHandle
(
img
.
getDataHandle
());
}
}
}
}
modules/tensor/pipelines/tensordemo.h
0 → 100644
View file @
2ce650a8
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012-2013, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universität München
// Boltzmannstr. 3, 85748 Garching b. München, Germany
//
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.
//
// ================================================================================================
#ifndef TENSORDEMO_H__
#define TENSORDEMO_H__
#include
"core/eventhandlers/mwheeltonumericpropertyeventlistener.h"
#include
"core/pipeline/autoevaluationpipeline.h"
#include
"modules/io/processors/mhdimagereader.h"
#include
"modules/tensor/processors/tensoranalyzer.h"
#include
"modules/vis/processors/sliceextractor.h"
namespace
campvis
{
class
TensorDemo
:
public
AutoEvaluationPipeline
{
public:
/**
* Small demo pipeline for tensor data visualization.
*/
TensorDemo
(
DataContainer
*
dc
);
/**
* Virtual Destructor
**/
virtual
~
TensorDemo
();
/// \see AutoEvaluationPipeline::init()
virtual
void
init
();
/// \see AbstractPipeline::getName()
virtual
const
std
::
string
getName
()
const
{
return
getId
();
};
/// \see AbstractPipeline::getId()
static
const
std
::
string
getId
()
{
return
"TensorDemo"
;
};
protected:
/**
* Slot getting called when one of the observed processors got validated.
* Updates the camera properties, when the input image has changed.
* \param processor The processor that emitted the signal
*/
virtual
void
onProcessorValidated
(
AbstractProcessor
*
processor
);
MhdImageReader
_imageReader
;
TensorAnalyzer
_ta
;
SliceExtractor
_sliceExtractor
;
MWheelToNumericPropertyEventListener
_wheelHandler
;
};
}
#endif // TENSORDEMO_H__
modules/tensor/processors/tensoranalyzer.cpp
View file @
2ce650a8
...
...
@@ -72,8 +72,8 @@ namespace campvis {
TensorAnalyzer
::
TensorAnalyzer
()
:
AbstractProcessor
()
,
p_inputImage
(
"InputImage"
,
"Input Tensor Image"
,
"tensors"
,
DataNameProperty
::
READ
,
AbstractProcessor
::
INVALID_RESULT
|
EIGENSYSTEM_INVALID
)
,
p_evalsImage
(
"EvalsImage"
,
"Output Eigenvalues Image"
,
"eigenvalues"
,
DataNameProperty
::
WRITE
)
,
p_evecsImage
(
"EvecsImage"
,
"Output Eigenvectors Image"
,
"eigenvectors"
,
DataNameProperty
::
WRITE
)
,
p_evalsImage
(
"EvalsImage"
,
"Output Eigenvalues Image"
,
"
TensorAnalyzer.
eigenvalues"
,
DataNameProperty
::
WRITE
)
,
p_evecsImage
(
"EvecsImage"
,
"Output Eigenvectors Image"
,
"
TensorAnalyzer.
eigenvectors"
,
DataNameProperty
::
WRITE
)
,
p_degeneratedHandling
(
"DegeneratedHandling"
,
"Handling of Degenerated Tensors"
,
handlingModes
,
4
)
,
p_maskMixedTensors
(
"MaskMixedTensors"
,
"Mask Mixed Tensors"
,
true
)
,
p_addOutputButton
(
"AddOutputButton"
,
"Add Output"
,
AbstractProcessor
::
VALID
)
...
...
@@ -122,7 +122,7 @@ namespace campvis {
GenericImageRepresentationLocal
<
float
,
3
>*
evalRep
=
GenericImageRepresentationLocal
<
float
,
3
>::
create
(
evals
,
0
);
ImageData
*
evecs
=
new
ImageData
(
input
->
getDimensionality
(),
input
->
getSize
(),
9
);
GenericImageRepresentationLocal
<
float
,
9
>*
evecRep
=
GenericImageRepresentationLocal
<
float
,
9
>::
create
(
ev
al
s
,
0
);
GenericImageRepresentationLocal
<
float
,
9
>*
evecRep
=
GenericImageRepresentationLocal
<
float
,
9
>::
create
(
ev
ec
s
,
0
);
tbb
::
atomic
<
size_t
>
countDiscarded
;
countDiscarded
=
0
;
...
...
modules/tensor/tensor.cmake
View file @
2ce650a8
...
...
@@ -14,3 +14,4 @@ FILE(GLOB ThisModHeaders RELATIVE ${ModulesDir}
)
SET
(
ThisModShaderDirectories
"modules/pipelines/glsl"
)
SET
(
ThisModDependencies io vis
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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