Commit 69802977 authored by schultezub's avatar schultezub

* some fixes in DataContainerInspectorCanvas

 * added tgt::Texture::isDepthTexture()
 * added more color conversions and updated AdvancedUsFusion processor, L*a*b*/L*C*H* still not working correctly...

git-svn-id: https://camplinux.in.tum.de/svn/campvis/trunk@473 bb408c1c-ae56-11e1-83d9-df6b3e0c105e
parent 604bb4b7
......@@ -51,6 +51,7 @@ uniform TFParameters1D _transferFunctionParams;
uniform bool _is3d;
uniform int _sliceNumber;
uniform vec4 _color;
uniform bool _isDepthTexture;
const vec4 checkerboardColor1 = vec4(0.90, 0.90, 0.90, 1.0);
const vec4 checkerboardColor2 = vec4(0.50, 0.50, 0.50, 1.0);
......@@ -73,7 +74,7 @@ void main() {
else {
vec4 texel = getElement2DNormalized(_texture2d, _2dTextureParams, ex_TexCoord.xy);
if (_2dTextureParams._numChannels == 1) {
out_Color = lookupTF(_transferFunction, _transferFunctionParams, texel.a);
out_Color = lookupTF(_transferFunction, _transferFunctionParams, (_isDepthTexture ? texel.r : texel.a));
}
else if (_2dTextureParams._numChannels == 3) {
out_Color = vec4(abs(texel.rgb), 1.0);
......
......@@ -39,7 +39,8 @@
#include "core/datastructures/imagerepresentationgl.h"
#include "core/datastructures/facegeometry.h"
#include "core/tools/job.h"
#include "core/classification/simpletransferfunction.h"
#include "core/classification/tfgeometry1d.h"
#include "core/classification/geometry1dtransferfunction.h"
namespace campvis {
......@@ -47,7 +48,7 @@ namespace campvis {
DataContainerInspectorCanvas::DataContainerInspectorCanvas(QWidget* parent /*= 0*/)
: tgt::QtThreadedCanvas("DataContainer Inspector", tgt::ivec2(640, 480), tgt::GLCanvas::RGBA_BUFFER, parent, true)
, p_currentSlice("CurrentSlice", "Slice", -1, -1, -1)
, p_transferFunction("TransferFunction", "Transfer Function", new SimpleTransferFunction(64))
, p_transferFunction("TransferFunction", "Transfer Function", new Geometry1DTransferFunction(256, tgt::vec2(0.f, 1.f)))
, _dataContainer(0)
, _paintShader(0)
, _quad(0)
......@@ -57,6 +58,7 @@ namespace campvis {
, _renderFullscreen(false)
, _currentSlice(-1)
{
static_cast<Geometry1DTransferFunction*>(p_transferFunction.getTF())->addGeometry(TFGeometry1D::createQuad(tgt::vec2(0.f, 1.f), tgt::col4(0, 0, 0, 255), tgt::col4(255, 255, 255, 255)));
makeCurrent();
// Init GLEW for this context
......@@ -162,6 +164,7 @@ namespace campvis {
unit2d.activate();
texture->bind();
_paintShader->setUniform("_is3d", false);
_paintShader->setUniform("_isDepthTexture", texture->isDepthTexture());
_paintShader->setUniform("_2dTextureParams._size", tgt::vec2(texture->getDimensions().xy()));
_paintShader->setUniform("_2dTextureParams._sizeRCP", tgt::vec2(1.f) / tgt::vec2(texture->getDimensions().xy()));
_paintShader->setUniform("_2dTextureParams._numChannels", static_cast<int>(texture->getNumChannels()));
......@@ -251,7 +254,7 @@ namespace campvis {
// existant -> replace
lb->second = QtDataHandle(dh);
// update _textures array
updateTextures();
_texturesDirty = true;
}
}
......
......@@ -141,7 +141,7 @@ namespace campvis {
/**
* Updates the textures vector.
* \note Only call with acquired lock!!
* \note Only call with acquired lock and valid OpenGL context!!
*/
void updateTextures();
......
......@@ -323,9 +323,9 @@ vec3 xyz2lab(in vec3 XYZ) {
}
float lab_helper_invF(in float p) {
float r = p*p*p;
float r = pow(p, 3.0);
if (r < 0.008856)
return (p-4.0/29.0)*(108.0/841.0);
return (p - 4.0/29.0)*(108.0/841.0);
else
return r;
}
......@@ -340,10 +340,84 @@ vec3 lab2xyz(in vec3 LAB) {
return vec3(X, Y, Z);
}
// ================================================================================================
const float lab_epsilon_ = 0.008856;
const float lab_kappa_ = 903.3;
const float pi_ = 3.14159265;
const float two_pi_ = 6.2831853;
float lab_helper_F2(in float p) {
if (p > lab_epsilon_)
return pow(p, 1.0/3.0);
else
return (lab_kappa_ * p + 16.0) / 116.0;
}
vec3 xyz2lab2(in vec3 XYZ) {
float fX = XYZ.x/0.950456;
float fY = XYZ.y/1.0;
float fZ = XYZ.z/1.088754;
fX = lab_helper_F2(fX);
fY = lab_helper_F2(fY);
fZ = lab_helper_F2(fZ);
return vec3(116.0 * fY - 16.0,
500.0 * (fX - fY),
200.0 * (fY - fZ));
}
float lab_helper_invF2(in float p) {
float r = p*p*p;
if (r < 0.008856)
return (p-4.0/29.0)*(108.0/841.0);
else
return r;
}
vec3 lab2xyz2(in vec3 LAB) {
float yr = (LAB.x > lab_kappa_ * lab_epsilon_) ? pow((LAB.x + 16.0) / 116.0, 3.0) : LAB.x / lab_kappa_;
float fy = (yr > lab_epsilon_) ? (LAB.x + 16.0) / 116.0 : (lab_kappa_ * yr + 16.0) / 116.0;
float fx = LAB.y / 500.0 + fy;
float fz = fy - LAB.z / 200.0;
float xr = (pow(fx, 3.0) > lab_epsilon_) ? pow(fx, 3.0) : (fx * 116.0 - 16.0) / lab_kappa_;
float zr = (pow(fz, 3.0) > lab_epsilon_) ? pow(fz, 3.0) : (fz * 116.0 - 16.0) / lab_kappa_;
return vec3(
0.950456 * xr,
1.0 * yr,
1.088754 * zr);
}
vec3 lab2lch(in vec3 LAB) {
LAB.y = sqrt(pow(LAB.y, 2.0) + pow(LAB.z, 2.0));
LAB.z = atan(LAB.z, LAB.y);
LAB.z = mod(LAB.z, two_pi_);
return LAB;
}
vec3 lch2lab(in vec3 LCH) {
float c = LCH.y;
LCH.y = cos(LCH.z) * c;
LCH.z = sin(LCH.z) * c;
return LCH;
}
vec3 rgb2lab(in vec3 RGB) {
return xyz2lab(rgb2ciexyz(RGB));
}
vec3 lab2rgb(in vec3 LAB) {
return ciexyz2rgb(lab2xyz(LAB));
}
vec3 rgb2lch(in vec3 RGB) {
return lab2lch(rgb2lab(RGB));
}
vec3 lch2rgb(in vec3 LCH) {
return lab2rgb(lch2lab(LCH));
}
\ No newline at end of file
......@@ -43,9 +43,9 @@ struct TFParameters2D {
*/
float mapIntensityToTFDomain(in vec2 intensityDomain, in float intensity) {
if(intensity < intensityDomain.x)
return -1.0;
return 0.0;
else if(intensity > intensityDomain.y)
return -1.0;
return 1.0;
else
return (intensity - intensityDomain.x) / (intensityDomain.y - intensityDomain.x);
}
......
......@@ -292,9 +292,8 @@ void Texture::applyFilter() {
glTexParameterf(type_, GL_TEXTURE_MAX_ANISOTROPY_EXT, GpuCaps.getMaxTextureAnisotropy());
case MIPMAP:
glTexParameteri(type_,GL_TEXTURE_MAG_FILTER,GL_NEAREST_MIPMAP_NEAREST);
glTexParameteri(type_,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
glTexParameteri(type_,GL_TEXTURE_MIN_FILTER,GL_NEAREST_MIPMAP_NEAREST);
glTexParameteri(type_, GL_SGIS_generate_mipmap, GL_TRUE);
break;
}
}
......@@ -501,4 +500,13 @@ bool Texture::isTextureRectangle() const {
#endif
}
bool Texture::isDepthTexture() const {
return internalformat_ == GL_DEPTH_COMPONENT
|| internalformat_ == GL_DEPTH_COMPONENT16
|| internalformat_ == GL_DEPTH_COMPONENT24
|| internalformat_ == GL_DEPTH_COMPONENT32
|| internalformat_ == GL_DEPTH_COMPONENT32F;
}
} // namespace tgt
......@@ -309,6 +309,12 @@ public:
*/
bool isTextureRectangle() const;
/**
* Returns, whether texture is a depth texture.
* \return internalformat_ == GL_DEPTH_COMPONENT
*/
bool isDepthTexture() const;
/*
1D access, always possible
*/
......
......@@ -76,67 +76,72 @@ void main() {
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:
out_Color = lookupTF(_transferFunction, _transferFunctionParams, texel.a);
break;
case 1:
out_Color = lookupTF(_transferFunction, _transferFunctionParams, blurred.a);
break;
case 2:
out_Color = lookupTF(_transferFunction, _transferFunctionParams, texel.a + texel.a - blurred.a);
break;
case 3:
out_Color = lookupTF(_transferFunction, _transferFunctionParams, texel.a);
vec3 hsv = rgb2hsv(out_Color.xyz);
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 = _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 = _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 = _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 = _hue;
hcy.y = 1.0 - confidence;
out_Color.xyz = hcy2rgb(hcy);
break;
case 8:
out_Color = lookupTF(_transferFunction, _transferFunctionParams, texel.a);
vec3 lab = rgb2lab(out_Color.xyz);
lab.y = (1.0 - confidence);
//lab.z = 50.0 * (1.0 - confidence);
out_Color.xyz = lab2rgb(lab);
break;
case 9:
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);
if (confidence <= 0.0) {
out_Color = lookupTF(_transferFunction, _transferFunctionParams, texel.a);
}
else {
switch (_viewIndex) {
case 0:
out_Color = lookupTF(_transferFunction, _transferFunctionParams, texel.a);
break;
case 1:
out_Color = lookupTF(_transferFunction, _transferFunctionParams, blurred.a);
break;
case 2:
out_Color = lookupTF(_transferFunction, _transferFunctionParams, texel.a + texel.a - blurred.a);
break;
case 3:
out_Color = lookupTF(_transferFunction, _transferFunctionParams, texel.a);
vec3 hsv = rgb2hsv(out_Color.xyz);
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 = _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 = _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 = _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 = _hue;
hcy.y = 1.0 - confidence;
out_Color.xyz = hcy2rgb(hcy);
break;
case 8:
out_Color = lookupTF(_transferFunction, _transferFunctionParams, texel.a);
vec3 lab = rgb2lch(out_Color.xyz);
//lab.y = 100.0 * _hue * (1.0 - confidence) - 50.0;
//lab.z = 100.0 * _hue * (1.0 - confidence);
out_Color.xyz = lch2rgb(lab);
break;
case 9:
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) * 6.0), 0.0);
vec4 lodTexel = texture(_usImage, texCoord, lod);
out_Color = lookupTF(_transferFunction, _transferFunctionParams, lodTexel.a);
break;
vec4 lodTexel = texture(_usImage, texCoord, lod);
out_Color = lookupTF(_transferFunction, _transferFunctionParams, lodTexel.a);
break;
}
}
}
......@@ -95,9 +95,9 @@ namespace campvis {
_camera.addSharedProperty(&_usEEP.p_camera);
_camera.addSharedProperty(&_usDVR.p_camera);
//_usReader.p_url.setValue("D:\\Medical Data\\US Confidence Vis\\CurefabCS\\Stent_Patient_ B-Mode_2013-02-11T14.56.46z\\01_us.mhd");
_usReader.p_url.setValue("D:\\Medical Data\\US Confidence Vis\\CurefabCS\\Stent_Patient_ B-Mode_2013-02-11T14.56.46z\\01_us.mhd");
//_usReader.p_url.setValue("D:\\Medical Data\\US Confidence Vis\\01\\BMode_01.mhd");
_usReader.p_url.setValue("D:\\Medical Data\\US Confidence Vis\\UltrasoundBoneData\\SynthesEvaluationUnterschenkel");
//_usReader.p_url.setValue("D:\\Medical Data\\US Confidence Vis\\UltrasoundBoneData\\SynthesEvaluationUnterschenkel");
//_usReader.p_url.setValue("D:\\Medical Data\\US Confidence Vis\\transcranial\\us.png");
_usReader.p_targetImageID.setValue("us.image");
_usReader.p_targetImageID.connect(&_confidenceGenerator.p_sourceImageID);
......@@ -110,9 +110,9 @@ namespace campvis {
_usReader.p_targetImageID.connect(&_usBlurFilter.p_sourceImageID);
_usReader.p_targetImageID.connect(&_usDenoiseilter.p_sourceImageID);
//_confidenceReader.p_url.setValue("D:\\Medical Data\\US Confidence Vis\\CurefabCS\\Stent_Patient_ B-Mode_2013-02-11T14.56.46z\\01_cm.mhd");
_confidenceReader.p_url.setValue("D:\\Medical Data\\US Confidence Vis\\CurefabCS\\Stent_Patient_ B-Mode_2013-02-11T14.56.46z\\01_cm.mhd");
//_confidenceReader.p_url.setValue("D:\\Medical Data\\US Confidence Vis\\01\\Confidence_01.mhd");
_confidenceReader.p_url.setValue("D:\\Medical Data\\US Confidence Vis\\UltrasoundBoneData\\SynthesEvaluationUnterschenkel");
//_confidenceReader.p_url.setValue("D:\\Medical Data\\US Confidence Vis\\UltrasoundBoneData\\SynthesEvaluationUnterschenkel");
//_confidenceReader.p_url.setValue("D:\\Medical Data\\US Confidence Vis\\transcranial\\cm.png");
_confidenceReader.p_targetImageID.setValue("confidence.image.read");
_confidenceReader.p_targetImageID.connect(&_usFusion1.p_confidenceImageID);
......
......@@ -89,8 +89,8 @@ namespace campvis {
CameraProperty _camera;
CsvdImageReader _usReader;
CsvdImageReader _confidenceReader;
MhdImageReader _usReader;
MhdImageReader _confidenceReader;
ConfidenceMapGenerator _confidenceGenerator;
GradientVolumeGenerator _gvg;
......
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