microscopyimagesegmentationdemo.cpp 3.75 KB
Newer Older
Hossain Mahmud's avatar
Hossain Mahmud committed
1
2
3
4
// ================================================================================================
// 
// This file is part of the CAMPVis Software Framework.
// 
5
// If not explicitly stated otherwise: Copyright (C) 2012-2015, all rights reserved,
Hossain Mahmud's avatar
Hossain Mahmud committed
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
//      Christian Schulte zu Berge <christian.szb@in.tum.de>
//      Chair for Computer Aided Medical Procedures
//      Technische Universitaet Muenchen
//      Boltzmannstr. 3, 85748 Garching b. Muenchen, 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 "microscopyimagesegmentationdemo.h"

27
#include "cgt/event/keyevent.h"
Hossain Mahmud's avatar
Hossain Mahmud committed
28
29
30
31
32
33
34
35
36
#include "core/datastructures/imagedata.h"

#include "core/classification/geometry1dtransferfunction.h"
#include "core/classification/tfgeometry1d.h"

#include "modules/devil/processors/devilimagereader.h"

namespace campvis {

37
38
    MicroscopyImageSegmentationDemo::MicroscopyImageSegmentationDemo(DataContainer& dc)
        : AutoEvaluationPipeline(dc, getId())
Hossain Mahmud's avatar
Hossain Mahmud committed
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
        , _lsp()
        , _ve(&_canvasSize)
    {
        addProcessor(&_lsp);

        addProcessor(&_imageReader);
        addProcessor(&_ve);

        addEventListenerToBack(&_ve);
    }

    MicroscopyImageSegmentationDemo::~MicroscopyImageSegmentationDemo() {
    }

    void MicroscopyImageSegmentationDemo::init() {
        AutoEvaluationPipeline::init();

        _ve.p_outputImage.setValue("mscopy");
        _renderTargetID.setValue("mscopy");

59
        _imageReader.p_url.setValue(CAMPVIS_SOURCE_DIR "/../lymph/LymphP1_0086.tif");
Hossain Mahmud's avatar
Hossain Mahmud committed
60
        MetaProperty *metaProp = dynamic_cast<MetaProperty*>(_imageReader.getProperty("DevilImageReaderMetaProp"));
61
        cgtAssert(nullptr != metaProp, "This should not happen.");
Hossain Mahmud's avatar
Hossain Mahmud committed
62
        BoolProperty *bp = dynamic_cast<BoolProperty*>(metaProp->getProperty("ImportSimilar"));
63
        cgtAssert(nullptr != bp, "This should not happen.");
Hossain Mahmud's avatar
Hossain Mahmud committed
64
65
        bp->setValue(true);

66
67
68
        if (GenericOptionProperty<std::string>* tester = dynamic_cast<GenericOptionProperty<std::string>*>(_imageReader.getNestedProperty("DevilImageReaderMetaProp::ImportType")))
            tester->selectById("localIntensity3");

69
70
        _imageReader.p_targetImageID.setValue("mscopy.output");
        _imageReader.p_targetImageID.addSharedProperty(&_ve.p_inputVolume);
Hossain Mahmud's avatar
Hossain Mahmud committed
71

72
73
74
75
        Geometry1DTransferFunction* dvrTF = new Geometry1DTransferFunction(128, cgt::vec2(0.f, .05f));
        dvrTF->addGeometry(TFGeometry1D::createQuad(cgt::vec2(.12f, .15f), cgt::col4(85, 0, 0, 128), cgt::col4(255, 0, 0, 128)));
        dvrTF->addGeometry(TFGeometry1D::createQuad(cgt::vec2(.19f, .28f), cgt::col4(89, 89, 89, 155), cgt::col4(89, 89, 89, 155)));
        dvrTF->addGeometry(TFGeometry1D::createQuad(cgt::vec2(.41f, .51f), cgt::col4(170, 170, 128, 64), cgt::col4(192, 192, 128, 64)));
Hossain Mahmud's avatar
Hossain Mahmud committed
76
77
78
79
80
81
82
        static_cast<TransferFunctionProperty*>(_ve.getNestedProperty("VolumeRendererProperties::RaycasterProps::TransferFunction"))->replaceTF(dvrTF);
        static_cast<FloatProperty*>(_ve.getNestedProperty("VolumeRendererProperties::RaycasterProps::SamplingRate"))->setValue(4.f);
    }

    void MicroscopyImageSegmentationDemo::deinit() {
        AutoEvaluationPipeline::deinit();
    }
83
}