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
259d6f41
Commit
259d6f41
authored
Jan 09, 2015
by
Christian Schulte zu Berge
Browse files
Introducing an additional custom transformation to ImageMappingInformation class.
parent
4f895879
Changes
7
Hide whitespace changes
Inline
Side-by-side
core/datastructures/imagemappinginformation.cpp
View file @
259d6f41
...
...
@@ -25,15 +25,22 @@
#include
"imagemappinginformation.h"
#include
"cgt/assert.h"
#include
"cgt/logmanager.h"
namespace
campvis
{
ImageMappingInformation
::
ImageMappingInformation
(
const
cgt
::
vec3
&
size
,
const
cgt
::
vec3
&
offset
,
const
cgt
::
vec3
&
voxelSize
,
const
LinearMapping
<
flo
at
>
&
realWorldValueMapping
/*= LinearMapping<float>::identity*/
)
ImageMappingInformation
::
ImageMappingInformation
(
const
cgt
::
vec3
&
size
,
const
cgt
::
vec3
&
offset
,
const
cgt
::
vec3
&
voxelSize
,
const
cgt
::
m
at
4
&
customTransformation
/*= LinearMapping<float>::identity*/
)
:
_size
(
size
)
,
_offset
(
offset
)
,
_voxelSize
(
voxelSize
)
,
_
realWorldValueMapping
(
realWorldValueMapping
)
,
_
customTransformation
(
customTransformation
)
{
cgt
::
mat4
invTrafo
;
if
(
!
_customTransformation
.
invert
(
invTrafo
))
{
LERRORC
(
"CAMPVis.core.ImageMappingInformation"
,
"Custom transformation is not invertable! Resetting to identity tranformation."
);
_customTransformation
=
cgt
::
mat4
::
identity
;
}
updateMatrices
();
}
...
...
@@ -45,20 +52,12 @@ namespace campvis {
return
_voxelSize
;
}
const
LinearMapping
<
float
>&
ImageMappingInformation
::
getRealWorldMapping
()
const
{
return
_realWorldValueMapping
;
}
void
ImageMappingInformation
::
setRealWorldMapping
(
const
LinearMapping
<
float
>&
rwvm
)
{
_realWorldValueMapping
=
rwvm
;
}
void
ImageMappingInformation
::
updateMatrices
()
{
_textureToWorldTransformation
=
cgt
::
mat4
::
createTranslation
(
_offset
)
*
cgt
::
mat4
::
createScale
(
_voxelSize
*
_size
);
_textureToWorldTransformation
=
cgt
::
mat4
::
createTranslation
(
_offset
)
*
_customTransformation
*
cgt
::
mat4
::
createScale
(
_voxelSize
*
_size
);
if
(
!
_textureToWorldTransformation
.
invert
(
_worldToTextureTransformation
))
cgtAssert
(
false
,
"Could not invert texture-to-world matrix. That should not happen!"
);
_voxelToWorldTransformation
=
cgt
::
mat4
::
createTranslation
(
_offset
)
*
cgt
::
mat4
::
createScale
(
_voxelSize
);
_voxelToWorldTransformation
=
cgt
::
mat4
::
createTranslation
(
_offset
)
*
_customTransformation
*
cgt
::
mat4
::
createScale
(
_voxelSize
);
if
(
!
_voxelToWorldTransformation
.
invert
(
_worldToVoxelTransformation
))
cgtAssert
(
false
,
"Could not invert voxel-to-world matrix. That should not happen!"
);
}
...
...
@@ -83,10 +82,15 @@ namespace campvis {
return
(
this
->
_offset
==
obj
.
_offset
)
&&
(
this
->
_size
==
obj
.
_size
)
&&
(
this
->
_voxelSize
==
obj
.
_voxelSize
)
&&
(
this
->
_
realWorldValueMapping
==
obj
.
_realWorldValueMapping
)
&&
(
this
->
_
customTransformation
==
obj
.
_customTransformation
)
&&
(
this
->
_textureToWorldTransformation
==
obj
.
_textureToWorldTransformation
)
&&
(
this
->
_voxelToWorldTransformation
==
obj
.
_voxelToWorldTransformation
)
&&
(
this
->
_worldToTextureTransformation
==
obj
.
_worldToTextureTransformation
)
&&
(
this
->
_worldToVoxelTransformation
==
obj
.
_worldToVoxelTransformation
);
}
const
cgt
::
mat4
ImageMappingInformation
::
getCustomTransformation
()
const
{
return
_customTransformation
;
}
}
core/datastructures/imagemappinginformation.h
View file @
259d6f41
...
...
@@ -46,13 +46,13 @@ namespace campvis {
* \param size Image size (number of elements, redundant...)
* \param offset Position of LLF corner in world coordinates (mm)
* \param voxelSize Voxel size in (mm)
* \param
realWorldValueMapping Linear mapping
for
ma
pping element values to real world valu
es, defaults to identity.
* \param
customTransformation Additional custom trans
forma
tion from voxel to world coordinat
es, defaults to identity.
*/
ImageMappingInformation
(
const
cgt
::
vec3
&
size
,
const
cgt
::
vec3
&
offset
,
const
cgt
::
vec3
&
voxelSize
,
const
LinearMapping
<
flo
at
>
&
realWorldValueMapping
=
LinearMapping
<
flo
at
>
::
identity
);
const
cgt
::
m
at
4
&
customTransformation
=
cgt
::
m
at
4
::
identity
);
/**
* Returns the position of LLF corner in world coordinates (mm).
...
...
@@ -66,6 +66,12 @@ namespace campvis {
*/
const
cgt
::
vec3
&
getVoxelSize
()
const
;
/**
* Returns the additional custom transformation from voxel to world coordinates.
* \return _customTransformation
*/
const
cgt
::
mat4
getCustomTransformation
()
const
;
/**
* Gets the transformation matrix from texture to world coordinates.
* \return _textureToWorldTransformation
...
...
@@ -90,18 +96,6 @@ namespace campvis {
*/
const
cgt
::
mat4
&
getWorldToVoxelMatrix
()
const
;
/**
* Get the real world value mapping.
* \return Linear mapping for mapping element values to real world values.
*/
const
LinearMapping
<
float
>&
getRealWorldMapping
()
const
;
/**
* Set the real world value mapping.
* \param rwvm Linear mapping for mapping element values to real world values.
*/
void
setRealWorldMapping
(
const
LinearMapping
<
float
>&
rwvm
);
/**
* Overloaded equal operator
* \param obj Object to compare with.
...
...
@@ -117,8 +111,7 @@ namespace campvis {
cgt
::
vec3
_size
;
///< Image size (number of elements, redundant...)
cgt
::
vec3
_offset
;
///< Position of LLF corner in world coordinates (mm)
cgt
::
vec3
_voxelSize
;
///< Voxel size in (mm)
LinearMapping
<
float
>
_realWorldValueMapping
;
///< Linear mapping for mapping element values to real world values
cgt
::
mat4
_customTransformation
;
///< Additional custom transformation from voxel to world coordinates
cgt
::
mat4
_textureToWorldTransformation
;
///< Transformation matrix from texture to world coordinates
cgt
::
mat4
_worldToTextureTransformation
;
///< Transformation matrix from world to texture coordinates
...
...
core/datastructures/imagerepresentationgl.cpp
View file @
259d6f41
...
...
@@ -169,7 +169,6 @@ namespace campvis {
shader
->
setUniform
(
texParamsUniform
+
"._voxelSizeRCP"
,
cgt
::
vec3
(
1.
f
)
/
_parent
->
getMappingInformation
().
getVoxelSize
());
shader
->
setUniform
(
texParamsUniform
+
"._textureToWorldMatrix"
,
_parent
->
getMappingInformation
().
getTextureToWorldMatrix
());
shader
->
setUniform
(
texParamsUniform
+
"._worldToTextureMatrix"
,
_parent
->
getMappingInformation
().
getWorldToTextureMatrix
());
shader
->
setUniform
(
texParamsUniform
+
"._realWorldMapping"
,
cgt
::
vec2
(
_parent
->
getMappingInformation
().
getRealWorldMapping
().
_shift
,
_parent
->
getMappingInformation
().
getRealWorldMapping
().
_scale
));
break
;
default:
...
...
core/glsl/tools/texture3d.frag
View file @
259d6f41
...
...
@@ -39,8 +39,6 @@ struct TextureParameters3D {
// Transformation matrices
mat4
_textureToWorldMatrix
;
mat4
_worldToTextureMatrix
;
vec2
_realWorldMapping
;
};
/**
...
...
@@ -86,11 +84,3 @@ vec4 worldToTexture(in TextureParameters3D texParams, in vec4 worldCoords) {
vec4
worldToTexture
(
in
TextureParameters3D
texParams
,
in
vec3
worldCoords
)
{
return
worldToTexture
(
texParams
,
vec4
(
worldCoords
,
1
.
0
));
}
float
applyRealWorldMapping
(
in
TextureParameters3D
tex
,
in
float
value
)
{
return
(
value
+
tex
.
_realWorldMapping
.
x
)
*
tex
.
_realWorldMapping
.
y
;
}
float
applyInverseRealWorldMapping
(
in
TextureParameters3D
tex
,
in
float
value
)
{
return
(
value
-
tex
.
_realWorldMapping
.
x
)
/
tex
.
_realWorldMapping
.
y
;
}
modules/preprocessing/processors/glimagecrop.cpp
View file @
259d6f41
...
...
@@ -108,7 +108,7 @@ namespace campvis {
ImageData
*
id
=
new
ImageData
(
3
,
outputSize
,
img
.
getImageData
()
->
getNumChannels
());
ImageRepresentationGL
::
create
(
id
,
resultTexture
);
const
ImageMappingInformation
&
imi
=
img
->
getParent
()
->
getMappingInformation
();
id
->
setMappingInformation
(
ImageMappingInformation
(
img
->
getSize
(),
imi
.
getOffset
()
+
(
cgt
::
vec3
(
p_llf
.
getValue
())
*
imi
.
getVoxelSize
()),
imi
.
getVoxelSize
(),
imi
.
get
RealWorldMapping
()));
id
->
setMappingInformation
(
ImageMappingInformation
(
img
->
getSize
(),
imi
.
getOffset
()
+
(
cgt
::
vec3
(
p_llf
.
getValue
())
*
imi
.
getVoxelSize
()),
imi
.
getVoxelSize
(),
imi
.
get
CustomTransformation
()));
data
.
addData
(
p_outputImage
.
getValue
(),
id
);
cgt
::
TextureUnit
::
setZeroUnit
();
...
...
modules/preprocessing/processors/glimageresampler.cpp
View file @
259d6f41
...
...
@@ -104,7 +104,7 @@ namespace campvis {
ImageData
*
id
=
new
ImageData
(
3
,
resampledSize
,
1
);
ImageRepresentationGL
::
create
(
id
,
resultTexture
);
const
ImageMappingInformation
&
imi
=
img
->
getParent
()
->
getMappingInformation
();
id
->
setMappingInformation
(
ImageMappingInformation
(
img
->
getSize
(),
imi
.
getOffset
(),
imi
.
getVoxelSize
()
/
p_resampleScale
.
getValue
(),
imi
.
get
RealWorldMapping
()));
id
->
setMappingInformation
(
ImageMappingInformation
(
img
->
getSize
(),
imi
.
getOffset
(),
imi
.
getVoxelSize
()
/
p_resampleScale
.
getValue
(),
imi
.
get
CustomTransformation
()));
data
.
addData
(
p_outputImage
.
getValue
(),
id
);
cgt
::
TextureUnit
::
setZeroUnit
();
...
...
modules/preprocessing/processors/glintensityquantizer.cpp
View file @
259d6f41
...
...
@@ -113,7 +113,7 @@ namespace campvis {
ImageData
*
id
=
new
ImageData
(
3
,
size
,
img
.
getImageData
()
->
getNumChannels
());
ImageRepresentationGL
::
create
(
id
,
resultTexture
);
const
ImageMappingInformation
&
imi
=
img
->
getParent
()
->
getMappingInformation
();
id
->
setMappingInformation
(
ImageMappingInformation
(
img
->
getSize
(),
imi
.
getOffset
(),
imi
.
getVoxelSize
(),
imi
.
get
RealWorldMapping
()));
id
->
setMappingInformation
(
ImageMappingInformation
(
img
->
getSize
(),
imi
.
getOffset
(),
imi
.
getVoxelSize
(),
imi
.
get
CustomTransformation
()));
data
.
addData
(
p_outputImage
.
getValue
(),
id
);
cgt
::
TextureUnit
::
setZeroUnit
();
...
...
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