Further work on cuda-cm module, final pre-merge cleanup.

ConfidenceMapGenerator now supports alpha-beta filtering.
parent 7fde4f5b
......@@ -30,7 +30,7 @@
#include "modules/modulesapi.h"
#include "modules/pipelinefactory.h"
#include "modules/io/processors/mhdimagereader.h"
#include "modules/io/processors/genericimagereader.h"
#include "modules/advancedusvis/processors/advancedusfusion.h"
#include "modules/preprocessing/processors/glgaussianfilter.h"
#include "modules/vis/processors/quadview.h"
......@@ -62,8 +62,8 @@ namespace campvis {
virtual void keyEvent(cgt::KeyEvent* e);
protected:
MhdImageReader _usReader;
MhdImageReader _confidenceReader;
GenericImageReader _usReader;
GenericImageReader _confidenceReader;
AdvancedUsFusion _usFusion1;
AdvancedUsFusion _usFusion2;
......
......@@ -51,6 +51,8 @@ namespace campvis {
, _usFusion(&_canvasSize)
, p_autoExecution("AutoExecution", "Automatic Execution", false)
, p_sourcePath("SourcePath", "Source Files Path", "", StringProperty::DIRECTORY)
, p_targetPathCm("TargetPathCm", "Target Path Confidence Map Files", "", StringProperty::DIRECTORY)
, p_targetPathColorOverlay("TargetPathColorOverlay", "Target Path Color Overlay Files", "", StringProperty::DIRECTORY)
, p_targetPathColor("TargetPathColor", "Target Path Color Files", "", StringProperty::DIRECTORY)
, p_targetPathFuzzy("TargetPathFuzzy", "Target Path Fuzzy Files", "", StringProperty::DIRECTORY)
, p_range("Range", "Files Range", cgt::ivec2(0, 1), cgt::ivec2(0, 0), cgt::ivec2(10000, 10000))
......@@ -63,6 +65,8 @@ namespace campvis {
addProperty(p_autoExecution);
addProperty(p_sourcePath);
addProperty(p_targetPathCm);
addProperty(p_targetPathColorOverlay);
addProperty(p_targetPathColor);
addProperty(p_targetPathFuzzy);
addProperty(p_range);
......@@ -75,13 +79,15 @@ namespace campvis {
void CmBatchGeneration::init() {
AutoEvaluationPipeline::init();
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_sourcePath.setValue("D:\\cm_stuff\\original");
p_targetPathCm.setValue("D:\\cm_stuff\\cm");
p_targetPathColorOverlay.setValue("D:\\cm_stuff\\colorOverlay");
p_targetPathColor.setValue("D:\\cm_stuff\\color");
p_targetPathFuzzy.setValue("D:\\cm_stuff\\fuzzy");
p_range.setValue(cgt::ivec2(0, 1));
p_execute.s_clicked.connect(this, &CmBatchGeneration::execute);
_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_url.setValue("D:\\cm_stuff\\original\\export0000.bmp");
_usReader.p_targetImageID.setValue("us.image");
_usReader.p_importType.selectById("localIntensity");
_usReader.p_targetImageID.addSharedProperty(&_confidenceGenerator.p_sourceImageID);
......@@ -97,6 +103,10 @@ namespace campvis {
//_confidenceGenerator.p_origin.setValue(cgt::vec2(320.f, 35.f));
//_confidenceGenerator.p_angles.setValue(cgt::vec2(45.f / 180.f * cgt::PIf, 135.f / 180.f * cgt::PIf));
_confidenceGenerator.p_lengths.setValue(cgt::vec2(116.f, 543.f));
_confidenceGenerator.p_alpha.setValue(2.f);
_confidenceGenerator.p_beta.setValue(80.f);
_confidenceGenerator.p_gamma.setValue(.05f);
_usFusion.p_targetImageID.setValue("us.fused");
_usFusion.p_view.selectById("mappingSharpness");
......@@ -112,6 +122,8 @@ namespace campvis {
_usFusion.p_transferFunction.replaceTF(tf);
_renderTargetID.setValue("us.fused");
setEnabled(false);
}
void CmBatchGeneration::deinit() {
......@@ -125,6 +137,10 @@ namespace campvis {
p_autoExecution.setValue(false);
cgt::GLContextScopedLock lock(_canvas);
getDataContainer().removeData(_confidenceGenerator.p_targetImageID.getValue());
getDataContainer().removeData(_confidenceGenerator.p_targetImageID.getValue() + "velocities");
for (int i = p_range.getValue().x; i < p_range.getValue().y; ++i) {
executePass(i);
}
......@@ -142,7 +158,7 @@ namespace campvis {
ss << p_sourcePath.getValue() << "\\" << "export" << std::setfill('0') << std::setw(4) << path << ".bmp";
_usReader.p_url.setValue(ss.str());
executeProcessor(&_usReader);
forceExecuteProcessor(&_usReader);
DataHandle dh = _data->getData(_usReader.p_targetImageID.getValue());
if (dh.getData() != 0) {
......@@ -151,16 +167,52 @@ namespace campvis {
}
}
executeProcessor(&_confidenceGenerator);
executeProcessor(&_usBlurFilter);
forceExecuteProcessor(&_confidenceGenerator);
forceExecuteProcessor(&_usBlurFilter);
_usFusion.p_transferFunction.setAutoFitWindowToData(false);
_usFusion.p_transferFunction.getTF()->setIntensityDomain(cgt::vec2(0.f, 1.f));
{
// Confidence Map
Geometry1DTransferFunction* tf = new Geometry1DTransferFunction(256);
tf->addGeometry(TFGeometry1D::createQuad(cgt::vec2(0.0f, 1.0f), cgt::col4(0, 0, 0, 255), cgt::col4(0, 0, 0, 0)));
_usFusion.p_confidenceTF.replaceTF(tf);
_usFusion.p_view.selectById("cm");
forceExecuteProcessor(&_usFusion);
save(path, p_targetPathCm.getValue());
}
_usFusion.p_view.selectById("mappingLAB");
executeProcessor(&_usFusion);
save(path, p_targetPathColor.getValue());
{
// Color Overlay mapping
Geometry1DTransferFunction* tf = new Geometry1DTransferFunction(256);
tf->addGeometry(TFGeometry1D::createQuad(cgt::vec2(0.0f, 0.45f), cgt::col4(0, 0, 0, 224), cgt::col4(0, 0, 0, 0)));
_usFusion.p_confidenceTF.replaceTF(tf);
_usFusion.p_hue.setValue(0.15f);
_usFusion.p_view.selectById("colorOverlay");
forceExecuteProcessor(&_usFusion);
save(path, p_targetPathColorOverlay.getValue());
}
{
// LAB mapping
Geometry1DTransferFunction* tf = new Geometry1DTransferFunction(256);
tf->addGeometry(TFGeometry1D::createQuad(cgt::vec2(0.0f, 0.5f), cgt::col4(0, 0, 0, 224), cgt::col4(0, 0, 0, 0)));
_usFusion.p_confidenceTF.replaceTF(tf);
_usFusion.p_hue.setValue(0.23f);
_usFusion.p_view.selectById("mappingLAB");
forceExecuteProcessor(&_usFusion);
save(path, p_targetPathColor.getValue());
}
// _usFusion.p_view.selectById("mappingSharpness");
// executeProcessor(&_usFusion);
// save(path, p_targetPathFuzzy.getValue());
{
// Fuzziness mapping
Geometry1DTransferFunction* tf = new Geometry1DTransferFunction(256);
tf->addGeometry(TFGeometry1D::createQuad(cgt::vec2(0.0f, 1.0f), cgt::col4(0, 0, 0, 255), cgt::col4(0, 0, 0, 0)));
_usFusion.p_confidenceTF.replaceTF(tf);
_usFusion.p_view.selectById("mappingSharpness");
forceExecuteProcessor(&_usFusion);
save(path, p_targetPathFuzzy.getValue());
}
}
......
......@@ -84,6 +84,8 @@ namespace campvis {
BoolProperty p_autoExecution;
StringProperty p_sourcePath;
StringProperty p_targetPathCm;
StringProperty p_targetPathColorOverlay;
StringProperty p_targetPathColor;
StringProperty p_targetPathFuzzy;
IVec2Property p_range;
......
......@@ -423,7 +423,8 @@ namespace campvis {
std::stringstream stream;
stream << "time, originalWidth, originalHeight, downsampledWidth, downsampledHeight, gaussianKernelSize, scalingFactor, alpha, beta, gamma, gradientScaling, iterations, solverExecutionTime, totalExecutionTime, solverError" << std::endl;
for (auto& item : _statistics) {
for (auto it = _statistics.begin(); it != _statistics.end(); ++it) {
auto& item = *it;
stream << item.time << ", ";
stream << item.originalWidth << ", ";
stream << item.originalHeight << ", ";
......
......@@ -134,7 +134,7 @@ namespace campvis {
_output[x + imageSize.x * y] = tmp[column + imageSize.y * row];
}
else {
_output[x + imageSize.x * y] = 0.f;
_output[x + imageSize.x * y] = 1.f;
}
}
}
......@@ -193,6 +193,8 @@ namespace campvis {
void ConfidenceMapGenerator::updateResult(DataContainer& data) {
ImageRepresentationLocal::ScopedRepresentation input(data, p_sourceImageID.getValue());
GenericImageRepresentationLocal<float, 1>::ScopedRepresentation previousResult(data, p_targetImageID.getValue());
GenericImageRepresentationLocal<float, 1>::ScopedRepresentation velocities(data, p_targetImageID.getValue() + "velocities");
if (input != 0 && input->getDimensionality() >= 2 && input->getParent()->getNumChannels() >= 1) {
const cgt::svec3& imageSize = input->getSize();
......@@ -204,7 +206,48 @@ namespace campvis {
CMGenerator(input, outputValues, this));
ImageData* output = new ImageData(input->getDimensionality(), cgt::svec3(input->getSize().x, input->getSize().y, 1), 1);
GenericImageRepresentationLocal<float, 1>::create(output, outputValues);
auto outRep = GenericImageRepresentationLocal<float, 1>::create(output, outputValues);
float dt = 0.5f;
float a = 0.36f;
float b = 0.005f;
if (previousResult && velocities && previousResult->getNumElements() == outRep->getNumElements() && velocities->getNumElements() == outRep->getNumElements()) {
tbb::parallel_for(tbb::blocked_range<size_t>(0, outRep->getNumElements()), [&] (const tbb::blocked_range<size_t>& range) {
for (size_t i = range.begin(); i != range.end(); ++i) {
float xk = previousResult->getElement(i) + (velocities->getElement(i) * dt);
float vk = velocities->getElement(i);
float rk = outRep->getElement(i) - xk;
xk += a * rk;
vk += (b*rk) / dt;
outRep->setElement(i, xk);
const_cast<GenericImageRepresentationLocal<float, 1>*>(&*velocities)->setElement(i, vk);
}
});
}
else {
ImageData* velocityImage = new ImageData(input->getDimensionality(), cgt::svec3(input->getSize().x, input->getSize().y, 1), 1);
auto veloRep = GenericImageRepresentationLocal<float, 1>::create(velocityImage, nullptr);
tbb::parallel_for(tbb::blocked_range<size_t>(0, outRep->getNumElements()), [&] (const tbb::blocked_range<size_t>& range) {
for (size_t i = range.begin(); i != range.end(); ++i) {
float xk = 0.f;
float vk = 0.f;
float rk = outRep->getElement(i) - xk;
xk += a * rk;
vk += (b*rk) / dt;
veloRep->setElement(i, vk);
}
});
data.addData(p_targetImageID.getValue() + "velocities", velocityImage);
}
data.addData(p_targetImageID.getValue(), output);
}
else {
......
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