Commit c6e9b3ac authored by schultezub's avatar schultezub
Browse files

Further work on Advanced US Fusion module

git-svn-id: https://camplinux.in.tum.de/svn/campvis/trunk@425 bb408c1c-ae56-11e1-83d9-df6b3e0c105e
parent a89b5e15
......@@ -63,7 +63,6 @@ namespace campvis {
_comboBox->setCurrentIndex(prop->getValue());
_comboBox->blockSignals(false);
_comboBox->blockSignals(false);
}
void OptionPropertyWidget::onComboBoxIndexChanged(int value) {
......
......@@ -37,22 +37,42 @@ out vec4 out_Color;
#include "tools/transferfunction.frag"
uniform Texture3D _usImage;
uniform Texture3D _blurredImage;
uniform Texture3D _confidenceMap;
uniform Texture3D _gradientMap;
uniform TransferFunction1D _transferFunction;
uniform int _sliceNumber;
uniform int _viewIndex;
uniform float _blurredScaling;
void main() {
vec3 texCoord = vec3(ex_TexCoord.xy, _usImage._sizeRCP.z * (_sliceNumber + 0.5));
vec4 texel = getElement3DNormalized(_usImage, texCoord);
vec4 blurred = getElement3DNormalized(_blurredImage, texCoord) * _blurredScaling;
vec4 gradient = getElement3DNormalized(_gradientMap, texCoord);
float confidence = getElement3DNormalized(_confidenceMap, texCoord).a;
out_Color = lookupTF(_transferFunction, texel.a);
vec3 hsv = rgb2hsv(out_Color.xyz);
hsv.y = 1.0 - confidence;
out_Color.xyz = hsv2rgb(hsv);
switch (_viewIndex) {
case 0:
out_Color = lookupTF(_transferFunction, texel.a);
break;
case 1:
out_Color = lookupTF(_transferFunction, blurred.a);
break;
case 2:
out_Color = lookupTF(_transferFunction, texel.a + texel.a - blurred.a);
break;
case 3:
out_Color = lookupTF(_transferFunction, texel.a);
vec3 hsv = rgb2hsv(out_Color.xyz);
hsv.y = 1.0 - confidence;
out_Color.xyz = hsv2rgb(hsv);
break;
case 4:
float intensity = mix(blurred.a, 2.0 * texel.a - blurred.a, confidence);
out_Color = lookupTF(_transferFunction, intensity);
break;
}
}
......@@ -79,9 +79,12 @@ namespace campvis {
_usFusion.p_targetImageID.setValue("us.fused");
_usFusion.p_sliceNumber.setValue(0);
_usFusion.p_view.setValue(0);
_usFilter.p_targetImageID.setValue("us.filtered");
_usFilter.p_targetImageID.connect(&_usFusion.p_blurredImageId);
_usFilter.p_filterMode.selectById("gauss");
_usFilter.p_sigma.setValue(4.f);
// TODO: replace this hardcoded domain by automatically determined from image min/max values
Geometry1DTransferFunction* tf = new Geometry1DTransferFunction(128, tgt::vec2(0.f, 1.f));
......
......@@ -44,22 +44,36 @@
namespace campvis {
const std::string AdvancedUsFusion::loggerCat_ = "CAMPVis.modules.vis.AdvancedUsFusion";
GenericOption<std::string> viewOptions[5] = {
GenericOption<std::string>("us", "Ultrasound Only"),
GenericOption<std::string>("smoothed", "Smoothed US Only"),
GenericOption<std::string>("sharpened", "Sharpened US Only"),
GenericOption<std::string>("mappingSaturation", "Mapping Uncertainty to Saturation"),
GenericOption<std::string>("mappingSharpness", "Mapping Uncertainty to Sharpness")
};
AdvancedUsFusion::AdvancedUsFusion(GenericProperty<tgt::ivec2>& canvasSize)
: VisualizationProcessor(canvasSize)
, p_usImageId("UsImageId", "Ultrasound Input Image", "", DataNameProperty::READ)
, p_blurredImageId("BlurredImageId", "Blurred Ultrasound Image", "", DataNameProperty::READ)
, p_gradientImageID("GradientImageId", "Gradient Input Image", "", DataNameProperty::READ)
, p_confidenceImageID("ConfidenceImageId", "Confidence Map Input", "", DataNameProperty::READ)
, 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, 5)
, p_blurredScaling("BlurredScaling", "Scaling for blurred image intensity", 1.f, .001f, 1000.f)
, _shader(0)
{
addProperty(&p_usImageId);
addProperty(&p_blurredImageId);
addProperty(&p_gradientImageID);
addProperty(&p_confidenceImageID);
addProperty(&p_targetImageID);
addProperty(&p_sliceNumber);
addProperty(&p_transferFunction);
addProperty(&p_view);
addProperty(&p_blurredScaling);
decoratePropertyCollection(this);
}
......@@ -82,10 +96,11 @@ namespace campvis {
void AdvancedUsFusion::process(DataContainer& data) {
ImageRepresentationGL::ScopedRepresentation img(data, p_usImageId.getValue());
ImageRepresentationGL::ScopedRepresentation blurred(data, p_blurredImageId.getValue());
ImageRepresentationGL::ScopedRepresentation confidence(data, p_confidenceImageID.getValue());
ImageRepresentationGL::ScopedRepresentation gradients(data, p_gradientImageID.getValue());
if (img != 0 && gradients != 0 && confidence != 0) {
if (img != 0 && blurred != 0 && gradients != 0 && confidence != 0) {
if (img->getDimensionality() == 3) {
if (img.getDataHandle().getTimestamp() != _sourceImageTimestamp) {
// source DataHandle has changed
......@@ -98,9 +113,12 @@ namespace campvis {
_shader->activate();
decorateRenderProlog(data, _shader);
_shader->setUniform("_sliceNumber", p_sliceNumber.getValue());
_shader->setUniform("_viewIndex", p_view.getValue());
_shader->setUniform("_blurredScaling", p_blurredScaling.getValue());
tgt::TextureUnit usUnit, confidenceUnit, gradientUnit, tfUnit;
tgt::TextureUnit usUnit, blurredUnit, confidenceUnit, gradientUnit, tfUnit;
img->bind(_shader, usUnit, "_usImage");
blurred->bind(_shader, blurredUnit, "_blurredImage");
confidence->bind(_shader, confidenceUnit, "_confidenceMap");
gradients->bind(_shader, gradientUnit, "_gradientMap");
p_transferFunction.getTF()->bind(_shader, tfUnit);
......
......@@ -37,6 +37,7 @@
#include "core/properties/datanameproperty.h"
#include "core/properties/genericproperty.h"
#include "core/properties/numericproperty.h"
#include "core/properties/optionproperty.h"
#include "core/properties/transferfunctionproperty.h"
namespace tgt {
......@@ -76,12 +77,15 @@ namespace campvis {
virtual void process(DataContainer& data);
DataNameProperty p_usImageId; ///< image ID for input image
DataNameProperty p_blurredImageId;
DataNameProperty p_gradientImageID;
DataNameProperty p_confidenceImageID;
DataNameProperty p_targetImageID; ///< image ID for output image
IntProperty p_sliceNumber; ///< number of the slice to extract
TransferFunctionProperty p_transferFunction; ///< Transfer function
GenericOptionProperty<std::string> p_view;
FloatProperty p_blurredScaling;
protected:
/// adapts the range of the p_sliceNumber property to the image
......
......@@ -38,6 +38,7 @@
#include <itkSobelEdgeDetectionImageFilter.h>
#include <itkGradientAnisotropicDiffusionImageFilter.h>
#include <itkCurvatureAnisotropicDiffusionImageFilter.h>
#include <itkLaplacianSharpeningImageFilter.h>
#include "tbb/include/tbb/tbb.h"
......@@ -179,12 +180,13 @@
namespace campvis {
static const GenericOption<std::string> filterModes[5] = {
static const GenericOption<std::string> filterModes[6] = {
GenericOption<std::string>("median", "Median"),
GenericOption<std::string>("gauss", "Gauss"),
GenericOption<std::string>("sobel", "Sobel"),
GenericOption<std::string>("gradientDiffusion", "Gradient Anisotropic Diffusion"),
GenericOption<std::string>("curvatureDiffusion", "Curvature Anisotropic Diffusion")
GenericOption<std::string>("curvatureDiffusion", "Curvature Anisotropic Diffusion"),
GenericOption<std::string>("laplacianSharpening", "Laplacian Sharpening")
};
const std::string ItkImageFilter::loggerCat_ = "CAMPVis.modules.classification.ItkImageFilter";
......@@ -193,7 +195,7 @@ namespace campvis {
: AbstractProcessor()
, p_sourceImageID("InputVolume", "Input Volume ID", "volume", DataNameProperty::READ)
, p_targetImageID("OutputGradients", "Output Gradient Volume ID", "gradients", DataNameProperty::WRITE)
, p_filterMode("FilterMode", "Filter Mode", filterModes, 5, InvalidationLevel::INVALID_RESULT | InvalidationLevel::INVALID_PROPERTIES)
, p_filterMode("FilterMode", "Filter Mode", filterModes, 6, InvalidationLevel::INVALID_RESULT | InvalidationLevel::INVALID_PROPERTIES)
, p_kernelSize("KernelSize", "Kernel Size", 3, 3, 15)
, p_sigma("Sigma", "Sigma", 1.f, .1f, 10.f)
, p_numberOfSteps("NumberOfSteps", "Number of Steps", 5, 1, 15)
......@@ -251,7 +253,9 @@ namespace campvis {
filter->SetConductanceParameter(p_conductance.getValue()); \
);
}
else if (p_filterMode.getOptionValue() == "laplacianSharpening") {
DISPATCH_ITK_FILTER(input, LaplacianSharpeningImageFilter, /* nothing here */);
}
data.addData(p_targetImageID.getValue(), id);
p_targetImageID.issueWrite();
}
......@@ -278,7 +282,7 @@ namespace campvis {
p_timeStep.setVisible(false);
p_conductance.setVisible(false);
}
else if (p_filterMode.getOptionValue() == "sobel") {
else if (p_filterMode.getOptionValue() == "sobel" || p_filterMode.getOptionValue() == "laplacianSharpening") {
p_kernelSize.setVisible(false);
p_sigma.setVisible(false);
p_numberOfSteps.setVisible(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