05.11., 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

Commit f704deb8 authored by schultezub's avatar schultezub

added mipmap filtering to GL textures

further work on AdvancedUsFusion processor introducing pixelate mode

git-svn-id: https://camplinux.in.tum.de/svn/campvis/trunk@471 bb408c1c-ae56-11e1-83d9-df6b3e0c105e
parent 78025428
......@@ -70,7 +70,7 @@ namespace campvis {
tgt::col4 diff = _rightColor - _leftColor;
for (size_t i = 0; i < _size.x; ++i) {
float multiplier = static_cast<float>(i) / _size.x;
float multiplier = static_cast<float>(i) / (_size.x - 1);
tgt::col4& texel = _texture->texel<tgt::col4>(i);
for (size_t j = 0; j < 4; ++j) {
texel[j] = static_cast<uint8_t>(_leftColor[j] + (static_cast<float>(diff[j]) * multiplier));
......
......@@ -117,7 +117,7 @@ namespace campvis {
void ImageRepresentationGL::createTexture(const WeaklyTypedPointer& wtp) {
tgtAssert(wtp._pointer != 0, "Pointer to image data must not be 0!");
_texture = new tgt::Texture(reinterpret_cast<GLubyte*>(wtp._pointer), getSize(), wtp.getGlFormat(), wtp.getGlInternalFormat(), wtp.getGlDataType(), tgt::Texture::LINEAR);
_texture = new tgt::Texture(reinterpret_cast<GLubyte*>(wtp._pointer), getSize(), wtp.getGlFormat(), wtp.getGlInternalFormat(), wtp.getGlDataType(), tgt::Texture::MIPMAP);
setupAndUploadTexture(_texture, wtp.isInteger(), wtp.isSigned());
}
......
......@@ -44,6 +44,7 @@ namespace campvis {
: AbstractPipeline()
, tgt::EventListener()
, _lqMode(false)
, _ignoreCanvasSizeUpdate(false)
, _canvasSize("CanvasSize", "Canvas Size", tgt::ivec2(128, 128), tgt::ivec2(1, 1), tgt::ivec2(4096, 4096))
, _effectiveRenderTargetSize("EffectiveRenderTargetSize", "Render Target Size", tgt::ivec2(128, 128), tgt::ivec2(1, 1), tgt::ivec2(4096, 4096))
, _renderTargetID("renderTargetID", "Render Target ID", "VisualizationPipeline.renderTarget")
......@@ -85,8 +86,9 @@ namespace campvis {
}
void VisualizationPipeline::setRenderTargetSize(const tgt::ivec2& size) {
if (_canvasSize.getValue() != size)
if (_canvasSize.getValue() != size && !_ignoreCanvasSizeUpdate) {
_canvasSize.setValue(size);
}
updateEffectiveRenderTargetSize();
}
......@@ -116,9 +118,12 @@ namespace campvis {
void VisualizationPipeline::onPropertyChanged(const AbstractProperty* prop) {
if (prop == &_renderTargetID)
s_renderTargetChanged();
else if (prop == &_canvasSize && _canvas != 0) {
if (_canvasSize.getValue() != _canvas->getSize())
else if (prop == &_canvasSize && _canvas != 0 && !_ignoreCanvasSizeUpdate) {
if (_canvasSize.getValue() != _canvas->getSize()) {
_ignoreCanvasSizeUpdate = true;
_canvas->setSize(_canvasSize.getValue());
_ignoreCanvasSizeUpdate = false;
}
}
else
AbstractPipeline::onPropertyChanged(prop);
......
......@@ -180,6 +180,7 @@ namespace campvis {
IVec2Property _canvasSize; ///< original canvas size
bool _lqMode; ///< Flag whether low quality mode is enables
bool _ignoreCanvasSizeUpdate;
IVec2Property _effectiveRenderTargetSize; ///< actual size of the render targets (considering LQ mode)
StringProperty _renderTargetID; ///< ID of the render target image to be rendered to the canvas
......
......@@ -292,8 +292,8 @@ void Texture::applyFilter() {
glTexParameterf(type_, GL_TEXTURE_MAX_ANISOTROPY_EXT, GpuCaps.getMaxTextureAnisotropy());
case MIPMAP:
glTexParameteri(type_,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(type_,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(type_,GL_TEXTURE_MAG_FILTER,GL_NEAREST_MIPMAP_NEAREST);
glTexParameteri(type_,GL_TEXTURE_MIN_FILTER,GL_NEAREST_MIPMAP_NEAREST);
glTexParameteri(type_, GL_SGIS_generate_mipmap, GL_TRUE);
break;
}
......@@ -326,17 +326,23 @@ void Texture::uploadTexture() {
case GL_TEXTURE_1D:
glTexImage1D(GL_TEXTURE_1D, 0, internalformat_, dimensions_.x, 0,
format_, dataType_, pixels_);
if (filter_ == MIPMAP)
glGenerateMipmap(GL_TEXTURE_1D);
break;
case GL_TEXTURE_2D:
glTexImage2D(GL_TEXTURE_2D, 0, internalformat_, dimensions_.x, dimensions_.y, 0,
format_, dataType_, pixels_);
if (filter_ == MIPMAP)
glGenerateMipmap(GL_TEXTURE_2D);
break;
case GL_TEXTURE_3D:
glTexImage3D(GL_TEXTURE_3D, 0, internalformat_,
dimensions_.x, dimensions_.y, dimensions_.z, 0,
format_, dataType_, pixels_);
if (filter_ == MIPMAP)
glGenerateMipmap(GL_TEXTURE_3D);
break;
#ifdef GL_TEXTURE_RECTANGLE_ARB
......
......@@ -61,7 +61,9 @@ uniform TFParameters1D _transferFunctionParams;
uniform int _sliceNumber;
uniform int _viewIndex;
uniform float _blurredScaling;
uniform float _confidenceScaling;
uniform float _hue;
void main() {
#ifdef USE_3D_TEX
......@@ -71,8 +73,8 @@ void main() {
#endif
vec4 texel = TEXTURE_LOOKUP_FUNC(_usImage, _usTextureParams, texCoord);
vec4 blurred = TEXTURE_LOOKUP_FUNC(_blurredImage, _blurredTextureParams, texCoord) * _blurredScaling;
float confidence = TEXTURE_LOOKUP_FUNC(_confidenceMap, _confidenceTextureParams, texCoord).a;
vec4 blurred = TEXTURE_LOOKUP_FUNC(_blurredImage, _blurredTextureParams, texCoord);
float confidence = clamp(TEXTURE_LOOKUP_FUNC(_confidenceMap, _confidenceTextureParams, texCoord).a * _confidenceScaling, 0.0, 1.0);
switch (_viewIndex) {
case 0:
......@@ -87,35 +89,35 @@ void main() {
case 3:
out_Color = lookupTF(_transferFunction, _transferFunctionParams, texel.a);
vec3 hsv = rgb2hsv(out_Color.xyz);
hsv.x = 0.15;
hsv.x = _hue;
hsv.y = 1.0 - confidence;
out_Color.xyz = hsv2rgb(hsv);
break;
case 4:
out_Color = lookupTF(_transferFunction, _transferFunctionParams, texel.a);
vec3 hsl = rgb2hsl(out_Color.xyz);
hsl.x = 0.15;
hsl.x = _hue;
hsl.y = 1.0 - confidence;
out_Color.xyz = hsl2rgb(hsl);
break;
case 5:
out_Color = lookupTF(_transferFunction, _transferFunctionParams, texel.a);
vec3 tsl = rgb2tsl(out_Color.xyz);
//tsl.x = 0.15;
//tsl.x = _hue;
//tsl.y = 1.0 - confidence;
out_Color.xyz = tsl2rgb(tsl);
break;
case 6:
out_Color = lookupTF(_transferFunction, _transferFunctionParams, texel.a);
vec3 hcl = rgb2hcl(out_Color.xyz);
hcl.x = 0.15;
hcl.x = _hue;
hcl.y = 1.0 - confidence;
out_Color.xyz = hcl2rgb(hcl);
break;
case 7:
out_Color = lookupTF(_transferFunction, _transferFunctionParams, texel.a);
vec3 hcy = rgb2hcy(out_Color.xyz);
hcy.x = 0.15;
hcy.x = _hue;
hcy.y = 1.0 - confidence;
out_Color.xyz = hcy2rgb(hcy);
break;
......@@ -127,8 +129,14 @@ void main() {
out_Color.xyz = lab2rgb(lab);
break;
case 9:
float intensity = mix(blurred.a, 2.0 * texel.a - blurred.a, confidence);
float intensity = mix(blurred.a, (2.0 * texel.a - blurred.a), confidence);
out_Color = lookupTF(_transferFunction, _transferFunctionParams, intensity);
break;
case 10:
float lod = max(floor((1.0 - confidence) * 8.0), 0.0);
vec4 lodTexel = texture(_usImage, texCoord, lod);
out_Color = lookupTF(_transferFunction, _transferFunctionParams, lodTexel.a);
break;
}
}
......@@ -44,7 +44,7 @@
namespace campvis {
const std::string AdvancedUsFusion::loggerCat_ = "CAMPVis.modules.vis.AdvancedUsFusion";
GenericOption<std::string> viewOptions[10] = {
GenericOption<std::string> viewOptions[11] = {
GenericOption<std::string>("us", "Ultrasound Only"),
GenericOption<std::string>("smoothed", "Smoothed US Only"),
GenericOption<std::string>("sharpened", "Sharpened US Only"),
......@@ -54,7 +54,8 @@ namespace campvis {
GenericOption<std::string>("mappingChromacityHCL", "Mapping Uncertainty to Chromacity (HCL)"),
GenericOption<std::string>("mappingChromacityHCY", "Mapping Uncertainty to Chromacity (HCY)"),
GenericOption<std::string>("mappingLAB", "Mapping Uncertainty L*a*b"),
GenericOption<std::string>("mappingSharpness", "Mapping Uncertainty to Sharpness")
GenericOption<std::string>("mappingSharpness", "Mapping Uncertainty to Sharpness"),
GenericOption<std::string>("pixelate", "Pixelate (Experimental)")
};
AdvancedUsFusion::AdvancedUsFusion(IVec2Property& canvasSize)
......@@ -66,8 +67,9 @@ namespace campvis {
, p_targetImageID("targetImageID", "Output Image", "", DataNameProperty::WRITE)
, p_sliceNumber("sliceNumber", "Slice Number", 0, 0, 0)
, p_transferFunction("transferFunction", "Transfer Function", new SimpleTransferFunction(256))
, p_view("View", "Image to Render", viewOptions, 10)
, p_blurredScaling("BlurredScaling", "Scaling for blurred image intensity", 1.f, .001f, 1000.f)
, p_view("View", "Image to Render", viewOptions, 11)
, p_confidenceScaling("ConfidenceScaling", "Confidence Scaling", 1.f, .001f, 1000.f)
, p_hue("Hue", "Hue for Uncertainty Mapping", .15f, 0.f, 1.f)
, p_use3DTexture("Use3DTexture", "Use 3D Texture", false)
, _shader(0)
{
......@@ -79,7 +81,8 @@ namespace campvis {
addProperty(&p_sliceNumber);
addProperty(&p_transferFunction);
addProperty(&p_view);
addProperty(&p_blurredScaling);
addProperty(&p_confidenceScaling);
addProperty(&p_hue);
decoratePropertyCollection(this);
}
......@@ -119,10 +122,12 @@ namespace campvis {
_shader->activate();
decorateRenderProlog(data, _shader);
_shader->setUniform("_sliceNumber", p_sliceNumber.getValue());
if (p_use3DTexture.getValue())
_shader->setUniform("_sliceNumber", p_sliceNumber.getValue());
_shader->setUniform("_viewIndex", p_view.getValue());
_shader->setUniform("_blurredScaling", p_blurredScaling.getValue());
_shader->setUniform("_confidenceScaling", p_confidenceScaling.getValue());
_shader->setUniform("_hue", p_hue.getValue());
tgt::TextureUnit usUnit, blurredUnit, confidenceUnit, tfUnit;
img->bind(_shader, usUnit, "_usImage", "_usTextureParams");
blurred->bind(_shader, blurredUnit, "_blurredImage", "_blurredTextureParams");
......
......@@ -85,7 +85,8 @@ namespace campvis {
IntProperty p_sliceNumber; ///< number of the slice to extract
TransferFunctionProperty p_transferFunction; ///< Transfer function
GenericOptionProperty<std::string> p_view;
FloatProperty p_blurredScaling;
FloatProperty p_confidenceScaling;
FloatProperty p_hue;
BoolProperty p_use3DTexture;
protected:
......
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