Commit 0a605c92 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[CHANGE #172] colormapper now also uses the upper threshold value.

parent d8287c1c
......@@ -43,9 +43,15 @@ WDataTexture3D::WDataTexture3D( boost::shared_ptr< WValueSetBase > valueSet, boo
setWrap( osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_BORDER );
setWrap( osg::Texture::WRAP_R, osg::Texture::CLAMP_TO_BORDER );
threshold()->setMin( valueSet->getMinimumValue() );
threshold()->setMax( valueSet->getMaximumValue() );
threshold()->set( valueSet->getMinimumValue() );
thresholdLower()->setMin( valueSet->getMinimumValue() );
thresholdLower()->setMax( valueSet->getMaximumValue() );
thresholdLower()->set( valueSet->getMinimumValue() );
thresholdUpper()->setMin( valueSet->getMinimumValue() );
thresholdUpper()->setMax( valueSet->getMaximumValue() );
thresholdUpper()->set( valueSet->getMaximumValue() );
window()->set( make_interval( valueSet->getMinimumValue(),
valueSet->getMaximumValue() ) );
// Scale according to bbox. This scaling is NOT included in the grid's transform, so we need to add it here
WMatrix4d scale = WMatrix4d::zero();
......
......@@ -123,7 +123,14 @@ public:
*
* \return threshold property
*/
WPropDouble threshold() const;
WPropDouble thresholdLower() const;
/**
* Returns the threshold property. The property can be changed. A change affects all colormaps using this texture.
*
* \return threshold property
*/
WPropDouble thresholdUpper() const;
/**
* Returns the property responsible for enabling threshold based clipping. If this is false, the threshold is ignored.
......@@ -344,7 +351,12 @@ private:
/**
* Threshold for clipping areas.
*/
WPropDouble m_threshold;
WPropDouble m_thresholdLower;
/**
* Threshold for clipping areas.
*/
WPropDouble m_thresholdUpper;
/**
* Threshold-enable flag.
......@@ -450,9 +462,13 @@ void WGETexture< TextureType >::setupProperties( double scale, double min )
m_thresholdEnabled = m_properties->addProperty( "Enable Threshold",
"If enabled, threshold based clipping is used. If not, threshold is ignored.", false );
m_threshold = m_properties->addProperty( "Threshold", "The threshold used to clip areas.", 0.0 );
m_threshold->setMin( min );
m_threshold->setMax( min + scale );
m_thresholdLower = m_properties->addProperty( "Lower Threshold", "The threshold used to clip areas below the specified value.", 0.0 );
m_thresholdLower->setMin( min );
m_thresholdLower->setMax( min + scale );
m_thresholdUpper = m_properties->addProperty( "Upper Threshold", "The threshold used to clip areas above the specified value.", 1.0 );
m_thresholdUpper->setMin( min );
m_thresholdUpper->setMax( min + scale );
m_windowEnabled = m_properties->addProperty( "Enable Windowing", "If enabled, window level settings are applied.", false );
m_window = m_properties->addProperty( "Window Level", "Define the interval in the data which is mapped to the colormap.",
......@@ -531,9 +547,15 @@ inline WPropDouble WGETexture< TextureType >::alpha() const
}
template < typename TextureType >
inline WPropDouble WGETexture< TextureType >::threshold() const
inline WPropDouble WGETexture< TextureType >::thresholdLower() const
{
return m_thresholdLower;
}
template < typename TextureType >
inline WPropDouble WGETexture< TextureType >::thresholdUpper() const
{
return m_threshold;
return m_thresholdUpper;
}
template < typename TextureType >
......@@ -595,7 +617,8 @@ void WGETexture< TextureType >::applyUniforms( std::string prefix, osg::StateSe
states->addUniform( new WGEPropertyUniform< WPropDouble >( prefix + "Scale", scale() ) );
states->addUniform( new WGEPropertyUniform< WPropDouble >( prefix + "Alpha", alpha() ) );
states->addUniform( new WGEPropertyUniform< WPropBool >( prefix + "ThresholdEnabled", thresholdEnabled() ) );
states->addUniform( new WGEPropertyUniform< WPropDouble >( prefix + "Threshold", threshold() ) );
states->addUniform( new WGEPropertyUniform< WPropDouble >( prefix + "ThresholdLower", thresholdLower() ) );
states->addUniform( new WGEPropertyUniform< WPropDouble >( prefix + "ThresholdUpper", thresholdUpper() ) );
states->addUniform( new WGEPropertyUniform< WPropSelection >( prefix + "Colormap", colormap() ) );
states->addUniform( new WGEPropertyUniform< WPropBool >( prefix + "Active", active() ) );
states->addUniform( new WGEPropertyUniform< WPropBool >( prefix + "WindowEnabled", windowEnabled() ) );
......
......@@ -82,19 +82,26 @@ float clipZero( in vec3 valueDescaled )
*
* \param valueDescaled the descaled data. Scalar or vector.
* \param colormap if this is a vector colormap, thresholding is done using vector length.
* \param thresholdV the descaled threshold value
* \param thresholdVLower the descaled threshold value
* \param thresholdVUpper the descaled threshold value
* \param thresholdEnabled flag denoting whether to use thresholding or not
*
* \return 0.0 if clipped
*/
float clipThreshold( in vec3 valueDescaled, in int colormap, in float thresholdV, in bool thresholdEnabled )
float clipThreshold( in vec3 valueDescaled, in int colormap, in float thresholdVLower, in float thresholdVUpper, in bool thresholdEnabled )
{
float isVec = float( colormap == 6 );
return max( 1.0 - float( thresholdEnabled ),
isVec * clamp( sign( length( valueDescaled ) - thresholdV ), 0.0, 1.0 )
isVec * clamp( sign( length( valueDescaled ) - thresholdVLower ) +
sign( 1.0 - ( length( valueDescaled ) - thresholdVUpper ) ),
0.0, 1.0 )
+
( 1.0 - isVec ) * clamp( sign( valueDescaled.r - ( thresholdV - 0.001 ) ), 0.0, 1.0 ) );
( 1.0 - isVec ) * clamp( sign( valueDescaled.r - ( thresholdVLower - 0.001 ) ) + // or
sign( 1.0 - ( valueDescaled.r - ( thresholdVUpper - 0.001 ) ) ),
0.0, 1.0 ) );
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
......@@ -431,7 +438,8 @@ vec4 atlas( in float value )
* \param value the value to map, <b>scaled</b>
* \param minV the minimum of the original value
* \param scaleV the scaler used to downscale the original value to [0-1]
* \param thresholdV a threshold in original space (you need to downscale it to [0-1] if you want to use it to scaled values.
* \param thresholdVLower a threshold in original space (you need to downscale it to [0-1] if you want to use it to scaled values.
* \param thresholdVUpper a threshold in original space (you need to downscale it to [0-1] if you want to use it to scaled values.
* \param thresholdEnabled a flag denoting whether threshold-based clipping should be done or not
* \param window a window level scaling in the descaled value
* \param windowEnabled if true, the window level scaling is applied
......@@ -439,7 +447,7 @@ vec4 atlas( in float value )
* \param colormap the colormap index to use
*/
vec4 colormap( in vec4 value, float minV, float scaleV,
float thresholdV, bool thresholdEnabled,
float thresholdVLower, float thresholdVUpper, bool thresholdEnabled,
vec2 window, bool windowEnabled,
float alpha, int colormap, bool active )
{
......@@ -479,7 +487,7 @@ vec4 colormap( in vec4 value, float minV, float scaleV,
// use threshold to clip away fragments.
// NOTE: thresholding is applied to the original interval in valueDescaled, NOT the window interval
float clipTh = clipThreshold( valueDescaled, colormap, thresholdV, thresholdEnabled );
float clipTh = clipThreshold( valueDescaled, colormap, thresholdVLower, thresholdVUpper, thresholdEnabled );
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Do colormapping
......
......@@ -42,7 +42,8 @@
* \param size the size in voxels
* \param minV the minimum of the original value
* \param scaleV the scaler used to downscale the original value to [0-1]
* \param thresholdV a threshold in original space (you need to downscale it to [0-1] if you want to use it to scaled values.
* \param thresholdVLower a threshold in original space (you need to downscale it to [0-1] if you want to use it to scaled values.
* \param thresholdVUpper a threshold in original space (you need to downscale it to [0-1] if you want to use it to scaled values.
* \param window a window level scaling
* \param windowEnabled if true, the window level scaling is applied
* \param alpha the alpha blending value
......@@ -50,7 +51,7 @@
*/
void colormap( inout vec4 color, in sampler3D sampler, in vec3 coord, in vec3 size,
float minV, float scaleV,
float thresholdV, bool thresholdEnabled,
float thresholdVLower, float thresholdVUpper, bool thresholdEnabled,
bool windowEnabled, vec2 window,
float alpha, int cmap, bool active )
{
......@@ -88,7 +89,7 @@ void colormap( inout vec4 color, in sampler3D sampler, in vec3 coord, in vec3 si
vec4 value = texture3D( sampler, coord ).rgba;
// let someone else apply the colormap
vec4 src = colormap( value, minV, scaleV, thresholdV, thresholdEnabled, window, windowEnabled, alpha, cmap, active );
vec4 src = colormap( value, minV, scaleV, thresholdVLower, thresholdVUpper, thresholdEnabled, window, windowEnabled, alpha, cmap, active );
// compositing:
// associated colors needed
......@@ -118,56 +119,56 @@ vec4 colormapping( vec4 texcoord )
#ifdef Colormap7Enabled
colormap( finalColor, u_colormap7Sampler, ( gl_TextureMatrix[ Colormap7Unit ] * t ).xyz,
vec3( u_colormap7SizeX, u_colormap7SizeY, u_colormap7SizeZ ),
u_colormap7Min, u_colormap7Scale, u_colormap7Threshold, u_colormap7ThresholdEnabled,
u_colormap7Min, u_colormap7Scale, u_colormap7ThresholdLower, u_colormap7ThresholdUpper, u_colormap7ThresholdEnabled,
u_colormap7WindowEnabled, u_colormap7Window,
u_colormap7Alpha, u_colormap7Colormap, u_colormap7Active );
#endif
#ifdef Colormap6Enabled
colormap( finalColor, u_colormap6Sampler, ( gl_TextureMatrix[ Colormap6Unit ] * t ).xyz,
vec3( u_colormap6SizeX, u_colormap6SizeY, u_colormap6SizeZ ),
u_colormap6Min, u_colormap6Scale, u_colormap6Threshold, u_colormap6ThresholdEnabled,
u_colormap6Min, u_colormap6Scale, u_colormap6ThresholdLower, u_colormap6ThresholdUpper, u_colormap6ThresholdEnabled,
u_colormap6WindowEnabled, u_colormap6Window,
u_colormap6Alpha, u_colormap6Colormap, u_colormap6Active );
#endif
#ifdef Colormap5Enabled
colormap( finalColor, u_colormap5Sampler, ( gl_TextureMatrix[ Colormap5Unit ] * t ).xyz,
vec3( u_colormap5SizeX, u_colormap5SizeY, u_colormap5SizeZ ),
u_colormap5Min, u_colormap5Scale, u_colormap5Threshold, u_colormap5ThresholdEnabled,
u_colormap5Min, u_colormap5Scale, u_colormap5ThresholdLower, u_colormap5ThresholdUpper, u_colormap5ThresholdEnabled,
u_colormap5WindowEnabled, u_colormap5Window,
u_colormap5Alpha, u_colormap5Colormap, u_colormap5Active );
#endif
#ifdef Colormap4Enabled
colormap( finalColor, u_colormap4Sampler, ( gl_TextureMatrix[ Colormap4Unit ] * t ).xyz,
vec3( u_colormap4SizeX, u_colormap4SizeY, u_colormap4SizeZ ),
u_colormap4Min, u_colormap4Scale, u_colormap4Threshold, u_colormap4ThresholdEnabled,
u_colormap4Min, u_colormap4Scale, u_colormap4ThresholdLower, u_colormap4ThresholdUpper, u_colormap4ThresholdEnabled,
u_colormap4WindowEnabled, u_colormap4Window,
u_colormap4Alpha, u_colormap4Colormap, u_colormap4Active );
#endif
#ifdef Colormap3Enabled
colormap( finalColor, u_colormap3Sampler, ( gl_TextureMatrix[ Colormap3Unit ] * t ).xyz,
vec3( u_colormap3SizeX, u_colormap3SizeY, u_colormap3SizeZ ),
u_colormap3Min, u_colormap3Scale, u_colormap3Threshold, u_colormap3ThresholdEnabled,
u_colormap3Min, u_colormap3Scale, u_colormap3ThresholdLower, u_colormap3ThresholdUpper, u_colormap3ThresholdEnabled,
u_colormap3WindowEnabled, u_colormap3Window,
u_colormap3Alpha, u_colormap3Colormap, u_colormap3Active );
#endif
#ifdef Colormap2Enabled
colormap( finalColor, u_colormap2Sampler, ( gl_TextureMatrix[ Colormap2Unit ] * t ).xyz,
vec3( u_colormap2SizeX, u_colormap2SizeY, u_colormap2SizeZ ),
u_colormap2Min, u_colormap2Scale, u_colormap2Threshold, u_colormap2ThresholdEnabled,
u_colormap2Min, u_colormap2Scale, u_colormap2ThresholdLower, u_colormap2ThresholdUpper, u_colormap2ThresholdEnabled,
u_colormap2WindowEnabled, u_colormap2Window,
u_colormap2Alpha, u_colormap2Colormap, u_colormap2Active );
#endif
#ifdef Colormap1Enabled
colormap( finalColor, u_colormap1Sampler, ( gl_TextureMatrix[ Colormap1Unit ] * t ).xyz,
vec3( u_colormap1SizeX, u_colormap1SizeY, u_colormap1SizeZ ),
u_colormap1Min, u_colormap1Scale, u_colormap1Threshold, u_colormap1ThresholdEnabled,
u_colormap1Min, u_colormap1Scale, u_colormap1ThresholdLower, u_colormap1ThresholdUpper, u_colormap1ThresholdEnabled,
u_colormap1WindowEnabled, u_colormap1Window,
u_colormap1Alpha, u_colormap1Colormap, u_colormap1Active );
#endif
#ifdef Colormap0Enabled
colormap( finalColor, u_colormap0Sampler, ( gl_TextureMatrix[ Colormap0Unit ] * t ).xyz,
vec3( u_colormap0SizeX, u_colormap0SizeY, u_colormap0SizeZ ),
u_colormap0Min, u_colormap0Scale, u_colormap0Threshold, u_colormap0ThresholdEnabled,
u_colormap0Min, u_colormap0Scale, u_colormap0ThresholdLower, u_colormap0ThresholdUpper, u_colormap0ThresholdEnabled,
u_colormap0WindowEnabled, u_colormap0Window,
u_colormap0Alpha, u_colormap0Colormap, u_colormap0Active );
#endif
......@@ -191,7 +192,7 @@ vec4 colormapping()
#ifdef Colormap7Enabled
colormap( finalColor, u_colormap7Sampler, v_colormap7TexCoord.xyz,
vec3( u_colormap7SizeX, u_colormap7SizeY, u_colormap7SizeZ ),
u_colormap7Min, u_colormap7Scale, u_colormap7Threshold,
u_colormap7Min, u_colormap7Scale, u_colormap7ThresholdLower, u_colormap7ThresholdUpper,
u_colormap7ThresholdEnabled,
u_colormap7WindowEnabled, u_colormap7Window,
u_colormap7Alpha, u_colormap7Colormap, u_colormap7Active );
......@@ -199,7 +200,7 @@ vec4 colormapping()
#ifdef Colormap6Enabled
colormap( finalColor, u_colormap6Sampler, v_colormap6TexCoord.xyz,
vec3( u_colormap6SizeX, u_colormap6SizeY, u_colormap6SizeZ ),
u_colormap6Min, u_colormap6Scale, u_colormap6Threshold,
u_colormap6Min, u_colormap6Scale, u_colormap6ThresholdLower, u_colormap6ThresholdUpper,
u_colormap6ThresholdEnabled,
u_colormap6WindowEnabled, u_colormap6Window,
u_colormap6Alpha, u_colormap6Colormap, u_colormap6Active );
......@@ -207,7 +208,7 @@ vec4 colormapping()
#ifdef Colormap5Enabled
colormap( finalColor, u_colormap5Sampler, v_colormap5TexCoord.xyz,
vec3( u_colormap5SizeX, u_colormap5SizeY, u_colormap5SizeZ ),
u_colormap5Min, u_colormap5Scale, u_colormap5Threshold,
u_colormap5Min, u_colormap5Scale, u_colormap5ThresholdLower, u_colormap5ThresholdUpper,
u_colormap5ThresholdEnabled,
u_colormap5WindowEnabled, u_colormap5Window,
u_colormap5Alpha, u_colormap5Colormap, u_colormap5Active );
......@@ -215,7 +216,7 @@ vec4 colormapping()
#ifdef Colormap4Enabled
colormap( finalColor, u_colormap4Sampler, v_colormap4TexCoord.xyz,
vec3( u_colormap4SizeX, u_colormap4SizeY, u_colormap4SizeZ ),
u_colormap4Min, u_colormap4Scale, u_colormap4Threshold,
u_colormap4Min, u_colormap4Scale, u_colormap4ThresholdLower, u_colormap4ThresholdUpper,
u_colormap4ThresholdEnabled,
u_colormap4WindowEnabled, u_colormap4Window,
u_colormap4Alpha, u_colormap4Colormap, u_colormap4Active );
......@@ -223,7 +224,7 @@ vec4 colormapping()
#ifdef Colormap3Enabled
colormap( finalColor, u_colormap3Sampler, v_colormap3TexCoord.xyz,
vec3( u_colormap3SizeX, u_colormap3SizeY, u_colormap3SizeZ ),
u_colormap3Min, u_colormap3Scale, u_colormap3Threshold,
u_colormap3Min, u_colormap3Scale, u_colormap3ThresholdLower, u_colormap3ThresholdUpper,
u_colormap3ThresholdEnabled,
u_colormap3WindowEnabled, u_colormap3Window,
u_colormap3Alpha, u_colormap3Colormap, u_colormap3Active );
......@@ -231,7 +232,7 @@ vec4 colormapping()
#ifdef Colormap2Enabled
colormap( finalColor, u_colormap2Sampler, v_colormap2TexCoord.xyz,
vec3( u_colormap2SizeX, u_colormap2SizeY, u_colormap2SizeZ ),
u_colormap2Min, u_colormap2Scale, u_colormap2Threshold,
u_colormap2Min, u_colormap2Scale, u_colormap2ThresholdLower, u_colormap2ThresholdUpper,
u_colormap2ThresholdEnabled,
u_colormap2WindowEnabled, u_colormap2Window,
u_colormap2Alpha, u_colormap2Colormap, u_colormap2Active );
......@@ -239,7 +240,7 @@ vec4 colormapping()
#ifdef Colormap1Enabled
colormap( finalColor, u_colormap1Sampler, v_colormap1TexCoord.xyz,
vec3( u_colormap1SizeX, u_colormap1SizeY, u_colormap1SizeZ ),
u_colormap1Min, u_colormap1Scale, u_colormap1Threshold,
u_colormap1Min, u_colormap1Scale, u_colormap1ThresholdLower, u_colormap1ThresholdUpper,
u_colormap1ThresholdEnabled,
u_colormap1WindowEnabled, u_colormap1Window,
u_colormap1Alpha, u_colormap1Colormap, u_colormap1Active );
......@@ -247,7 +248,7 @@ vec4 colormapping()
#ifdef Colormap0Enabled
colormap( finalColor, u_colormap0Sampler, v_colormap0TexCoord.xyz,
vec3( u_colormap0SizeX, u_colormap0SizeY, u_colormap0SizeZ ),
u_colormap0Min, u_colormap0Scale, u_colormap0Threshold,
u_colormap0Min, u_colormap0Scale, u_colormap0ThresholdLower, u_colormap0ThresholdUpper,
u_colormap0ThresholdEnabled,
u_colormap0WindowEnabled, u_colormap0Window,
u_colormap0Alpha, u_colormap0Colormap, u_colormap0Active );
......
......@@ -44,7 +44,10 @@ uniform float u_colormap0Scale = 1;
uniform float u_colormap0Alpha;
//!< The threshold value for this colormap. Is in [Min,Scale+Min]
uniform float u_colormap0Threshold;
uniform float u_colormap0ThresholdLower;
//!< The threshold value for this colormap. Is in [Min,Scale+Min]
uniform float u_colormap0ThresholdUpper;
//!< Flag denoting whether to use the threshold value for clipping or not.
uniform bool u_colormap0ThresholdEnabled = false;
......@@ -83,7 +86,10 @@ uniform float u_colormap1Scale = 1;
uniform float u_colormap1Alpha;
//!< The threshold value for this colormap. Is in [Min,Scale+Min]
uniform float u_colormap1Threshold;
uniform float u_colormap1ThresholdLower;
//!< The threshold value for this colormap. Is in [Min,Scale+Min]
uniform float u_colormap1ThresholdUpper;
//!< Flag denoting whether to use the threshold value for clipping or not.
uniform bool u_colormap1ThresholdEnabled = false;
......@@ -122,7 +128,10 @@ uniform float u_colormap2Scale = 1;
uniform float u_colormap2Alpha;
//!< The threshold value for this colormap. Is in [Min,Scale+Min]
uniform float u_colormap2Threshold;
uniform float u_colormap2ThresholdLower;
//!< The threshold value for this colormap. Is in [Min,Scale+Min]
uniform float u_colormap2ThresholdUpper;
//!< Flag denoting whether to use the threshold value for clipping or not.
uniform bool u_colormap2ThresholdEnabled = false;
......@@ -161,7 +170,10 @@ uniform float u_colormap3Scale = 1;
uniform float u_colormap3Alpha;
//!< The threshold value for this colormap. Is in [Min,Scale+Min]
uniform float u_colormap3Threshold;
uniform float u_colormap3ThresholdLower;
//!< The threshold value for this colormap. Is in [Min,Scale+Min]
uniform float u_colormap3ThresholdUpper;
//!< Flag denoting whether to use the threshold value for clipping or not.
uniform bool u_colormap3ThresholdEnabled = false;
......@@ -200,7 +212,10 @@ uniform float u_colormap4Scale = 1;
uniform float u_colormap4Alpha;
//!< The threshold value for this colormap. Is in [Min,Scale+Min]
uniform float u_colormap4Threshold;
uniform float u_colormap4ThresholdLower;
//!< The threshold value for this colormap. Is in [Min,Scale+Min]
uniform float u_colormap4ThresholdUpper;
//!< Flag denoting whether to use the threshold value for clipping or not.
uniform bool u_colormap4ThresholdEnabled = false;
......@@ -239,7 +254,10 @@ uniform float u_colormap5Scale = 1;
uniform float u_colormap5Alpha;
//!< The threshold value for this colormap. Is in [Min,Scale+Min]
uniform float u_colormap5Threshold;
uniform float u_colormap5ThresholdLower;
//!< The threshold value for this colormap. Is in [Min,Scale+Min]
uniform float u_colormap5ThresholdUpper;
//!< Flag denoting whether to use the threshold value for clipping or not.
uniform bool u_colormap5ThresholdEnabled = false;
......@@ -278,7 +296,10 @@ uniform float u_colormap6Scale = 1;
uniform float u_colormap6Alpha;
//!< The threshold value for this colormap. Is in [Min,Scale+Min]
uniform float u_colormap6Threshold;
uniform float u_colormap6ThresholdLower;
//!< The threshold value for this colormap. Is in [Min,Scale+Min]
uniform float u_colormap6ThresholdUpper;
//!< Flag denoting whether to use the threshold value for clipping or not.
uniform bool u_colormap6ThresholdEnabled = false;
......@@ -317,7 +338,10 @@ uniform float u_colormap7Scale = 1;
uniform float u_colormap7Alpha;
//!< The threshold value for this colormap. Is in [Min,Scale+Min]
uniform float u_colormap7Threshold;
uniform float u_colormap7ThresholdLower;
//!< The threshold value for this colormap. Is in [Min,Scale+Min]
uniform float u_colormap7ThresholdUpper;
//!< Flag denoting whether to use the threshold value for clipping or not.
uniform bool u_colormap7ThresholdEnabled = false;
......
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