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

Commit 3a8cf4a7 authored by schultezub's avatar schultezub

further work on AdvancedUsFusion: added further color spaces - conversion...

further work on AdvancedUsFusion: added further color spaces - conversion functions still have bug though!

git-svn-id: https://camplinux.in.tum.de/svn/campvis/trunk@466 bb408c1c-ae56-11e1-83d9-df6b3e0c105e
parent 6ade6e78
......@@ -47,8 +47,8 @@ using namespace campvis;
**/
int main(int argc, char** argv) {
CampVisApplication app(argc, argv);
//app.addVisualizationPipeline("Advanced Ultrasound Visualization", new AdvancedUsVis());
app.addVisualizationPipeline("IXPV", new IxpvDemo());
app.addVisualizationPipeline("Advanced Ultrasound Visualization", new AdvancedUsVis());
//app.addVisualizationPipeline("IXPV", new IxpvDemo());
//app.addVisualizationPipeline("SliceVis", new SliceVis());
//app.addVisualizationPipeline("DVRVis", new DVRVis());
#ifdef HAS_KISSCL
......
......@@ -31,6 +31,10 @@
// Should sum to unity.
const vec3 HCYwts_ = vec3(0.299, 0.587, 0.114);
float HCLgamma_ = 3.0;
float HCLy0_ = 100;
float HCLmaxL_ = 0.530454533953517;
/**
* Converts pure Hue to RGB
* Using the efficient implementation from http://www.chilliant.com/rgb2hsv.html.
......@@ -103,6 +107,48 @@ vec3 hcy2rgb(in vec3 HCY) {
return (RGB - vec3(Z, Z, Z)) * HCY.y + HCY.z;
}
vec3 hcl2rgb(in vec3 HCL)
{
vec3 RGB = vec3(0.0, 0.0, 0.0);
if (HCL.z != 0.0) {
float H = HCL.x;
float C = HCL.y;
float L = HCL.z * HCLmaxL_;
float Q = exp((1.0 - C / (2.0 * L)) * (HCLgamma_ / HCLy0_));
float U = (2.0 * L - C) / (2.0 * Q - 1.0);
float V = C / Q;
float T = tan((H + min(fract(2.0 * H) / 4.0, fract(-2.0 * H) / 8.0)) * 6.283185307);
H *= 6.0;
if (H <= 1.0) {
RGB.r = 1.0;
RGB.g = T / (1.0 + T);
}
else if (H <= 2.0) {
RGB.r = (1.0 + T) / T;
RGB.g = 1.0;
}
else if (H <= 3.0) {
RGB.g = 1.0;
RGB.b = 1.0 + T;
}
else if (H <= 4.0) {
RGB.g = 1.0 / (1.0 + T);
RGB.b = 1.0;
}
else if (H <= 5.0) {
RGB.r = -1.0 / T;
RGB.b = 1.0;
}
else {
RGB.r = 1.0;
RGB.b = -T;
}
return RGB * V + U;
}
return RGB;
}
/**
* Converts a color from RGB space to HSV space.
* Using the efficient implementation from http://www.chilliant.com/rgb2hsv.html.
......@@ -167,6 +213,26 @@ vec3 rgb2hcy(in vec3 RGB) {
return HCY;
}
vec3 rgb2hcl(in vec3 RGB) {
vec3 HCL = vec3(0.0, 0.0, 0.0);
float H = 0.0;
float U, V;
U = -min(RGB.r, min(RGB.g, RGB.b));
V = max(RGB.r, max(RGB.g, RGB.b));
float Q = HCLgamma_ / HCLy0_;
HCL.y = V + U;
if (HCL.y != 0.0)
{
H = atan(RGB.g - RGB.b, RGB.r - RGB.g) / 3.14159265;
Q *= -U / V;
}
Q = exp(Q);
HCL.x = fract(H / 2.0 - min(fract(H), fract(-H)) / 6.0);
HCL.y *= Q;
HCL.z = mix(U, V, Q) / (HCLmaxL_ * 2.0);
return HCL;
}
/**
* Converts a color from RGB space to CIEXYZ space.
* \see http://wiki.labomedia.org/images/1/10/Orange_Book_-_OpenGL_Shading_Language_2nd_Edition.pdf
......@@ -194,3 +260,90 @@ vec3 ciexyz2rgb(in vec3 colorCIEXYZ) {
-0.498535, 0.041556, 1.057311);
return colorCIEXYZ * conversionMatrix;
}
vec3 rgb2tsl(in vec3 RGB) {
const float twoPiRCP_ = 0.15915494309;
const float oneThird = 1.0 / 3.0;
vec3 TSL = vec3(0.0, 0.0, 0.0);
float sum = RGB.r + RGB.g + RGB.b;
float rs = (RGB.r / sum) - oneThird;
float gs = (RGB.g / sum) - oneThird;
if (gs > 0)
TSL.x = twoPiRCP_ * atan(rs/gs + 0.25);
else if (gs < 0)
TSL.x = twoPiRCP_ * atan(rs/gs + 0.75);
TSL.y = sqrt(9.0 * (rs*rs + gs*gs) / 5.0);
TSL.z = dot(RGB, HCYwts_);
return TSL;
};
vec3 tsl2rgb(in vec3 TSL) {
vec3 RGB = vec3(0.0, 0.0, 0.0);
float x = -1.0 / tan(TSL.x * 6.283185307);
if (TSL.x == 0.0)
RGB.g = 0.0;
else if (TSL.x > 0.5)
RGB.g = TSL.y * -sqrt(5.0/(9.0 * (x*x + 1.0)));
else if (TSL.x < 0.5)
RGB.g = TSL.y * sqrt(5.0/(9.0 * (x*x + 1.0)));
if (TSL.x == 0)
RGB.r = TSL.y * sqrt(5.0)/3.0;
else
RGB.r = x * RGB.g + (1.0/3.0);
RGB.b = 1.0 - RGB.r - RGB.g;
float k = 1.0 / (0.185*RGB.r + 0.473*RGB.b + 0.114);
return k * RGB;
}
// ================================================================================================
float lab_helper_F(in float p) {
if (p<0.008856)
return p*(841.0/108.0) + (4.0/29.0);
return pow(p,1.0/3.0);
}
vec3 xyz2lab(in vec3 XYZ) {
float fX = XYZ.x/0.950456;
float fY = XYZ.y/1.0;
float fZ = XYZ.z/1.088754;
fX = lab_helper_F(fX);
fY = lab_helper_F(fY);
fZ = lab_helper_F(fZ);
return vec3(116.0 * fY - 16.0,
500.0 * (fX - fY),
200.0 * (fY - fZ));
}
float lab_helper_invF(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 lab2xyz(in vec3 LAB) {
float Y = (LAB.x + 16.0)/116.0;
float X = Y + LAB.y/500.0;
float Z = Y - LAB.z/200.0;
X = 0.950456 * lab_helper_invF(X);
Y = 1.0 * lab_helper_invF(Y);
Z = 1.088754 * lab_helper_invF(Z);
return vec3(X, Y, Z);
}
vec3 rgb2lab(in vec3 RGB) {
return xyz2lab(rgb2ciexyz(RGB));
}
vec3 lab2rgb(in vec3 LAB) {
return ciexyz2rgb(lab2xyz(LAB));
}
\ No newline at end of file
......@@ -84,13 +84,34 @@ void main() {
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.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.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.y = 1.0 - confidence;
out_Color.xyz = hcy2rgb(hcy);
break;
case 6:
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;
......
......@@ -62,7 +62,7 @@ namespace campvis {
{
addProcessor(&_usReader);
addProcessor(&_confidenceReader);
addProcessor(&_confidenceGenerator);
//addProcessor(&_confidenceGenerator);
addProcessor(&_gvg);
//addProcessor(&_lhh);
addProcessor(&_usBlurFilter);
......@@ -71,10 +71,10 @@ namespace campvis {
addProcessor(&_usFusion3);
addProcessor(&_usFusion4);
addProcessor(&_quadView);
addProcessor(&_usDenoiseilter);
addProcessor(&_usProxy);
addProcessor(&_usEEP);
addProcessor(&_usDVR);
//addProcessor(&_usDenoiseilter);
//addProcessor(&_usProxy);
//addProcessor(&_usEEP);
//addProcessor(&_usDVR);
addEventHandler(&_wheelHandler);
//addEventHandler(&_tfWindowingHandler);
......@@ -95,8 +95,8 @@ namespace campvis {
_camera.addSharedProperty(&_usEEP.p_camera);
_camera.addSharedProperty(&_usDVR.p_camera);
//_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\\Athanasios\\US.csvd");
_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\\Athanasios\\US.csvd");
//_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);
......@@ -109,8 +109,8 @@ 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\\01\\Confidence_01.mhd");
_confidenceReader.p_url.setValue("D:\\Medical Data\\US Confidence Vis\\UltrasoundBoneData\\SynthesEvaluationUnterschenkel\\Athanasios\\Map.csvd");
_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\\Athanasios\\Map.csvd");
//_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);
......@@ -144,7 +144,7 @@ namespace campvis {
_usFusion3.p_targetImageID.setValue("us.fused3");
_usFusion3.p_targetImageID.connect(&_quadView.p_inputImage3);
_usFusion3.p_view.selectById("mappingChromacity");
_usFusion3.p_view.selectById("mappingChromacityHCY");
_usFusion4.p_targetImageID.setValue("us.fused4");
_usFusion4.p_targetImageID.connect(&_quadView.p_inputImage4);
......
......@@ -89,8 +89,8 @@ namespace campvis {
CameraProperty _camera;
CsvdImageReader _usReader;
CsvdImageReader _confidenceReader;
MhdImageReader _usReader;
MhdImageReader _confidenceReader;
ConfidenceMapGenerator _confidenceGenerator;
GradientVolumeGenerator _gvg;
......
......@@ -44,13 +44,16 @@
namespace campvis {
const std::string AdvancedUsFusion::loggerCat_ = "CAMPVis.modules.vis.AdvancedUsFusion";
GenericOption<std::string> viewOptions[7] = {
GenericOption<std::string> viewOptions[10] = {
GenericOption<std::string>("us", "Ultrasound Only"),
GenericOption<std::string>("smoothed", "Smoothed US Only"),
GenericOption<std::string>("sharpened", "Sharpened US Only"),
GenericOption<std::string>("mappingSaturationHSV", "Mapping Uncertainty to Saturation (HSV)"),
GenericOption<std::string>("mappingSaturationHSL", "Mapping Uncertainty to Saturation (HSL)"),
GenericOption<std::string>("mappingChromacity", "Mapping Uncertainty to Chromacity"),
GenericOption<std::string>("mappingSaturationTSL", "Mapping Uncertainty to Saturation (TSL)"),
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")
};
......@@ -63,7 +66,7 @@ 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, 7)
, p_view("View", "Image to Render", viewOptions, 10)
, p_blurredScaling("BlurredScaling", "Scaling for blurred image intensity", 1.f, .001f, 1000.f)
, _shader(0)
{
......
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