Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
9.2.2023: Due to updates GitLab will be unavailable for some minutes between 9:00 and 11:00.
Open sidebar
CAMP
campvis-public
Commits
bcdae20a
Commit
bcdae20a
authored
Dec 12, 2013
by
Christian Schulte zu Berge
Browse files
Introducing GlImageResampler processor and ResamplingDemo pipeline
parent
535a3f34
Changes
6
Hide whitespace changes
Inline
Side-by-side
modules/preprocessing/glsl/glimageresampler.frag
0 → 100644
View file @
bcdae20a
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012, 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".
//
// The licensing of this softare is not yet resolved. Until then, redistribution in source or
// binary forms outside the CAMP chair is not permitted, unless explicitly stated in legal form.
// However, the names of the original authors and the above copyright notice must retain in its
// original state in any case.
//
// Legal disclaimer provided by the BSD license:
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ================================================================================================
in
vec3
ex_TexCoord
;
out
vec4
out_Color
;
#include
"tools/gradient.frag"
#include
"tools/texture3d.frag"
uniform
sampler3D
_texture
;
uniform
TextureParameters3D
_textureParams
;
uniform
float
_zTexCoord
;
void
main
()
{
out_Color
=
texture
(
_texture
,
vec3
(
ex_TexCoord
.
xy
,
_zTexCoord
));
}
modules/preprocessing/processors/glgradientvolumegenerator.cpp
View file @
bcdae20a
...
...
@@ -89,7 +89,6 @@ namespace campvis {
}
const
tgt
::
svec3
&
size
=
img
->
getSize
();
tgt
::
ivec2
viewportSize
=
size
.
xy
();
tgt
::
TextureUnit
inputUnit
;
inputUnit
.
activate
();
...
...
@@ -104,7 +103,7 @@ namespace campvis {
// activate FBO and attach texture
_fbo
->
activate
();
glViewport
(
0
,
0
,
static_cast
<
GLsizei
>
(
viewportS
ize
.
x
),
static_cast
<
GLsizei
>
(
viewportS
ize
.
y
));
glViewport
(
0
,
0
,
static_cast
<
GLsizei
>
(
s
ize
.
x
),
static_cast
<
GLsizei
>
(
s
ize
.
y
));
// render quad to compute difference measure by shader
for
(
int
z
=
0
;
z
<
size
.
z
;
++
z
)
{
...
...
modules/preprocessing/processors/glimageresampler.cpp
0 → 100644
View file @
bcdae20a
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012, 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".
//
// The licensing of this softare is not yet resolved. Until then, redistribution in source or
// binary forms outside the CAMP chair is not permitted, unless explicitly stated in legal form.
// However, the names of the original authors and the above copyright notice must retain in its
// original state in any case.
//
// Legal disclaimer provided by the BSD license:
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ================================================================================================
#include
"glimageresampler.h"
#include
"tgt/logmanager.h"
#include
"tgt/shadermanager.h"
#include
"tgt/textureunit.h"
#include
"tgt/texture.h"
#include
"core/datastructures/imagedata.h"
#include
"core/datastructures/imagerepresentationgl.h"
#include
"core/datastructures/renderdata.h"
#include
"core/tools/quadrenderer.h"
namespace
campvis
{
const
std
::
string
GlImageResampler
::
loggerCat_
=
"CAMPVis.modules.classification.GlImageResampler"
;
GlImageResampler
::
GlImageResampler
(
IVec2Property
*
viewportSizeProp
)
:
VisualizationProcessor
(
viewportSizeProp
)
,
p_inputImage
(
"InputImage"
,
"Input Image"
,
""
,
DataNameProperty
::
READ
)
,
p_outputImage
(
"OutputImage"
,
"Output Image"
,
"GlImageResampler.out"
,
DataNameProperty
::
WRITE
)
,
p_resampleScale
(
"ResampleScale"
,
"Resampling Scale"
,
.5
f
,
.01
f
,
10.
f
)
,
_shader
(
0
)
{
addProperty
(
&
p_inputImage
);
addProperty
(
&
p_outputImage
);
addProperty
(
&
p_resampleScale
);
}
GlImageResampler
::~
GlImageResampler
()
{
}
void
GlImageResampler
::
init
()
{
VisualizationProcessor
::
init
();
_shader
=
ShdrMgr
.
loadSeparate
(
"core/glsl/passthrough.vert"
,
"modules/preprocessing/glsl/glimageresampler.frag"
,
""
,
false
);
_shader
->
setAttributeLocation
(
0
,
"in_Position"
);
_shader
->
setAttributeLocation
(
1
,
"in_TexCoord"
);
}
void
GlImageResampler
::
deinit
()
{
ShdrMgr
.
dispose
(
_shader
);
VisualizationProcessor
::
deinit
();
}
void
GlImageResampler
::
process
(
DataContainer
&
data
)
{
ImageRepresentationGL
::
ScopedRepresentation
img
(
data
,
p_inputImage
.
getValue
());
if
(
img
!=
0
)
{
tgt
::
vec3
originalSize
(
img
->
getSize
());
tgt
::
ivec3
resampledSize
(
originalSize
*
p_resampleScale
.
getValue
());
tgt
::
TextureUnit
inputUnit
;
inputUnit
.
activate
();
// create texture for result
tgt
::
Texture
*
resultTexture
=
new
tgt
::
Texture
(
0
,
resampledSize
,
img
->
getTexture
()
->
getFormat
(),
img
->
getTexture
()
->
getInternalFormat
(),
img
->
getTexture
()
->
getDataType
(),
tgt
::
Texture
::
LINEAR
);
resultTexture
->
uploadTexture
();
// activate shader and bind textures
_shader
->
activate
();
img
->
bind
(
_shader
,
inputUnit
);
// activate FBO and attach texture
_fbo
->
activate
();
glViewport
(
0
,
0
,
static_cast
<
GLsizei
>
(
resampledSize
.
x
),
static_cast
<
GLsizei
>
(
resampledSize
.
y
));
// render quad to compute difference measure by shader
for
(
int
z
=
0
;
z
<
resampledSize
.
z
;
++
z
)
{
float
zTexCoord
=
static_cast
<
float
>
(
z
)
/
static_cast
<
float
>
(
resampledSize
.
z
)
+
.5
f
/
static_cast
<
float
>
(
resampledSize
.
z
);
_shader
->
setUniform
(
"_zTexCoord"
,
zTexCoord
);
_fbo
->
attachTexture
(
resultTexture
,
GL_COLOR_ATTACHMENT0
,
0
,
z
);
QuadRdr
.
renderQuad
();
}
_fbo
->
detachAll
();
_fbo
->
deactivate
();
_shader
->
deactivate
();
// put resulting image into DataContainer
ImageData
*
id
=
new
ImageData
(
3
,
resampledSize
,
1
);
ImageRepresentationGL
::
create
(
id
,
resultTexture
);
id
->
setMappingInformation
(
img
->
getParent
()
->
getMappingInformation
());
data
.
addData
(
p_outputImage
.
getValue
(),
id
);
tgt
::
TextureUnit
::
setZeroUnit
();
LGL_ERROR
;
}
else
{
LERROR
(
"No suitable input image found."
);
}
validate
(
INVALID_RESULT
);
}
}
modules/preprocessing/processors/glimageresampler.h
0 → 100644
View file @
bcdae20a
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012, 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".
//
// The licensing of this softare is not yet resolved. Until then, redistribution in source or
// binary forms outside the CAMP chair is not permitted, unless explicitly stated in legal form.
// However, the names of the original authors and the above copyright notice must retain in its
// original state in any case.
//
// Legal disclaimer provided by the BSD license:
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ================================================================================================
#ifndef GLIMAGERESAMPLER_H__
#define GLIMAGERESAMPLER_H__
#include
<string>
#include
"core/pipeline/abstractprocessordecorator.h"
#include
"core/pipeline/visualizationprocessor.h"
#include
"core/properties/datanameproperty.h"
#include
"core/properties/floatingpointproperty.h"
namespace
tgt
{
class
Shader
;
}
namespace
campvis
{
/**
* Resamples am image on the GPU using OpenGL.
*/
class
GlImageResampler
:
public
VisualizationProcessor
{
public:
/**
* Constructs a new GlImageResampler Processor
**/
GlImageResampler
(
IVec2Property
*
viewportSizeProp
);
/**
* Destructor
**/
virtual
~
GlImageResampler
();
/// \see AbstractProcessor::init
virtual
void
init
();
/// \see AbstractProcessor::deinit
virtual
void
deinit
();
/// \see AbstractProcessor::getName()
virtual
const
std
::
string
getName
()
const
{
return
"GlImageResampler"
;
};
/// \see AbstractProcessor::getDescription()
virtual
const
std
::
string
getDescription
()
const
{
return
"Resamples am image on the GPU using OpenGL."
;
};
/// \see AbstractProcessor::getAuthor()
virtual
const
std
::
string
getAuthor
()
const
{
return
"Christian Schulte zu Berge <christian.szb@in.tum.de>"
;
};
/// \see AbstractProcessor::getProcessorState()
virtual
ProcessorState
getProcessorState
()
const
{
return
AbstractProcessor
::
EXPERIMENTAL
;
};
/// \see AbstractProcessor::process()
virtual
void
process
(
DataContainer
&
data
);
DataNameProperty
p_inputImage
;
///< ID for input volume
DataNameProperty
p_outputImage
;
///< ID for output gradient volume
FloatProperty
p_resampleScale
;
///< Resampling Scale
protected:
tgt
::
Shader
*
_shader
;
///< Shader for resampling
static
const
std
::
string
loggerCat_
;
};
}
#endif // GLIMAGERESAMPLER_H__
modules/vis/pipelines/resamplingdemo.cpp
0 → 100644
View file @
bcdae20a
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012, 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".
//
// The licensing of this softare is not yet resolved. Until then, redistribution in source or
// binary forms outside the CAMP chair is not permitted, unless explicitly stated in legal form.
// However, the names of the original authors and the above copyright notice must retain in its
// original state in any case.
//
// Legal disclaimer provided by the BSD license:
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ================================================================================================
#include
"resamplingdemo.h"
#include
"tgt/event/keyevent.h"
#include
"core/datastructures/imagedata.h"
#include
"core/classification/geometry1dtransferfunction.h"
#include
"core/classification/tfgeometry1d.h"
namespace
campvis
{
ResamplingDemo
::
ResamplingDemo
(
DataContainer
*
dc
)
:
AutoEvaluationPipeline
(
dc
)
,
_imageReader
()
,
_resampler
(
&
_canvasSize
)
,
_ve
(
&
_canvasSize
)
{
addProcessor
(
&
_imageReader
);
addProcessor
(
&
_resampler
);
addProcessor
(
&
_ve
);
addEventListenerToBack
(
&
_ve
);
}
ResamplingDemo
::~
ResamplingDemo
()
{
}
void
ResamplingDemo
::
init
()
{
AutoEvaluationPipeline
::
init
();
_imageReader
.
s_validated
.
connect
(
this
,
&
ResamplingDemo
::
onProcessorValidated
);
_ve
.
p_outputImage
.
setValue
(
"result"
);
_renderTargetID
.
setValue
(
"result"
);
_imageReader
.
p_url
.
setValue
(
"D:
\\
Medical Data
\\
smallHeart.mhd"
);
_imageReader
.
p_targetImageID
.
setValue
(
"reader.output"
);
_imageReader
.
p_targetImageID
.
addSharedProperty
(
&
_resampler
.
p_inputImage
);
_resampler
.
p_outputImage
.
setValue
(
"resampled"
);
_resampler
.
p_outputImage
.
addSharedProperty
(
&
_ve
.
p_inputVolume
);
Geometry1DTransferFunction
*
dvrTF
=
new
Geometry1DTransferFunction
(
128
,
tgt
::
vec2
(
0.
f
,
.05
f
));
dvrTF
->
addGeometry
(
TFGeometry1D
::
createQuad
(
tgt
::
vec2
(
.1
f
,
.125
f
),
tgt
::
col4
(
255
,
0
,
0
,
32
),
tgt
::
col4
(
255
,
0
,
0
,
32
)));
dvrTF
->
addGeometry
(
TFGeometry1D
::
createQuad
(
tgt
::
vec2
(
.4
f
,
.5
f
),
tgt
::
col4
(
0
,
255
,
0
,
128
),
tgt
::
col4
(
0
,
255
,
0
,
128
)));
static_cast
<
TransferFunctionProperty
*>
(
_ve
.
getProperty
(
"TransferFunction"
))
->
replaceTF
(
dvrTF
);
_canvasSize
.
s_changed
.
connect
<
ResamplingDemo
>
(
this
,
&
ResamplingDemo
::
onRenderTargetSizeChanged
);
}
void
ResamplingDemo
::
deinit
()
{
_canvasSize
.
s_changed
.
disconnect
(
this
);
AutoEvaluationPipeline
::
deinit
();
}
void
ResamplingDemo
::
onRenderTargetSizeChanged
(
const
AbstractProperty
*
prop
)
{
}
void
ResamplingDemo
::
onProcessorValidated
(
AbstractProcessor
*
processor
)
{
}
}
\ No newline at end of file
modules/vis/pipelines/resamplingdemo.h
0 → 100644
View file @
bcdae20a
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012, 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".
//
// The licensing of this softare is not yet resolved. Until then, redistribution in source or
// binary forms outside the CAMP chair is not permitted, unless explicitly stated in legal form.
// However, the names of the original authors and the above copyright notice must retain in its
// original state in any case.
//
// Legal disclaimer provided by the BSD license:
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ================================================================================================
#ifndef RESAMPLINGDEMO_H__
#define RESAMPLINGDEMO_H__
#include
"core/pipeline/autoevaluationpipeline.h"
#include
"core/properties/cameraproperty.h"
#include
"modules/io/processors/mhdimagereader.h"
#include
"modules/preprocessing/processors/glimageresampler.h"
#include
"modules/vis/processors/volumeexplorer.h"
namespace
campvis
{
class
ResamplingDemo
:
public
AutoEvaluationPipeline
{
public:
/**
* Creates a AutoEvaluationPipeline.
*/
ResamplingDemo
(
DataContainer
*
dc
);
/**
* Virtual Destructor
**/
virtual
~
ResamplingDemo
();
/// \see AutoEvaluationPipeline::init()
virtual
void
init
();
/// \see AutoEvaluationPipeline::deinit()
virtual
void
deinit
();
/// \see AbstractPipeline::getName()
virtual
const
std
::
string
getName
()
const
{
return
getId
();
};
static
const
std
::
string
getId
()
{
return
"ResamplingDemo"
;
};
void
onRenderTargetSizeChanged
(
const
AbstractProperty
*
prop
);
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
;
GlImageResampler
_resampler
;
VolumeExplorer
_ve
;
};
}
#endif // RESAMPLINGDEMO_H__
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