advancedusvis.cpp 6.19 KB
Newer Older
1
2
3
4
// ================================================================================================
// 
// This file is part of the CAMPVis Software Framework.
// 
5
// If not explicitly stated otherwise: Copyright (C) 2012-2014, all rights reserved,
6
7
//      Christian Schulte zu Berge <christian.szb@in.tum.de>
//      Chair for Computer Aided Medical Procedures
8
9
//      Technische Universitaet Muenchen
//      Boltzmannstr. 3, 85748 Garching b. Muenchen, Germany
10
// 
11
12
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
// 
13
14
15
16
// 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
17
// 
18
19
20
21
// 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.
22
23
24
25
26
27
// 
// ================================================================================================

#include "advancedusvis.h"

#include "tgt/event/keyevent.h"
28

29
30
#include "core/classification/geometry1dtransferfunction.h"
#include "core/classification/tfgeometry1d.h"
31
32
#include "core/tools/simplejobprocessor.h"
#include "core/tools/job.h"
33

34
35
#include "core/datastructures/genericimagerepresentationlocal.h"

36
37
namespace campvis {

38
39
    AdvancedUsVis::AdvancedUsVis(DataContainer* dc)
        : AutoEvaluationPipeline(dc)
40
41
        , _usReader()
        , _confidenceReader()
42
43
44
45
        , _usFusion1(&_canvasSize)
        , _usFusion2(&_canvasSize)
        , _usFusion3(&_canvasSize)
        , _usFusion4(&_canvasSize)
46
        , _usBlurFilter(&_canvasSize)
47
        , _quadView(&_canvasSize)
48
    {
49
50
        addProcessor(&_usReader);
        addProcessor(&_confidenceReader);
51
        addProcessor(&_usBlurFilter);
schultezub's avatar
schultezub committed
52
53
54
55
56
        addProcessor(&_usFusion1);
        addProcessor(&_usFusion2);
        addProcessor(&_usFusion3);
        addProcessor(&_usFusion4);
        addProcessor(&_quadView);
57
58
59
60
61
62
    }

    AdvancedUsVis::~AdvancedUsVis() {
    }

    void AdvancedUsVis::init() {
63
        AutoEvaluationPipeline::init();
64

65
        _usReader.p_url.setValue(CAMPVIS_SOURCE_DIR "/modules/advancedusvis/sampledata/us.mhd");
66
        _usReader.p_targetImageID.setValue("us.image");
67
68
69
70
        _usReader.p_targetImageID.addSharedProperty(&_usFusion1.p_usImageId);
        _usReader.p_targetImageID.addSharedProperty(&_usFusion2.p_usImageId);
        _usReader.p_targetImageID.addSharedProperty(&_usFusion3.p_usImageId);
        _usReader.p_targetImageID.addSharedProperty(&_usFusion4.p_usImageId);
71
72
73
        _usReader.p_targetImageID.addSharedProperty(&_usBlurFilter.p_inputImage);

        _confidenceReader.p_url.setValue(CAMPVIS_SOURCE_DIR "/modules/advancedusvis/sampledata/cm.mhd");
74
        _confidenceReader.p_targetImageID.setValue("confidence.image.read");
75
76
77
78
        _confidenceReader.p_targetImageID.addSharedProperty(&_usFusion1.p_confidenceImageID);
        _confidenceReader.p_targetImageID.addSharedProperty(&_usFusion2.p_confidenceImageID);
        _confidenceReader.p_targetImageID.addSharedProperty(&_usFusion3.p_confidenceImageID);
        _confidenceReader.p_targetImageID.addSharedProperty(&_usFusion4.p_confidenceImageID);
79

schultezub's avatar
schultezub committed
80
        _usFusion1.p_targetImageID.setValue("us.fused1");
81
        _usFusion1.p_targetImageID.addSharedProperty(&_quadView.p_inputImage1);
schultezub's avatar
schultezub committed
82
83
84
85
86
87
88
        _usFusion1.p_view.selectById("us");
        _usFusion1.p_sliceNumber.setValue(0);
        _usFusion1.p_sliceNumber.addSharedProperty(&_usFusion2.p_sliceNumber);
        _usFusion1.p_sliceNumber.addSharedProperty(&_usFusion3.p_sliceNumber);
        _usFusion1.p_sliceNumber.addSharedProperty(&_usFusion4.p_sliceNumber);

        _usFusion2.p_targetImageID.setValue("us.fused2");
89
        _usFusion2.p_targetImageID.addSharedProperty(&_quadView.p_inputImage2);
schultezub's avatar
schultezub committed
90
91
92
        _usFusion2.p_view.selectById("mappingSaturationHSV");

        _usFusion3.p_targetImageID.setValue("us.fused3");
93
        _usFusion3.p_targetImageID.addSharedProperty(&_quadView.p_inputImage3);
94
95
        _usFusion3.p_view.selectById("mappingLAB");
        _usFusion3.p_hue.setValue(0.22f);
schultezub's avatar
schultezub committed
96
97

        _usFusion4.p_targetImageID.setValue("us.fused4");
98
        _usFusion4.p_targetImageID.addSharedProperty(&_quadView.p_inputImage4);
schultezub's avatar
schultezub committed
99
        _usFusion4.p_view.selectById("mappingSharpness");
100

101
102
103
104
105
        _usBlurFilter.p_outputImage.setValue("us.blurred");
        _usBlurFilter.p_outputImage.addSharedProperty(&_usFusion1.p_blurredImageId);
        _usBlurFilter.p_outputImage.addSharedProperty(&_usFusion2.p_blurredImageId);
        _usBlurFilter.p_outputImage.addSharedProperty(&_usFusion3.p_blurredImageId);
        _usBlurFilter.p_outputImage.addSharedProperty(&_usFusion4.p_blurredImageId);
106
107
        _usBlurFilter.p_sigma.setValue(4.f);

schultezub's avatar
schultezub committed
108
109
        _quadView.p_outputImage.setValue("quadview.output");

110
        // TODO: replace this hardcoded domain by automatically determined from image min/max values
111
        Geometry1DTransferFunction* tf = new Geometry1DTransferFunction(128, tgt::vec2(0.f, 1.f));
112
        tf->addGeometry(TFGeometry1D::createQuad(tgt::vec2(0.f, 1.f), tgt::col4(0, 0, 0, 255), tgt::col4(255, 255, 255, 255)));
schultezub's avatar
schultezub committed
113
        _usFusion1.p_transferFunction.replaceTF(tf);
114
115
116
        _usFusion2.p_transferFunction.replaceTF(tf->clone());
        _usFusion3.p_transferFunction.replaceTF(tf->clone());
        _usFusion4.p_transferFunction.replaceTF(tf->clone());
117

schultezub's avatar
schultezub committed
118
        _renderTargetID.setValue("quadview.output");
119
120
    }

121
    void AdvancedUsVis::deinit() {
122
        AutoEvaluationPipeline::deinit();
123
124
    }

125
126
127
128
    void AdvancedUsVis::keyEvent(tgt::KeyEvent* e) {
        if (e->pressed()) {
            switch (e->keyCode()) {
                case tgt::KeyEvent::K_UP:
schultezub's avatar
schultezub committed
129
                    _usFusion1.p_sliceNumber.increment();
130
131
                    break;
                case tgt::KeyEvent::K_DOWN:
schultezub's avatar
schultezub committed
132
                    _usFusion1.p_sliceNumber.decrement();
133
                    break;
134
135
                default:
                    break;
136
137
138
139
            }
        }
    }

140
}