The expiration time for new job artifacts in CI/CD pipelines is now 30 days (GitLab default). Previously generated artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

Commit 259d6f41 authored by Christian Schulte zu Berge's avatar Christian Schulte zu Berge
Browse files

Introducing an additional custom transformation to ImageMappingInformation class.

parent 4f895879
......@@ -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<float>& realWorldValueMapping /*= LinearMapping<float>::identity*/)
ImageMappingInformation::ImageMappingInformation(const cgt::vec3& size, const cgt::vec3& offset, const cgt::vec3& voxelSize, const cgt::mat4& 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;
}
}
......@@ -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 mapping element values to real world values, defaults to identity.
* \param customTransformation Additional custom transformation from voxel to world coordinates, defaults to identity.
*/
ImageMappingInformation(
const cgt::vec3& size,
const cgt::vec3& offset,
const cgt::vec3& voxelSize,
const LinearMapping<float>& realWorldValueMapping = LinearMapping<float>::identity);
const cgt::mat4& customTransformation = cgt::mat4::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
......
......@@ -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:
......
......@@ -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;
}
......@@ -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.getRealWorldMapping()));
id->setMappingInformation(ImageMappingInformation(img->getSize(), imi.getOffset() + (cgt::vec3(p_llf.getValue()) * imi.getVoxelSize()), imi.getVoxelSize(), imi.getCustomTransformation()));
data.addData(p_outputImage.getValue(), id);
cgt::TextureUnit::setZeroUnit();
......
......@@ -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.getRealWorldMapping()));
id->setMappingInformation(ImageMappingInformation(img->getSize(), imi.getOffset(), imi.getVoxelSize() / p_resampleScale.getValue(), imi.getCustomTransformation()));
data.addData(p_outputImage.getValue(), id);
cgt::TextureUnit::setZeroUnit();
......
......@@ -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.getRealWorldMapping()));
id->setMappingInformation(ImageMappingInformation(img->getSize(), imi.getOffset(), imi.getVoxelSize(), imi.getCustomTransformation()));
data.addData(p_outputImage.getValue(), id);
cgt::TextureUnit::setZeroUnit();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment