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

Refactored ConfidenceMapGenerator: Extracted scanline conversion from...

Refactored ConfidenceMapGenerator: Extracted scanline conversion from Cartesian to polar coordinates into separate ScanlineConverter processor. Updated CmBatchGeneration pipeline.
parent 8bc22f3c
......@@ -31,11 +31,18 @@
#include "modules/modulesapi.h"
#include "modules/devil/processors/devilimagereader.h"
#include "modules/devil/processors/devilimagewriter.h"
#include "modules/advancedusvis/processors/advancedusfusion.h"
#include "modules/advancedusvis/processors/scanlineconverter.h"
#include "modules/preprocessing/processors/glgaussianfilter.h"
#include "modules/randomwalk/processors/confidencemapgenerator.h"
namespace cgt {
class Shader;
}
namespace campvis {
class CAMPVIS_MODULES_API CmBatchGeneration : public AutoEvaluationPipeline {
public:
/**
......@@ -57,37 +64,38 @@ namespace campvis {
static const std::string getId() { return "CmBatchGeneration"; };
/**
* Execute this pipeline.
**/
void execute();
virtual void paint() override;
protected:
/**
* Slot getting called when one of the observed processors got invalidated.
* Overwrites the default behaviour to do nothing.
*/
virtual void onProcessorInvalidated(AbstractProcessor* processor);
void onPropertyChanged(const AbstractProperty* p) override;
virtual void onProcessorInvalidated(AbstractProcessor* processor) override;
void startBatchProcess();
void executePass(int path);
void save(const std::string& dataName, const std::string& fileName);
void save(int path, const std::string& basePath);
DevilImageReader _usReader; ///< Reads the original image
ScanlineConverter _scanlineConverter; ///< Performs a scanline conversion
ConfidenceMapGenerator _confidenceGenerator; ///< Computes the CM using the original RandomWalks library
GlGaussianFilter _usBlurFilter; ///< Performs a Gaussian Blur
AdvancedUsFusion _usFusion; ///< Applies the Uncertainty Visualization
DevilImageReader _usReader;
ConfidenceMapGenerator _confidenceGenerator;
GlGaussianFilter _usBlurFilter;
AdvancedUsFusion _usFusion;
DevilImageWriter _imageWriter; ///< Used to write out images
BoolProperty p_autoExecution;
BoolProperty p_showFan;
StringProperty p_sourcePath; ///< Path for the input images
StringProperty p_targetPathResampled; ///< Path for the resampled images
StringProperty p_targetPathCmCpu; ///< Path for the CPU-computed Confidence Maps
StringProperty p_targetPathColorOverlay; ///< Path for the color overlay visualization
StringProperty p_targetPathColor; ///< Path for the color modulation visualization
StringProperty p_targetPathFuzzy; ///< Path for the fuzziness visualization
StringProperty p_sourcePath;
StringProperty p_targetPathCm;
StringProperty p_targetPathColorOverlay;
StringProperty p_targetPathColor;
StringProperty p_targetPathFuzzy;
IVec2Property p_range;
IVec2Property p_range; ///< Range for image iteration
ButtonProperty p_execute; ///< Button to start the batch process
ButtonProperty p_execute;
cgt::Shader* _shader;
};
}
......
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012-2015, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universitaet Muenchen
// Boltzmannstr. 3, 85748 Garching b. Muenchen, Germany
//
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.
//
// ================================================================================================
#include "scanlineconverter.h"
#include "cgt/logmanager.h"
#include "cgt/cgt_math.h"
#include "cgt/vector.h"
#include "core/tools/interval.h"
#include "core/datastructures/imagedata.h"
#include "core/datastructures/genericimagerepresentationlocal.h"
namespace campvis {
const std::string ScanlineConverter::loggerCat_ = "CAMPVis.modules.classification.ScanlineConverter";
ScanlineConverter::ScanlineConverter()
: AbstractProcessor()
, p_sourceImageID("InputImage", "Input Image ID", "image", DataNameProperty::READ)
, p_targetImageID("OutputConfidenceMap", "Output Confidence Map Image ID", "confidencemap", DataNameProperty::WRITE)
, p_targetSize("TargetSize", "Target Image Size", cgt::ivec2(512, 512), cgt::ivec2(16, 16), cgt::ivec2(2048, 2048))
, p_origin("PolarOrigin", "Polar Origin", cgt::vec2(340.f, 536.f), cgt::vec2(-1000.f), cgt::vec2(1000.f), cgt::vec2(0.1f))
, p_angles("PolarAngles", "Polar Angles", cgt::vec2(233.f, 308.f), cgt::vec2(0.f), cgt::vec2(360.f), cgt::vec2(0.1f))
, p_lengths("PolarLengths", "Polar Lengths", cgt::vec2(116.f, 540.f), cgt::vec2(0.f), cgt::vec2(1000.f), cgt::vec2(0.1f))
{
addProperty(p_sourceImageID);
addProperty(p_targetImageID);
addProperty(p_targetSize);
addProperty(p_origin);
addProperty(p_angles);
addProperty(p_lengths);
}
ScanlineConverter::~ScanlineConverter() {
}
std::vector<cgt::vec3> ScanlineConverter::generateLookupVertices(const ImageData* inputImage) const {
cgtAssert(inputImage != nullptr, "Input image must not be 0!");
std::vector<cgt::vec3> vertices;
const cgt::ivec2 inputSize = inputImage->getSize().xy();
const cgt::ivec2& outputSize = p_targetSize.getValue();
const float rarara = cgt::PIf / 180.f;
Interval<float> fanAngles(p_angles.getValue().x * rarara, p_angles.getValue().y * rarara);
Interval<float> fanSize(p_lengths.getValue().x, p_lengths.getValue().y);
for (size_t y = 0; y < outputSize.y; ++y) {
float r = fanSize.getLeft() + static_cast<float>(outputSize.y - 1 -y) / static_cast<float>(outputSize.y) * fanSize.size();
for (int x = 0; x < outputSize.x; ++x) {
float phi = fanAngles.getLeft() + (static_cast<float>(x) / static_cast<float>(outputSize.x) * fanAngles.size());
const cgt::vec3 cc(r * cos(phi) + p_origin.getValue().x, r * sin(phi) + p_origin.getValue().y, 0.f);
vertices.push_back(cc);
}
}
return vertices;
}
void ScanlineConverter::updateResult(DataContainer& dataContainer) {
ImageRepresentationLocal::ScopedRepresentation input(dataContainer, p_sourceImageID.getValue());
if (input != 0 && input->getDimensionality() == 2) {
// resample image
size_t numChannels = input->getParent()->getNumChannels();
auto outputImage = new ImageData(2, cgt::vec3(p_targetSize.getValue().x, p_targetSize.getValue().y, 1), numChannels);
auto wtp = input->getWeaklyTypedPointer();
wtp._pointer = nullptr;
auto outputRep = ImageRepresentationLocal::create(outputImage, wtp);
auto vertices = generateLookupVertices(input->getParent());
for (size_t i = 0; i < vertices.size(); ++i) {
for (size_t c = 0; c < numChannels; ++c) {
outputRep->setElementNormalized(i, c, input->getElementNormalizedLinear(vertices[i], c));
}
}
dataContainer.addData(p_targetImageID.getValue(), outputImage);
}
else {
LDEBUG("No suitable input image found.");
}
}
}
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012-2015, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universitaet Muenchen
// Boltzmannstr. 3, 85748 Garching b. Muenchen, Germany
//
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.
//
// ================================================================================================
#ifndef SCANLINECONVERTER_H__
#define SCANLINECONVERTER_H__
#include "core/pipeline/abstractprocessor.h"
#include "core/properties/datanameproperty.h"
#include "core/properties/floatingpointproperty.h"
#include "core/properties/numericproperty.h"
#include "core/properties/optionproperty.h"
#include "modules/modulesapi.h"
namespace campvis {
class ImageData;
/**
* Performs scanline conversion from a curvilinear (US) image in a rectilinear image into
* a rectilinear image given the fan parameters.
*/
class CAMPVIS_MODULES_API ScanlineConverter : public AbstractProcessor {
public:
/**
* Constructs a new ScanlineConverter Processor
**/
ScanlineConverter();
/**
* Destructor
**/
virtual ~ScanlineConverter();
/// \see AbstractProcessor::getName()
virtual const std::string getName() const { return "ScanlineConverter"; };
/// \see AbstractProcessor::getDescription()
virtual const std::string getDescription() const { return "Performs scanline conversion from a curvilinear (US) image in a rectilinear image into a rectilinear image given the fan parameters."; };
/// \see AbstractProcessor::getAuthor()
virtual const std::string getAuthor() const { return "Christian Schulte zu Berge <christian.szb@in.tum.de>"; };
/// \see AbstractProcessor::getProcessorState()
virtual ProcessorState getProcessorState() const { return AbstractProcessor::TESTING; };
/**
* Generates all the lookup vertices for the target image in pixel coordinates of the input image.
* \param inputImage Pointer to the input image (required for meta data)
* \return A vector of all lookup vertices in the input image.
*/
std::vector<cgt::vec3> generateLookupVertices(const ImageData* inputImage) const;
DataNameProperty p_sourceImageID; ///< ID for input image
DataNameProperty p_targetImageID; ///< ID for output confidence map image
IVec2Property p_targetSize; ///< Target image size
Vec2Property p_origin; ///< Origin of the fan in the input image
Vec2Property p_angles; ///< Start and end angles of the fan
Vec2Property p_lengths; ///< Start and end radius of the fan
protected:
/// \see AbstractProcessor::updateResult
virtual void updateResult(DataContainer& dataContainer);
static const std::string loggerCat_;
};
}
#endif // SCANLINECONVERTER_H__
......@@ -69,11 +69,6 @@ namespace campvis {
GenericOptionProperty<std::string> p_solver; ///< Solver to use
IntProperty p_numSteps;
BoolProperty p_curvilinear;
Vec2Property p_origin;
Vec2Property p_angles;
Vec2Property p_lengths;
protected:
/// \see AbstractProcessor::updateResult
virtual void updateResult(DataContainer& dataContainer);
......
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