Commit 31ba23bf authored by Jakob Weiss's avatar Jakob Weiss

Fixed glimageresampler and added assert

* glImageResampler now sets the mapping information correctly
* ImageData now asserts that an associated imagemappinginformation has the
  same dimensionality
parent aee5eb16
...@@ -84,6 +84,7 @@ namespace campvis { ...@@ -84,6 +84,7 @@ namespace campvis {
} }
void ImageData::setMappingInformation(const ImageMappingInformation& imi) { void ImageData::setMappingInformation(const ImageMappingInformation& imi) {
cgtAssert(cgt::vec3(_size) == imi.getImageSize(), "Image Mapping Information must have the same voxel dimensions!");
_mappingInformation = imi; _mappingInformation = imi;
} }
...@@ -134,4 +135,4 @@ namespace campvis { ...@@ -134,4 +135,4 @@ namespace campvis {
return "Image Data"; return "Image Data";
} }
} }
\ No newline at end of file
...@@ -88,6 +88,11 @@ namespace campvis { ...@@ -88,6 +88,11 @@ namespace campvis {
return _worldToVoxelTransformation; return _worldToVoxelTransformation;
} }
const cgt::vec3 & ImageMappingInformation::getImageSize() const
{
return _size;
}
bool ImageMappingInformation::operator==(const ImageMappingInformation& obj) const{ bool ImageMappingInformation::operator==(const ImageMappingInformation& obj) const{
return (this->_offset == obj._offset) return (this->_offset == obj._offset)
&& (this->_size == obj._size) && (this->_size == obj._size)
......
...@@ -108,6 +108,12 @@ namespace campvis { ...@@ -108,6 +108,12 @@ namespace campvis {
*/ */
const cgt::mat4& getWorldToVoxelMatrix() const; const cgt::mat4& getWorldToVoxelMatrix() const;
/**
* Returns the image size information, as specified in the constructor as the
* number of voxels in each direction.
*/
const cgt::vec3& getImageSize() const;
/** /**
* Overloaded equal operator * Overloaded equal operator
* \param obj Object to compare with. * \param obj Object to compare with.
......
...@@ -26,7 +26,7 @@ in vec3 ex_TexCoord; ...@@ -26,7 +26,7 @@ in vec3 ex_TexCoord;
out vec4 out_Color; out vec4 out_Color;
#ifdef GLRESAMPLER_3D #ifdef GLRESAMPLER_3D
uniform sampler3D _texture; uniform TextureParameters3D _textureParams;
uniform float _zTexCoord; uniform float _zTexCoord;
#endif #endif
......
...@@ -39,7 +39,7 @@ namespace campvis { ...@@ -39,7 +39,7 @@ namespace campvis {
: AutoEvaluationPipeline(dc, getId()) : AutoEvaluationPipeline(dc, getId())
, _lsp() , _lsp()
, _imageReader() , _imageReader()
, _resampler() , _resampler(&_canvasSize)
, _ve(&_canvasSize) , _ve(&_canvasSize)
{ {
addProcessor(&_lsp); addProcessor(&_lsp);
...@@ -78,4 +78,4 @@ namespace campvis { ...@@ -78,4 +78,4 @@ namespace campvis {
} }
} }
\ No newline at end of file
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#include "modules/modulesapi.h" #include "modules/modulesapi.h"
#include "modules/base/processors/lightsourceprovider.h" #include "modules/base/processors/lightsourceprovider.h"
#include "modules/io/processors/mhdimagereader.h" #include "modules/io/processors/mhdimagereader.h"
#include "modules/preprocessing/processors/medianfilter.h" #include "modules/preprocessing/processors/glimageresampler.h"
#include "modules/vis/processors/volumeexplorer.h" #include "modules/vis/processors/volumeexplorer.h"
namespace campvis { namespace campvis {
...@@ -58,7 +58,7 @@ namespace campvis { ...@@ -58,7 +58,7 @@ namespace campvis {
protected: protected:
LightSourceProvider _lsp; LightSourceProvider _lsp;
MhdImageReader _imageReader; MhdImageReader _imageReader;
MedianFilter _resampler; GlImageResampler _resampler;
VolumeExplorer _ve; VolumeExplorer _ve;
}; };
} }
......
...@@ -79,8 +79,11 @@ namespace campvis { ...@@ -79,8 +79,11 @@ namespace campvis {
if (img != 0) { if (img != 0) {
cgt::vec3 originalSize(img->getSize()); cgt::vec3 originalSize(img->getSize());
cgt::ivec3 resampledSize = p_targetSize.getValue(); cgt::ivec3 resampledSize = p_targetSize.getValue();
cgt::vec3 resampleScale = p_resampleScale.getValue();
if (p_relativeScale.getValue()) if (p_relativeScale.getValue())
resampledSize = cgt::ivec3(p_resampleScale.getValue() * cgt::vec3(img->getSize())); resampledSize = cgt::ivec3(resampleScale * originalSize);
else
resampleScale = cgt::vec3(resampledSize) / cgt::vec3(originalSize);
bool isTexture2D = img->getParent()->getDimensionality() == 2; bool isTexture2D = img->getParent()->getDimensionality() == 2;
...@@ -124,7 +127,7 @@ namespace campvis { ...@@ -124,7 +127,7 @@ namespace campvis {
ImageData* id = new ImageData(img->getParent()->getDimensionality(), resampledSize, img->getParent()->getNumChannels()); ImageData* id = new ImageData(img->getParent()->getDimensionality(), resampledSize, img->getParent()->getNumChannels());
ImageRepresentationGL::create(id, resultTexture); ImageRepresentationGL::create(id, resultTexture);
const ImageMappingInformation& imi = img->getParent()->getMappingInformation(); const ImageMappingInformation& imi = img->getParent()->getMappingInformation();
id->setMappingInformation(ImageMappingInformation(img->getSize(), imi.getOffset(), imi.getVoxelSize() / p_resampleScale.getValue(), imi.getCustomTransformation())); id->setMappingInformation(ImageMappingInformation(resampledSize, imi.getOffset(), imi.getVoxelSize() / resampleScale, imi.getCustomTransformation()));
data.addData(p_outputImage.getValue(), id); data.addData(p_outputImage.getValue(), id);
cgt::TextureUnit::setZeroUnit(); 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