Commit 1779f044 authored by schultezub's avatar schultezub

various work on AdvancedUsVis module

git-svn-id: https://camplinux.in.tum.de/svn/campvis/trunk@488 bb408c1c-ae56-11e1-83d9-df6b3e0c105e
parent 69aa6793
......@@ -20,7 +20,8 @@ namespace tgt {
QtThreadedCanvas* QtContextManager::createContext(const std::string& key, const std::string& title /*= ""*/, const ivec2& size /*= ivec2(DEFAULT_WINDOW_WIDTH, DEFAULT_WINDOW_HEIGHT)*/, const GLCanvas::Buffers buffers /*= RGBADD*/, QWidget* parent /*= 0*/, bool shared /*= true*/, Qt::WFlags f /*= 0*/, char* name /*= 0*/)
{
tgtAssert(_contexts.find(key) == _contexts.end(), "A context with the same key already exists!");
// FIXME: rethink this concept of unique IDs
//tgtAssert(_contexts.find(key) == _contexts.end(), "A context with the same key already exists!");
tbb::mutex::scoped_lock lock(_glMutex);
QtThreadedCanvas* toReturn = new QtThreadedCanvas(title, size, buffers, parent, shared, f, name);
......
......@@ -59,11 +59,14 @@ uniform TEXPARAMS_TYPE _confidenceTextureParams;
uniform sampler1D _transferFunction;
uniform TFParameters1D _transferFunctionParams;
uniform sampler1D _confidenceTF;
uniform TFParameters1D _confidenceTFParams;
uniform int _sliceNumber;
uniform int _viewIndex;
uniform float _confidenceScaling;
uniform float _hue;
uniform float _blurredScale;
void main() {
#ifdef USE_3D_TEX
......@@ -73,8 +76,9 @@ void main() {
#endif
vec4 texel = TEXTURE_LOOKUP_FUNC(_usImage, _usTextureParams, texCoord);
vec4 blurred = TEXTURE_LOOKUP_FUNC(_blurredImage, _blurredTextureParams, texCoord);
vec4 blurred = TEXTURE_LOOKUP_FUNC(_blurredImage, _blurredTextureParams, texCoord) * _blurredScale;
float confidence = clamp(TEXTURE_LOOKUP_FUNC(_confidenceMap, _confidenceTextureParams, texCoord).a * _confidenceScaling, 0.0, 1.0);
float uncertainty = lookupTF(_confidenceTF, _confidenceTFParams, confidence).a;
if (confidence <= 0.0) {
out_Color = lookupTF(_transferFunction, _transferFunctionParams, texel.a);
......@@ -88,63 +92,63 @@ void main() {
out_Color = lookupTF(_transferFunction, _transferFunctionParams, blurred.a);
break;
case 2:
out_Color = lookupTF(_transferFunction, _transferFunctionParams, texel.a + texel.a - blurred.a);
out_Color = lookupTF(_transferFunction, _transferFunctionParams, confidence);
break;
case 3:
out_Color = lookupTF(_transferFunction, _transferFunctionParams, texel.a);
vec3 hsv = rgb2hsv(out_Color.xyz);
hsv.x = _hue;
hsv.y = 1.0 - confidence;
hsv.y = uncertainty;
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;
hsl.y = uncertainty;
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;
//tsl.y = uncertainty;
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;
hcl.y = uncertainty;
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;
hcy.y = uncertainty;
out_Color.xyz = hcy2rgb(hcy);
break;
case 8:
out_Color = lookupTF(_transferFunction, _transferFunctionParams, texel.a);
vec3 lch = rgb2lch(out_Color.xyz);
lch.z = 6.2831853 * _hue;
lch.y = 100.0 * (1.0 - confidence);
lch.y = 100.0 * (uncertainty);
out_Color.xyz = lch2rgb(lch);
break;
case 9:
out_Color = lookupTF(_transferFunction, _transferFunctionParams, texel.a);
vec3 hlch = lab2lch(xyz2hlab(rgb2xyz(out_Color.xyz)));
//hlch.z = 6.2831853 * _hue;
//hlch.y = 100.0 * (1.0 - confidence);
//hlch.y = 100.0 * (uncertainty);
out_Color.xyz = xyz2rgb(hlab2xyz(lch2lab(hlch)));
break;
case 10:
float intensity = mix(blurred.a, (2.0 * texel.a - blurred.a), confidence);
float intensity = mix((2.0 * texel.a - blurred.a), blurred.a, uncertainty);
out_Color = lookupTF(_transferFunction, _transferFunctionParams, intensity);
break;
case 11:
float lod = max(floor((1.0 - confidence) * 6.0), 0.0);
float lod = max(floor((uncertainty) * 6.0), 0.0);
vec4 lodTexel = texture(_usImage, texCoord, lod);
out_Color = lookupTF(_transferFunction, _transferFunctionParams, lodTexel.a);
......
......@@ -30,6 +30,7 @@
#include "cmbatchgeneration.h"
#include "tgt/event/keyevent.h"
#include "tgt/filesystem.h"
#include "core/classification/geometry1dtransferfunction.h"
#include "core/classification/tfgeometry1d.h"
......@@ -54,8 +55,10 @@ namespace campvis {
, _confidenceGenerator()
, _usBlurFilter()
, _usFusion(_effectiveRenderTargetSize)
, p_autoExecution("AutoExecution", "Automatic Execution", false)
, p_sourcePath("SourcePath", "Source Files Path", "")
, p_targetPath("TargetPath", "Target Files Path", "")
, p_targetPathColor("TargetPathColor", "Target Path Color Files", "")
, p_targetPathFuzzy("TargetPathFuzzy", "Target Path Fuzzy Files", "")
, p_range("Range", "Files Range", tgt::ivec2(0, 1), tgt::ivec2(0, 0), tgt::ivec2(10000, 10000))
, p_execute("Execute", "Execute Batch Pipeline")
{
......@@ -64,8 +67,10 @@ namespace campvis {
addProcessor(&_usFusion);
addProcessor(&_usBlurFilter);
addProperty(&p_autoExecution);
addProperty(&p_sourcePath);
addProperty(&p_targetPath);
addProperty(&p_targetPathColor);
addProperty(&p_targetPathFuzzy);
addProperty(&p_range);
addProperty(&p_execute);
}
......@@ -76,12 +81,13 @@ namespace campvis {
void CmBatchGeneration::init() {
VisualizationPipeline::init();
p_sourcePath.setValue("D:\\Medical Data\\US Confidence Vis\\transcranial\\bl01");
p_targetPath.setValue("D:\\Medical Data\\US Confidence Vis\\transcranial\\bl01cm");
p_sourcePath.setValue("D:\\Medical Data\\US Confidence Vis\\Pasing 13-02-26\\04-02-22-212506_Perez11_20040222_212506_20040222_220332\\gallenblase");
p_targetPathColor.setValue("D:\\Medical Data\\US Confidence Vis\\Pasing 13-02-26\\04-02-22-212506_Perez11_20040222_212506_20040222_220332\\gallenblase\\color");
p_targetPathFuzzy.setValue("D:\\Medical Data\\US Confidence Vis\\Pasing 13-02-26\\04-02-22-212506_Perez11_20040222_212506_20040222_220332\\gallenblase\\fuzzy");
p_range.setValue(tgt::ivec2(0, 1));
p_execute.s_clicked.connect(this, &CmBatchGeneration::execute);
_usReader.p_url.setValue("D:\\Medical Data\\US Confidence Vis\\transcranial\\us.png");
_usReader.p_url.setValue("D:\\Medical Data\\US Confidence Vis\\Pasing 13-02-26\\04-02-22-212506_Perez11_20040222_212506_20040222_220332\\11_niere_re_durch_leber2\\original\\export0000.bmp");
_usReader.p_targetImageID.setValue("us.image");
_usReader.p_importType.selectById("localIntensity");
_usReader.p_targetImageID.connect(&_confidenceGenerator.p_sourceImageID);
......@@ -91,11 +97,12 @@ namespace campvis {
_confidenceGenerator.p_targetImageID.setValue("confidence.image.generated");
_confidenceGenerator.p_targetImageID.connect(&_usFusion.p_confidenceImageID);
_confidenceGenerator.p_curvilinear.setValue(true);
_confidenceGenerator.p_origin.setValue(tgt::vec2(320.f, 444.f));
_confidenceGenerator.p_angles.setValue(tgt::vec2(225.f / 180.f * tgt::PIf, 315.f / 180.f * tgt::PIf));
_confidenceGenerator.p_origin.setValue(tgt::vec2(340.f, 540.f));
_confidenceGenerator.p_angles.setValue(tgt::vec2(4.064f, 5.363f));
//_confidenceGenerator.p_angles.setValue(tgt::vec2(232.f / 180.f * tgt::PIf, 307.f / 180.f * tgt::PIf));
//_confidenceGenerator.p_origin.setValue(tgt::vec2(320.f, 35.f));
//_confidenceGenerator.p_angles.setValue(tgt::vec2(45.f / 180.f * tgt::PIf, 135.f / 180.f * tgt::PIf));
_confidenceGenerator.p_lengths.setValue(tgt::vec2(0.f, 410.f));
_confidenceGenerator.p_lengths.setValue(tgt::vec2(116.f, 543.f));
_usFusion.p_targetImageID.setValue("us.fused");
_usFusion.p_view.selectById("mappingSharpness");
......@@ -123,6 +130,7 @@ namespace campvis {
if (p_range.getValue().x > p_range.getValue().y)
return;
p_autoExecution.setValue(false);
for (int i = p_range.getValue().x; i < p_range.getValue().y; ++i) {
GLJobProc.enqueueJob(_canvas, makeJobOnHeap(this, &CmBatchGeneration::executePass, i), OpenGLJobProcessor::SerialJob);
}
......@@ -133,14 +141,15 @@ namespace campvis {
}
void CmBatchGeneration::onProcessorInvalidated(AbstractProcessor* processor) {
// do nothing here - we do our own evaluation
if (p_autoExecution.getValue())
VisualizationPipeline::onProcessorInvalidated(processor);
}
void CmBatchGeneration::executePass(int path) {
std::stringstream ss;
// set up processors:
ss << p_sourcePath.getValue() << "\\" << "export" << std::setfill('0') << std::setw(4) << path << ".tga";
ss << p_sourcePath.getValue() << "\\" << "export" << std::setfill('0') << std::setw(4) << path << ".bmp";
_usReader.p_url.setValue(ss.str());
executeProcessor(&_usReader);
......@@ -154,14 +163,27 @@ namespace campvis {
executeProcessor(&_confidenceGenerator);
executeProcessor(&_usBlurFilter);
_usFusion.p_view.selectById("mappingLAB");
executeProcessor(&_usFusion);
save(path, p_targetPathColor.getValue());
// _usFusion.p_view.selectById("mappingSharpness");
// executeProcessor(&_usFusion);
// save(path, p_targetPathFuzzy.getValue());
}
void CmBatchGeneration::save(int path, const std::string& basePath) {
// get result
ImageRepresentationRenderTarget::ScopedRepresentation repRT(_data, _usFusion.p_targetImageID.getValue());
if (repRT != 0) {
#ifdef CAMPVIS_HAS_MODULE_DEVIL
if (! tgt::FileSystem::dirExists(basePath))
tgt::FileSystem::createDirectory(basePath);
std::stringstream sss;
sss << p_targetPath.getValue() << "\\" << "export" << std::setfill('0') << std::setw(4) << path << ".png";
sss << basePath << "\\" << "export" << std::setfill('0') << std::setw(4) << path << ".bmp";
std::string filename = sss.str();
if (tgt::FileSystem::fileExtension(filename).empty()) {
LERROR("Filename has no extension");
......@@ -193,7 +215,6 @@ namespace campvis {
return;
#endif
}
}
}
\ No newline at end of file
......@@ -84,13 +84,18 @@ namespace campvis {
void executePass(int path);
void save(int path, const std::string& basePath);
DevilImageReader _usReader;
ConfidenceMapGenerator _confidenceGenerator;
ItkImageFilter _usBlurFilter;
AdvancedUsFusion _usFusion;
BoolProperty p_autoExecution;
StringProperty p_sourcePath;
StringProperty p_targetPath;
StringProperty p_targetPathColor;
StringProperty p_targetPathFuzzy;
IVec2Property p_range;
ButtonProperty p_execute;
......
......@@ -38,6 +38,8 @@
#include "core/pipeline/processordecoratorbackground.h"
#include "core/classification/simpletransferfunction.h"
#include "core/classification/geometry1dtransferfunction.h"
#include "core/classification/tfgeometry1d.h"
#include "core/tools/quadrenderer.h"
......@@ -47,7 +49,7 @@ namespace campvis {
GenericOption<std::string> viewOptions[12] = {
GenericOption<std::string>("us", "Ultrasound Only"),
GenericOption<std::string>("smoothed", "Smoothed US Only"),
GenericOption<std::string>("sharpened", "Sharpened US Only"),
GenericOption<std::string>("cm", "Confidence Map US Only"),
GenericOption<std::string>("mappingSaturationHSV", "Mapping Uncertainty to Saturation (HSV)"),
GenericOption<std::string>("mappingSaturationHSL", "Mapping Uncertainty to Saturation (HSL)"),
GenericOption<std::string>("mappingSaturationTSL", "Mapping Uncertainty to Saturation (TSL)"),
......@@ -68,8 +70,10 @@ 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_confidenceTF("ConfidenceTF", "Confidence to Uncertainty TF", new Geometry1DTransferFunction(256))
, p_view("View", "Image to Render", viewOptions, 12)
, p_confidenceScaling("ConfidenceScaling", "Confidence Scaling", 1.f, .001f, 1000.f)
, p_blurredScaling("BlurredScaling", "Blurred 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)
......@@ -78,13 +82,18 @@ namespace campvis {
addProperty(&p_blurredImageId);
addProperty(&p_gradientImageID);
addProperty(&p_confidenceImageID);
addProperty(&p_blurredScaling);
addProperty(&p_targetImageID);
addProperty(&p_sliceNumber);
addProperty(&p_transferFunction);
addProperty(&p_confidenceTF);
addProperty(&p_view);
addProperty(&p_confidenceScaling);
addProperty(&p_hue);
Geometry1DTransferFunction* tf = static_cast<Geometry1DTransferFunction*>(p_confidenceTF.getTF());
tf->addGeometry(TFGeometry1D::createQuad(tgt::vec2(0.f, 1.f), tgt::col4(0, 0, 0, 96), tgt::col4(0, 0, 0, 0)));
decoratePropertyCollection(this);
}
......@@ -115,11 +124,12 @@ namespace campvis {
// source DataHandle has changed
updateProperties(img.getDataHandle());
_sourceImageTimestamp = img.getDataHandle().getTimestamp();
_shader->setHeaders(generateHeader());
_shader->rebuild();
//p_confidenceTF.getTF()->setImageHandle(confidence.getDataHandle());
//_shader->setHeaders(generateHeader());
//_shader->rebuild();
}
std::pair<ImageData*, ImageRepresentationRenderTarget*> rt = ImageRepresentationRenderTarget::createWithImageData(_renderTargetSize.getValue(), GL_RGBA32F);
std::pair<ImageData*, ImageRepresentationRenderTarget*> rt = ImageRepresentationRenderTarget::createWithImageData(_renderTargetSize.getValue());
_shader->activate();
decorateRenderProlog(data, _shader);
......@@ -128,12 +138,14 @@ namespace campvis {
_shader->setUniform("_viewIndex", p_view.getValue());
_shader->setUniform("_confidenceScaling", p_confidenceScaling.getValue());
_shader->setUniform("_hue", p_hue.getValue());
_shader->setUniform("_blurredScale", 1.f / p_blurredScaling.getValue());
tgt::TextureUnit usUnit, blurredUnit, confidenceUnit, tfUnit;
tgt::TextureUnit usUnit, blurredUnit, confidenceUnit, tfUnit, tf2Unit;
img->bind(_shader, usUnit, "_usImage", "_usTextureParams");
blurred->bind(_shader, blurredUnit, "_blurredImage", "_blurredTextureParams");
confidence->bind(_shader, confidenceUnit, "_confidenceMap", "_confidenceTextureParams");
p_transferFunction.getTF()->bind(_shader, tfUnit);
p_confidenceTF.getTF()->bind(_shader, tf2Unit, "_confidenceTF", "_confidenceTFParams");
rt.second->activate();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
......
......@@ -84,7 +84,9 @@ namespace campvis {
IntProperty p_sliceNumber; ///< number of the slice to extract
TransferFunctionProperty p_transferFunction; ///< Transfer function
TransferFunctionProperty p_confidenceTF; ///< Transfer function confidence to uncertainty
GenericOptionProperty<std::string> p_view;
FloatProperty p_blurredScaling;
FloatProperty p_confidenceScaling;
FloatProperty p_hue;
BoolProperty p_use3DTexture;
......
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